Merge pull request #229 from alimy/pr-pg-ddl

add PostgreSQL DDL file
pull/242/head v0.2.3
北野 - Michael Li 2 years ago committed by GitHub
commit d560a90aa6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -4,6 +4,17 @@ All notable changes to paopao-ce are documented in this file.
## 0.3.0+dev ([`dev`](https://github.com/rocboss/paopao-ce/tree/dev))
## 0.2.3
### Added
- add PostgreSQL DDL file [#229](https://github.com/rocboss/paopao-ce/pull/229)
### Changed
- optimize MySQL DDL file [#229](https://github.com/rocboss/paopao-ce/pull/229)
- optimize Sqlite3 DDL file [#229](https://github.com/rocboss/paopao-ce/pull/229)
## 0.2.2
### Fixed

@ -171,10 +171,11 @@ Postgres: # PostgreSQL数据库
User: paopao
Password: paopao
DBName: paopao
Schema: public
Host: localhost
Port: 5432
SSLMode: disable
TimeZone: Asia/Shanghai
ApplicationName:
Sqlite3: # Sqlite3数据库
Path: custom/data/sqlite3/paopao-ce.db
Redis:

@ -301,8 +301,18 @@ func (s *MySQLSettingS) Dsn() string {
func (s PostgresSettingS) Dsn() string {
var params []string
for k, v := range s {
if len(v) > 0 {
params = append(params, strings.ToLower(k)+"="+v)
if len(v) == 0 {
continue
}
lk := strings.ToLower(k)
tv := strings.Trim(v, " ")
switch lk {
case "schema":
params = append(params, "search_path="+tv)
case "applicationname":
params = append(params, "application_name="+tv)
default:
params = append(params, lk+"="+tv)
}
}
return strings.Join(params, " ")

@ -7,6 +7,7 @@ package dbr
import (
"github.com/sirupsen/logrus"
"gorm.io/gorm"
"gorm.io/gorm/clause"
)
const (
@ -73,7 +74,7 @@ func (c *Contact) List(db *gorm.DB, conditions ConditionsT, offset, limit int) (
}
}
db.Joins("User").Order("`User`.`nickname` ASC")
db.Joins("User").Order(clause.OrderByColumn{Column: clause.Column{Name: "nickname"}, Desc: false})
if err = db.Find(&contacts).Error; err != nil {
return nil, err
}

@ -8,6 +8,7 @@ import (
"time"
"gorm.io/gorm"
"gorm.io/gorm/clause"
)
type PostCollection struct {
@ -31,7 +32,7 @@ func (p *PostCollection) Get(db *gorm.DB) (*PostCollection, error) {
db = db.Where(tn+"user_id = ?", p.UserID)
}
db = db.Joins("Post").Where("Post.visibility <> ?", PostVisitPrivate).Order("Post.id DESC")
db = db.Joins("Post").Where("visibility <> ?", PostVisitPrivate).Order(clause.OrderByColumn{Column: clause.Column{Table: "Post", Name: "id"}, Desc: true})
err := db.First(&star).Error
if err != nil {
return &star, err
@ -73,7 +74,7 @@ func (p *PostCollection) List(db *gorm.DB, conditions *ConditionsT, offset, limi
}
}
db = db.Joins("Post").Where("Post.visibility <> ?", PostVisitPrivate).Order("Post.id DESC")
db = db.Joins("Post").Where(`visibility <> ?`, PostVisitPrivate).Order(clause.OrderByColumn{Column: clause.Column{Table: "Post", Name: "id"}, Desc: true})
if err = db.Where(tn+"is_del = ?", 0).Find(&collections).Error; err != nil {
return nil, err
}
@ -97,7 +98,7 @@ func (p *PostCollection) Count(db *gorm.DB, conditions *ConditionsT) (int64, err
}
}
db = db.Joins("Post").Where("Post.visibility <> ?", PostVisitPrivate)
db = db.Joins("Post").Where(`visibility <> ?`, PostVisitPrivate)
if err := db.Model(p).Count(&count).Error; err != nil {
return 0, err
}

@ -8,6 +8,7 @@ import (
"time"
"gorm.io/gorm"
"gorm.io/gorm/clause"
)
type PostStar struct {
@ -31,7 +32,7 @@ func (p *PostStar) Get(db *gorm.DB) (*PostStar, error) {
db = db.Where(tn+"user_id = ?", p.UserID)
}
db = db.Joins("Post").Where("Post.visibility <> ?", PostVisitPrivate).Order("Post.id DESC")
db = db.Joins("Post").Where("visibility <> ?", PostVisitPrivate).Order(clause.OrderByColumn{Column: clause.Column{Table: "Post", Name: "id"}, Desc: true})
if err := db.First(&star).Error; err != nil {
return nil, err
}
@ -71,7 +72,7 @@ func (p *PostStar) List(db *gorm.DB, conditions *ConditionsT, offset, limit int)
}
}
db = db.Joins("Post").Where("Post.visibility <> ?", PostVisitPrivate).Order("Post.id DESC")
db = db.Joins("Post").Where("visibility <> ?", PostVisitPrivate).Order(clause.OrderByColumn{Column: clause.Column{Table: "Post", Name: "id"}, Desc: true})
if err = db.Find(&stars).Error; err != nil {
return nil, err
}
@ -94,7 +95,7 @@ func (p *PostStar) Count(db *gorm.DB, conditions *ConditionsT) (int64, error) {
}
}
db = db.Joins("Post").Where("Post.visibility <> ?", PostVisitPrivate)
db = db.Joins("Post").Where("visibility <> ?", PostVisitPrivate)
if err := db.Model(p).Count(&count).Error; err != nil {
return 0, err
}

@ -1,3 +1 @@
ALTER TABLE `p_post` DROP COLUMN `visibility`;
DROP INDEX `idx_visibility` ON `p_post`;

@ -1,3 +1,2 @@
ALTER TABLE `p_post` ADD COLUMN `visibility` tinyint unsigned NOT NULL DEFAULT '0' COMMENT '可见性 0公开 1私密 2好友可见';
CREATE INDEX `idx_visibility` ON `p_post` ( `visibility` ) USING BTREE;

@ -0,0 +1,66 @@
ALTER TABLE `p_attachment`
RENAME KEY `idx_attachment_user_id` TO `idx_user`;
ALTER TABLE `p_captcha`
RENAME KEY `idx_captcha_phone` TO `idx_phone`,
RENAME KEY `idx_captcha_expired_on` TO `idx_expired_on`,
RENAME KEY `idx_captcha_use_times` TO `idx_use_times`;
ALTER TABLE `p_comment`
RENAME KEY `idx_comment_post_id` TO `idx_post`,
RENAME KEY `idx_comment_user_id` TO `idx_user`;
ALTER TABLE `p_comment_content`
RENAME KEY `idx_comment_content_comment_id` TO `idx_reply`,
RENAME KEY `idx_comment_content_user_id` TO `idx_user`,
RENAME KEY `idx_comment_content_type` TO `idx_type`,
RENAME KEY `idx_comment_content_sort` TO `idx_sort`;
ALTER TABLE `p_comment_reply`
RENAME KEY `idx_comment_reply_comment_id` TO `idx_comment`;
ALTER TABLE `p_message`
RENAME KEY `idx_message_receiver_user_id` TO `idx_receiver`,
RENAME KEY `idx_message_is_read` TO `idx_is_read`,
RENAME KEY `idx_message_type` TO `idx_type`;
ALTER TABLE `p_post`
RENAME KEY `idx_post_user_id` TO `idx_user`,
RENAME KEY `idx_post_visibility` TO `idx_visibility`;
ALTER TABLE `p_post_attachment_bill`
RENAME KEY `idx_post_attachment_bill_post_id` TO `idx_post`,
RENAME KEY `idx_post_attachment_bill_user_id` TO `idx_user`;
ALTER TABLE `p_post_collection`
RENAME KEY `idx_post_collection_post_id` TO `idx_post`,
RENAME KEY `idx_post_collection_user_id` TO `idx_user`;
ALTER TABLE `p_post_content`
RENAME KEY `idx_post_content_post_id` TO `idx_post`,
RENAME KEY `idx_post_content_user_id` TO `idx_user`;
ALTER TABLE `p_post_star`
RENAME KEY `idx_post_star_post_id` TO `idx_post`,
RENAME KEY `idx_post_star_user_id` TO `idx_user`;
ALTER TABLE `p_tag`
RENAME KEY `idx_tag_user_id` TO `idx_user`,
RENAME KEY `idx_tag_quote_num` TO `idx_num`;
ALTER TABLE `p_user`
RENAME KEY `idx_user_username` TO `idx_username`,
RENAME KEY `idx_user_phone` TO `idx_phone`;
ALTER TABLE `p_wallet_recharge`
RENAME KEY `idx_wallet_recharge_user_id` TO `idx_user`,
RENAME KEY `idx_wallet_recharge_trade_no` TO `idx_trade_no`,
RENAME KEY `idx_wallet_recharge_trade_status` TO `idx_trade_status`;
ALTER TABLE `p_wallet_statement`
RENAME KEY `idx_wallet_statement_user_id` TO `idx_user`;
ALTER TABLE `p_contact`
RENAME KEY `idx_contact_user_friend` TO `idx_user_friend_id`,
RENAME KEY `idx_contact_user_friend_status` TO `idx_user_friend_status`;

@ -0,0 +1,65 @@
ALTER TABLE `p_attachment`
RENAME KEY `idx_user` TO `idx_attachment_user_id`;
ALTER TABLE `p_captcha`
RENAME KEY `idx_phone` TO `idx_captcha_phone`,
RENAME KEY `idx_expired_on` TO `idx_captcha_expired_on`,
RENAME KEY `idx_use_times` TO `idx_captcha_use_times`;
ALTER TABLE `p_comment`
RENAME KEY `idx_post` TO `idx_comment_post_id`,
RENAME KEY `idx_user` TO `idx_comment_user_id`;
ALTER TABLE `p_comment_content`
RENAME KEY `idx_reply` TO `idx_comment_content_comment_id`,
RENAME KEY `idx_user` TO `idx_comment_content_user_id`,
RENAME KEY `idx_type` TO `idx_comment_content_type`,
RENAME KEY `idx_sort` TO `idx_comment_content_sort`;
ALTER TABLE `p_comment_reply`
RENAME KEY `idx_comment` TO `idx_comment_reply_comment_id`;
ALTER TABLE `p_message`
RENAME KEY `idx_receiver` TO `idx_message_receiver_user_id`,
RENAME KEY `idx_is_read` TO `idx_message_is_read`,
RENAME KEY `idx_type` TO `idx_message_type`;
ALTER TABLE `p_post`
RENAME KEY `idx_user` TO `idx_post_user_id`,
RENAME KEY `idx_visibility` TO `idx_post_visibility`;
ALTER TABLE `p_post_attachment_bill`
RENAME KEY `idx_post` TO `idx_post_attachment_bill_post_id`,
RENAME KEY `idx_user` TO `idx_post_attachment_bill_user_id`;
ALTER TABLE `p_post_collection`
RENAME KEY `idx_post` TO `idx_post_collection_post_id`,
RENAME KEY `idx_user` TO `idx_post_collection_user_id`;
ALTER TABLE `p_post_content`
RENAME KEY `idx_post` TO `idx_post_content_post_id`,
RENAME KEY `idx_user` TO `idx_post_content_user_id`;
ALTER TABLE `p_post_star`
RENAME KEY `idx_post` TO `idx_post_star_post_id`,
RENAME KEY `idx_user` TO `idx_post_star_user_id`;
ALTER TABLE `p_tag`
RENAME KEY `idx_user` TO `idx_tag_user_id`,
RENAME KEY `idx_num` TO `idx_tag_quote_num`;
ALTER TABLE `p_user`
RENAME KEY `idx_username` TO `idx_user_username`,
RENAME KEY `idx_phone` TO `idx_user_phone`;
ALTER TABLE `p_wallet_recharge`
RENAME KEY `idx_user` TO `idx_wallet_recharge_user_id`,
RENAME KEY `idx_trade_no` TO `idx_wallet_recharge_trade_no`,
RENAME KEY `idx_trade_status` TO `idx_wallet_recharge_trade_status`;
ALTER TABLE `p_wallet_statement`
RENAME KEY `idx_user` To `idx_wallet_statement_user_id`;
ALTER TABLE `p_contact`
RENAME KEY `idx_user_friend_id` TO `idx_contact_user_friend`,
RENAME KEY `idx_user_friend_status` TO `idx_contact_user_friend_status`;

@ -0,0 +1,16 @@
DROP TABLE IF EXISTS p_attachment;
DROP TABLE IF EXISTS p_captcha;
DROP TABLE IF EXISTS p_comment;
DROP TABLE IF EXISTS p_comment_content;
DROP TABLE IF EXISTS p_comment_reply;
DROP TABLE IF EXISTS p_message;
DROP TABLE IF EXISTS p_post;
DROP TABLE IF EXISTS p_post_attachment_bill;
DROP TABLE IF EXISTS p_post_collection;
DROP TABLE IF EXISTS p_post_content;
DROP TABLE IF EXISTS p_post_star;
DROP TABLE IF EXISTS p_tag;
DROP TABLE IF EXISTS p_user;
DROP TABLE IF EXISTS p_wallet_recharge;
DROP TABLE IF EXISTS p_wallet_statement;
DROP SEQUENCE IF EXISTS post_id_seq;

@ -0,0 +1,232 @@
CREATE TABLE p_attachment (
id BIGSERIAL PRIMARY KEY,
user_id BIGINT NOT NULL DEFAULT 0,
file_size BIGINT NOT NULL,
img_width BIGINT NOT NULL DEFAULT 0,
img_height BIGINT NOT NULL DEFAULT 0,
"type" SMALLINT NOT NULL DEFAULT 1, -- 1图片、2视频、3其他附件
content VARCHAR(255) NOT NULL DEFAULT '',
created_on BIGINT NOT NULL DEFAULT 0,
modified_on BIGINT NOT NULL DEFAULT 0,
deleted_on BIGINT NOT NULL DEFAULT 0,
is_del SMALLINT NOT NULL DEFAULT 0 -- 是否删除 0为未删除、1为已删除
);
CREATE INDEX idx_attachment_user_id ON p_attachment USING btree (id);
CREATE TABLE p_captcha (
id BIGSERIAL PRIMARY KEY,
phone VARCHAR(16),
captcha VARCHAR(16),
use_times INTEGER NOT NULL DEFAULT 0,
expired_on BIGINT NOT NULL DEFAULT 0,
created_on BIGINT NOT NULL DEFAULT 0,
modified_on BIGINT NOT NULL DEFAULT 0,
deleted_on BIGINT NOT NULL DEFAULT 0,
is_del SMALLINT NOT NULL DEFAULT 0 -- 是否删除 0为未删除、1为已删除'
);
CREATE INDEX idx_captcha_phone ON p_captcha USING btree (phone);
CREATE INDEX idx_captcha_expired_on ON p_captcha USING btree (expired_on);
CREATE INDEX idx_captcha_use_times ON p_captcha USING btree (use_times);
CREATE TABLE p_comment (
id BIGSERIAL PRIMARY KEY,
post_id BIGINT NOT NULL DEFAULT 0,
user_id BIGINT NOT NULL DEFAULT 0,
ip VARCHAR(64) NOT NULL DEFAULT '',
ip_loc VARCHAR(64) NOT NULL DEFAULT '',
created_on BIGINT NOT NULL DEFAULT 0,
modified_on BIGINT NOT NULL DEFAULT 0,
deleted_on BIGINT NOT NULL DEFAULT 0,
is_del SMALLINT NOT NULL DEFAULT 0
);
CREATE INDEX idx_comment_post_id ON p_comment USING btree (post_id);
CREATE INDEX idx_comment_user_id ON p_comment USING btree (user_id);
CREATE TABLE p_comment_content (
id BIGSERIAL PRIMARY KEY,
comment_id BIGINT NOT NULL DEFAULT 0,
user_id BIGINT NOT NULL DEFAULT 0,
content VARCHAR(255) NOT NULL DEFAULT '',
"type" SMALLINT NOT NULL DEFAULT 2, -- 类型1标题2文字段落3图片地址4视频地址5语音地址6链接地址,
sort BIGINT NOT NULL DEFAULT 100,
created_on BIGINT NOT NULL DEFAULT 0,
modified_on BIGINT NOT NULL DEFAULT 0,
deleted_on BIGINT NOT NULL DEFAULT 0,
is_del SMALLINT NOT NULL DEFAULT 0
);
CREATE INDEX idx_comment_content_comment_id ON p_comment_content USING btree (comment_id);
CREATE INDEX idx_comment_content_user_id ON p_comment_content USING btree (user_id);
CREATE INDEX idx_comment_content_type ON p_comment_content USING btree ("type");
CREATE INDEX idx_comment_content_sort ON p_comment_content USING btree (sort);
CREATE TABLE p_comment_reply (
id BIGSERIAL PRIMARY KEY,
comment_id BIGINT NOT NULL DEFAULT 0,
user_id BIGINT NOT NULL DEFAULT 0,
at_user_id BIGINT NOT NULL DEFAULT 0,
content VARCHAR(255) NOT NULL DEFAULT '',
ip VARCHAR(64) NOT NULL DEFAULT '',
ip_loc VARCHAR(64) NOT NULL DEFAULT '',
created_on BIGINT NOT NULL DEFAULT 0,
modified_on BIGINT NOT NULL DEFAULT 0,
deleted_on BIGINT NOT NULL DEFAULT 0,
is_del SMALLINT NOT NULL DEFAULT 0
);
CREATE INDEX idx_comment_reply_comment_id ON p_comment_reply USING btree (comment_id);
CREATE TABLE p_message (
id BIGSERIAL PRIMARY KEY,
sender_user_id BIGINT NOT NULL DEFAULT 0,
receiver_user_id BIGINT NOT NULL DEFAULT 0,
type SMALLINT NOT NULL DEFAULT 1,
brief VARCHAR(255) NOT NULL DEFAULT '',
content VARCHAR(255) NOT NULL DEFAULT '',
post_id BIGINT NOT NULL DEFAULT 0,
comment_id BIGINT NOT NULL DEFAULT 0,
reply_id BIGINT NOT NULL DEFAULT 0,
is_read SMALLINT NOT NULL DEFAULT 0,
created_on BIGINT NOT NULL DEFAULT 0,
modified_on BIGINT NOT NULL DEFAULT 0,
deleted_on BIGINT NOT NULL DEFAULT 0,
is_del SMALLINT NOT NULL DEFAULT 0
);
CREATE INDEX idx_message_receiver_user_id ON p_message USING btree (receiver_user_id);
CREATE INDEX idx_message_is_read ON p_message USING btree (is_read);
CREATE INDEX idx_message_type ON p_message USING btree ("type");
CREATE SEQUENCE IF NOT EXISTS post_id_seq AS BIGINT MINVALUE 1080017989 NO MAXVALUE;
CREATE TABLE p_post (
id BIGINT NOT NULL DEFAULT nextval('post_id_seq'::regclass),
user_id BIGINT NOT NULL DEFAULT 0,
comment_count BIGINT NOT NULL DEFAULT 0,
collection_count BIGINT NOT NULL DEFAULT 0,
upvote_count BIGINT NOT NULL DEFAULT 0,
is_top SMALLINT NOT NULL DEFAULT 0, -- 是否置顶
is_essence SMALLINT NOT NULL DEFAULT 0, -- 是否精华
is_lock SMALLINT NOT NULL DEFAULT 0, -- 是否锁定
latest_replied_on BIGINT NOT NULL DEFAULT 0, -- 最新回复时间
tags VARCHAR(255) NOT NULL DEFAULT '',
attachment_price BIGINT NOT NULL DEFAULT 0, -- 附件价格(分)
ip VARCHAR(64) NOT NULL DEFAULT '', -- IP地址
ip_loc VARCHAR(64) NOT NULL DEFAULT '', -- IP城市地址
created_on BIGINT NOT NULL DEFAULT 0,
modified_on BIGINT NOT NULL DEFAULT 0,
deleted_on BIGINT NOT NULL DEFAULT 0,
is_del SMALLINT NOT NULL DEFAULT 0,
PRIMARY KEY (id)
);
CREATE INDEX idx_post_user_id ON p_post USING btree (user_id);
CREATE TABLE p_post_attachment_bill (
id BIGSERIAL PRIMARY KEY,
post_id BIGINT NOT NULL DEFAULT 0,
user_id BIGINT NOT NULL DEFAULT 0,
paid_amount BIGINT NOT NULL DEFAULT 0, -- 支付金额
created_on BIGINT NOT NULL DEFAULT 0,
modified_on BIGINT NOT NULL DEFAULT 0,
deleted_on BIGINT NOT NULL DEFAULT 0,
is_del SMALLINT NOT NULL DEFAULT 0
);
CREATE INDEX idx_post_attachment_bill_post_id ON p_post_attachment_bill USING btree (post_id);
CREATE INDEX idx_post_attachment_bill_user_id ON p_post_attachment_bill USING btree (user_id);
CREATE TABLE p_post_collection (
id BIGSERIAL PRIMARY KEY,
post_id BIGINT NOT NULL DEFAULT 0,
user_id BIGINT NOT NULL DEFAULT 0,
created_on BIGINT NOT NULL DEFAULT 0,
modified_on BIGINT NOT NULL DEFAULT 0,
deleted_on BIGINT NOT NULL DEFAULT 0,
is_del SMALLINT NOT NULL DEFAULT 0
);
CREATE INDEX idx_post_collection_post_id ON p_post_collection USING btree (post_id);
CREATE INDEX idx_post_collection_user_id ON p_post_collection USING btree (user_id);
CREATE TABLE p_post_content (
id BIGSERIAL PRIMARY KEY,
post_id BIGINT NOT NULL DEFAULT 0,
user_id BIGINT NOT NULL DEFAULT 0,
content VARCHAR(2000) NOT NULL DEFAULT '',
"type" SMALLINT NOT NULL DEFAULT 2, -- 类型1标题2文字段落3图片地址4视频地址5语音地址6链接地址7附件资源8收费资源
sort SMALLINT NOT NULL DEFAULT 100,
created_on BIGINT NOT NULL DEFAULT 0,
modified_on BIGINT NOT NULL DEFAULT 0,
deleted_on BIGINT NOT NULL DEFAULT 0,
is_del SMALLINT NOT NULL DEFAULT 0
);
CREATE INDEX idx_post_content_post_id ON p_post_content USING btree (post_id);
CREATE INDEX idx_post_content_user_id ON p_post_content USING btree (user_id);
CREATE TABLE p_post_star (
id BIGSERIAL PRIMARY KEY,
post_id BIGINT NOT NULL DEFAULT 0,
user_id BIGINT NOT NULL DEFAULT 0,
created_on BIGINT NOT NULL DEFAULT 0,
modified_on BIGINT NOT NULL DEFAULT 0,
deleted_on BIGINT NOT NULL DEFAULT 0,
is_del SMALLINT NOT NULL DEFAULT 0
);
CREATE INDEX idx_post_star_post_id ON p_post_star USING btree (post_id);
CREATE INDEX idx_post_star_user_id ON p_post_star USING btree (user_id);
CREATE TABLE p_tag (
id BIGSERIAL PRIMARY KEY,
user_id BIGINT NOT NULL DEFAULT 0,
tag VARCHAR(255) NOT NULL,
quote_num BIGINT NOT NULL DEFAULT 0, -- 引用数
created_on BIGINT NOT NULL DEFAULT 0,
modified_on BIGINT NOT NULL DEFAULT 0,
deleted_on BIGINT NOT NULL DEFAULT 0,
is_del SMALLINT NOT NULL DEFAULT 0
);
CREATE UNIQUE INDEX idx_tag_tag ON p_tag USING btree (tag);
CREATE INDEX idx_tag_user_id ON p_tag USING btree (user_id);
CREATE INDEX idx_tag_quote_num ON p_tag USING btree (quote_num);
CREATE TABLE p_user (
id BIGSERIAL PRIMARY KEY,
nickname VARCHAR(32) NOT NULL DEFAULT '',
username VARCHAR(32) NOT NULL DEFAULT '',
phone VARCHAR(16) NOT NULL DEFAULT '', -- 手机号
password VARCHAR(32) NOT NULL DEFAULT '', -- MD5密码
salt VARCHAR(16) NOT NULL DEFAULT '', -- 盐值
status SMALLINT NOT NULL DEFAULT 1, -- 状态1正常2停用
avatar VARCHAR(255) NOT NULL DEFAULT '',
balance BIGINT NOT NULL, -- 用户余额(分)
is_admin BOOLEAN NOT NULL DEFAULT false, -- 是否管理员
created_on BIGINT NOT NULL DEFAULT 0,
modified_on BIGINT NOT NULL DEFAULT 0,
deleted_on BIGINT NOT NULL DEFAULT 0,
is_del SMALLINT NOT NULL DEFAULT 0
);
CREATE UNIQUE INDEX idx_user_username ON p_user USING btree (username);
CREATE INDEX idx_user_phone ON p_user USING btree (phone);
CREATE TABLE p_wallet_recharge (
id BIGSERIAL PRIMARY KEY,
user_id BIGINT NOT NULL DEFAULT 0,
amount BIGINT NOT NULL DEFAULT 0, -- 充值金额
trade_no VARCHAR(64) NOT NULL DEFAULT '', -- 支付宝订单号
trade_status VARCHAR(32) NOT NULL DEFAULT '', -- 交易状态
created_on BIGINT NOT NULL DEFAULT 0,
modified_on BIGINT NOT NULL DEFAULT 0,
deleted_on BIGINT NOT NULL DEFAULT 0,
is_del SMALLINT NOT NULL DEFAULT 0 -- 是否删除 0 为未删除、1 为已删除
);
CREATE INDEX idx_wallet_recharge_user_id ON p_wallet_recharge USING btree (user_id);
CREATE INDEX idx_wallet_recharge_trade_no ON p_wallet_recharge USING btree (trade_no);
CREATE INDEX idx_wallet_recharge_trade_status ON p_wallet_recharge USING btree (trade_status);
CREATE TABLE p_wallet_statement (
id BIGSERIAL PRIMARY KEY,
user_id BIGINT NOT NULL DEFAULT 0,
change_amount BIGINT NOT NULL DEFAULT 0, -- 变动金额
balance_snapshot BIGINT NOT NULL DEFAULT 0, -- 资金快照
reason VARCHAR(255) NOT NULL, -- 变动原因
post_id BIGINT NOT NULL DEFAULT 0, -- 关联动态
created_on BIGINT NOT NULL DEFAULT 0,
modified_on BIGINT NOT NULL DEFAULT 0,
deleted_on BIGINT NOT NULL DEFAULT 0,
is_del SMALLINT NOT NULL DEFAULT 0
);
CREATE INDEX idx_wallet_statement_user_id ON p_wallet_statement USING btree (user_id);

@ -0,0 +1 @@
ALTER TABLE p_post DROP COLUMN visibility;

@ -0,0 +1 @@
ALTER TABLE p_post ADD COLUMN visibility SMALLINT NOT NULL DEFAULT 0; -- 可见性 0公开 1私密 2好友可见

@ -0,0 +1,2 @@
DROP TABLE IF EXISTS p_contact;
DROP TABLE IF EXISTS p_contact_group;

@ -0,0 +1,27 @@
CREATE TABLE p_contact (
id BIGSERIAL PRIMARY KEY,
user_id BIGINT NOT NULL,
friend_id BIGINT NOT NULL,
group_id BIGINT NOT NULL DEFAULT 0, -- 好友分组ID:默认为0无分组
remark VARCHAR(32) NOT NULL DEFAULT '', -- 好友备注
status SMALLINT NOT NULL DEFAULT 0, -- 好友状态: 1请求好友, 2已好友, 3拒绝好友, 4已删好友
is_top SMALLINT NOT NULL DEFAULT 0, -- 是否置顶, 0否, 1是
is_black SMALLINT NOT NULL DEFAULT 0, -- 是否为黑名单, 0否, 1是
is_del SMALLINT NOT NULL DEFAULT 0, -- 否删除好友, 0否, 1是
notice_enable SMALLINT NOT NULL DEFAULT 0, -- 是否有消息提醒, 0否, 1是
created_on BIGINT NOT NULL DEFAULT 0,
modified_on BIGINT NOT NULL DEFAULT 0,
deleted_on BIGINT NOT NULL DEFAULT 0
);
CREATE UNIQUE INDEX idx_contact_user_friend ON p_contact USING btree (user_id,friend_id);
CREATE INDEX idx_contact_user_friend_status ON p_contact USING btree (user_id, friend_id, status);
CREATE TABLE p_contact_group (
id BIGSERIAL PRIMARY KEY,
user_id int NOT NULL DEFAULT 0,
name VARCHAR(32) NOT NULL DEFAULT '', -- 分组名称
is_del SMALLINT NOT NULL DEFAULT 1, -- 是否删除, 0否, 1是
created_on BIGINT NOT NULL DEFAULT 0,
modified_on BIGINT NOT NULL DEFAULT 0,
deleted_on BIGINT NOT NULL DEFAULT 0
);

@ -0,0 +1 @@
ALTER TABLE `p_post` DROP COLUMN `visibility`;

@ -0,0 +1,39 @@
PRAGMA foreign_keys = false;
DROP INDEX IF EXISTS "idx_attachment_user_id";
DROP INDEX IF EXISTS "idx_captcha_expired_on";
DROP INDEX IF EXISTS "idx_captcha_phone";
DROP INDEX IF EXISTS "idx_captcha_use_times";
DROP INDEX IF EXISTS "idx_comment_post_id";
DROP INDEX IF EXISTS "idx_comment_user_id";
DROP INDEX IF EXISTS "idx_comment_content_comment_id";
DROP INDEX IF EXISTS "idx_comment_content_sort";
DROP INDEX IF EXISTS "idx_comment_content_type";
DROP INDEX IF EXISTS "idx_comment_content_user_id";
DROP INDEX IF EXISTS "idx_comment_reply_comment_id";
DROP INDEX IF EXISTS "idx_contact_user_friend";
DROP INDEX IF EXISTS "idx_contact_user_friend_status";
DROP INDEX IF EXISTS "idx_message_is_read";
DROP INDEX IF EXISTS "idx_message_receiver_user_id";
DROP INDEX IF EXISTS "idx_message_type";
DROP INDEX IF EXISTS "idx_post_user_id";
DROP INDEX IF EXISTS "idx_post_visibility";
DROP INDEX IF EXISTS "idx_post_attachment_bill_post_id";
DROP INDEX IF EXISTS "idx_post_attachment_bill_user_id";
DROP INDEX IF EXISTS "idx_post_collection_post_id";
DROP INDEX IF EXISTS "idx_post_collection_user_id";
DROP INDEX IF EXISTS "idx_post_content_post_id";
DROP INDEX IF EXISTS "idx_post_content_user_id";
DROP INDEX IF EXISTS "idx_post_star_post_id";
DROP INDEX IF EXISTS "idx_post_star_user_id";
DROP INDEX IF EXISTS "idx_tag";
DROP INDEX IF EXISTS "idx_tag_quote_num";
DROP INDEX IF EXISTS "idx_tag_user_id";
DROP INDEX IF EXISTS "idx_user_phone";
DROP INDEX IF EXISTS "idx_user_username";
DROP INDEX IF EXISTS "idx_wallet_recharge_trade_no";
DROP INDEX IF EXISTS "idx_wallet_recharge_trade_status";
DROP INDEX IF EXISTS "idx_wallet_recharge_user_id";
DROP INDEX IF EXISTS "idx_wallet_statement_user_id";
PRAGMA foreign_keys = true;

@ -0,0 +1,219 @@
PRAGMA foreign_keys = false;
DROP INDEX IF EXISTS "main"."idx_user";
DROP INDEX IF EXISTS "main"."idx_expired_on";
DROP INDEX IF EXISTS "main"."idx_phone";
DROP INDEX IF EXISTS "main"."idx_use_times";
DROP INDEX IF EXISTS "main"."idx_post";
DROP INDEX IF EXISTS "main"."idx_user_friend_id";
DROP INDEX IF EXISTS "main"."idx_user_friend_status";
DROP INDEX IF EXISTS "main"."idx_visibility";
-- ----------------------------
-- Indexes structure for table p_attachment
-- ----------------------------
CREATE INDEX "idx_attachment_user_id"
ON "p_attachment" (
"user_id" ASC
);
-- ----------------------------
-- Indexes structure for table p_captcha
-- ----------------------------
CREATE INDEX "idx_captcha_expired_on"
ON "p_captcha" (
"expired_on" ASC
);
CREATE INDEX "idx_captcha_phone"
ON "p_captcha" (
"phone" ASC
);
CREATE INDEX "idx_captcha_use_times"
ON "p_captcha" (
"use_times" ASC
);
-- ----------------------------
-- Indexes structure for table p_comment
-- ----------------------------
CREATE INDEX "idx_comment_post_id"
ON "p_comment" (
"post_id" ASC
);
CREATE INDEX "idx_comment_user_id"
ON "p_comment" (
"user_id" ASC
);
-- ----------------------------
-- Indexes structure for table p_comment_content
-- ----------------------------
CREATE INDEX "idx_comment_content_comment_id"
ON "p_comment_content" (
"comment_id" ASC
);
CREATE INDEX "idx_comment_content_sort"
ON "p_comment_content" (
"sort" ASC
);
CREATE INDEX "idx_comment_content_type"
ON "p_comment_content" (
"type" ASC
);
CREATE INDEX "idx_comment_content_user_id"
ON "p_comment_content" (
"user_id" ASC
);
-- ----------------------------
-- Indexes structure for table p_comment_reply
-- ----------------------------
CREATE INDEX "idx_comment_reply_comment_id"
ON "p_comment_reply" (
"comment_id" ASC
);
-- ----------------------------
-- Indexes structure for table p_contact
-- ----------------------------
CREATE UNIQUE INDEX "idx_contact_user_friend"
ON "p_contact" (
"user_id" ASC,
"friend_id" ASC
);
CREATE INDEX "idx_contact_user_friend_status"
ON "p_contact" (
"user_id" ASC,
"friend_id" ASC,
"status" ASC
);
-- ----------------------------
-- Indexes structure for table p_message
-- ----------------------------
CREATE INDEX "idx_message_is_read"
ON "p_message" (
"is_read" ASC
);
CREATE INDEX "idx_message_receiver_user_id"
ON "p_message" (
"receiver_user_id" ASC
);
CREATE INDEX "idx_message_type"
ON "p_message" (
"type" ASC
);
-- ----------------------------
-- Indexes structure for table p_post
-- ----------------------------
CREATE INDEX "idx_post_user_id"
ON "p_post" (
"user_id" ASC
);
CREATE INDEX "idx_post_visibility"
ON "p_post" (
"visibility" ASC
);
-- ----------------------------
-- Indexes structure for table p_post_attachment_bill
-- ----------------------------
CREATE INDEX "idx_post_attachment_bill_post_id"
ON "p_post_attachment_bill" (
"post_id" ASC
);
CREATE INDEX "idx_post_attachment_bill_user_id"
ON "p_post_attachment_bill" (
"user_id" ASC
);
-- ----------------------------
-- Indexes structure for table p_post_collection
-- ----------------------------
CREATE INDEX "idx_post_collection_post_id"
ON "p_post_collection" (
"post_id" ASC
);
CREATE INDEX "idx_post_collection_user_id"
ON "p_post_collection" (
"user_id" ASC
);
-- ----------------------------
-- Indexes structure for table p_post_content
-- ----------------------------
CREATE INDEX "idx_post_content_post_id"
ON "p_post_content" (
"post_id" ASC
);
CREATE INDEX "idx_post_content_user_id"
ON "p_post_content" (
"user_id" ASC
);
-- ----------------------------
-- Indexes structure for table p_post_star
-- ----------------------------
CREATE INDEX "idx_post_star_post_id"
ON "p_post_star" (
"post_id" ASC
);
CREATE INDEX "idx_post_star_user_id"
ON "p_post_star" (
"user_id" ASC
);
-- ----------------------------
-- Indexes structure for table p_tag
-- ----------------------------
CREATE UNIQUE INDEX "idx_tag"
ON "p_tag" (
"tag" ASC
);
CREATE INDEX "idx_tag_quote_num"
ON "p_tag" (
"quote_num" ASC
);
CREATE INDEX "idx_tag_user_id"
ON "p_tag" (
"user_id" ASC
);
-- ----------------------------
-- Indexes structure for table p_user
-- ----------------------------
CREATE INDEX "idx_user_phone"
ON "p_user" (
"phone" ASC
);
CREATE UNIQUE INDEX "idx_user_username"
ON "p_user" (
"username" ASC
);
-- ----------------------------
-- Indexes structure for table p_wallet_recharge
-- ----------------------------
CREATE INDEX "idx_wallet_recharge_trade_no"
ON "p_wallet_recharge" (
"trade_no" ASC
);
CREATE INDEX "idx_wallet_recharge_trade_status"
ON "p_wallet_recharge" (
"trade_status" ASC
);
CREATE INDEX "idx_wallet_recharge_user_id"
ON "p_wallet_recharge" (
"user_id" ASC
);
-- ----------------------------
-- Indexes structure for table p_wallet_statement
-- ----------------------------
CREATE INDEX "idx_wallet_statement_user_id"
ON "p_wallet_statement" (
"user_id" ASC
);
PRAGMA foreign_keys = true;

@ -1,3 +0,0 @@
ALTER TABLE `p_post` DROP COLUMN `visibility`;
DROP INDEX "main"."idx_visibility" ON "p_post"

@ -18,7 +18,7 @@ CREATE TABLE `p_attachment` (
`deleted_on` bigint unsigned NOT NULL DEFAULT '0' COMMENT '删除时间',
`is_del` tinyint unsigned NOT NULL DEFAULT '0' COMMENT '是否删除 0 为未删除、1 为已删除',
PRIMARY KEY (`id`) USING BTREE,
KEY `idx_user` (`user_id`) USING BTREE
KEY `idx_attachment_user` (`user_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=100041 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='附件';
-- ----------------------------
@ -36,9 +36,9 @@ CREATE TABLE `p_captcha` (
`deleted_on` bigint unsigned NOT NULL DEFAULT '0' COMMENT '删除时间',
`is_del` tinyint unsigned NOT NULL DEFAULT '0' COMMENT '是否删除 0 为未删除、1 为已删除',
PRIMARY KEY (`id`) USING BTREE,
KEY `idx_phone` (`phone`) USING BTREE,
KEY `idx_expired_on` (`expired_on`) USING BTREE,
KEY `idx_use_times` (`use_times`) USING BTREE
KEY `idx_captcha_phone` (`phone`) USING BTREE,
KEY `idx_captcha_expired_on` (`expired_on`) USING BTREE,
KEY `idx_captcha_use_times` (`use_times`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1021 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='手机验证码';
-- ----------------------------
@ -56,8 +56,8 @@ CREATE TABLE `p_comment` (
`deleted_on` bigint unsigned NOT NULL DEFAULT '0' COMMENT '删除时间',
`is_del` tinyint unsigned NOT NULL DEFAULT '0' COMMENT '是否删除 0 为未删除、1 为已删除',
PRIMARY KEY (`id`) USING BTREE,
KEY `idx_post` (`post_id`) USING BTREE,
KEY `idx_user` (`user_id`) USING BTREE
KEY `idx_comment_post_id` (`post_id`) USING BTREE,
KEY `idx_comment_user_id` (`user_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=6001736 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='评论';
-- ----------------------------
@ -76,10 +76,10 @@ CREATE TABLE `p_comment_content` (
`deleted_on` bigint unsigned NOT NULL DEFAULT '0' COMMENT '删除时间',
`is_del` tinyint unsigned NOT NULL DEFAULT '0' COMMENT '是否删除 0 为未删除、1 为已删除',
PRIMARY KEY (`id`) USING BTREE,
KEY `idx_reply` (`comment_id`) USING BTREE,
KEY `idx_user` (`user_id`) USING BTREE,
KEY `idx_type` (`type`) USING BTREE,
KEY `idx_sort` (`sort`) USING BTREE
KEY `idx_comment_content_comment_id` (`comment_id`) USING BTREE,
KEY `idx_comment_content_user_id` (`user_id`) USING BTREE,
KEY `idx_comment_content_type` (`type`) USING BTREE,
KEY `idx_comment_content_sort` (`sort`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=11001738 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='评论内容';
-- ----------------------------
@ -99,7 +99,7 @@ CREATE TABLE `p_comment_reply` (
`deleted_on` bigint unsigned NOT NULL DEFAULT '0' COMMENT '删除时间',
`is_del` tinyint unsigned NOT NULL DEFAULT '0' COMMENT '是否删除 0 为未删除、1 为已删除',
PRIMARY KEY (`id`) USING BTREE,
KEY `idx_comment` (`comment_id`) USING BTREE
KEY `idx_comment_reply_comment_id` (`comment_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=12000015 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='评论回复';
-- ----------------------------
@ -122,9 +122,9 @@ CREATE TABLE `p_message` (
`deleted_on` bigint unsigned NOT NULL DEFAULT '0' COMMENT '删除时间',
`is_del` tinyint unsigned NOT NULL DEFAULT '0' COMMENT '是否删除 0 为未删除、1 为已删除',
PRIMARY KEY (`id`) USING BTREE,
KEY `idx_receiver` (`receiver_user_id`) USING BTREE,
KEY `idx_is_read` (`is_read`) USING BTREE,
KEY `idx_type` (`type`) USING BTREE
KEY `idx_message_receiver_user_id` (`receiver_user_id`) USING BTREE,
KEY `idx_message_is_read` (`is_read`) USING BTREE,
KEY `idx_message_type` (`type`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=16000033 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='消息通知';
-- ----------------------------
@ -151,8 +151,8 @@ CREATE TABLE `p_post` (
`deleted_on` bigint unsigned NOT NULL DEFAULT '0' COMMENT '删除时间',
`is_del` tinyint unsigned NOT NULL DEFAULT '0' COMMENT '是否删除 0 为未删除、1 为已删除',
PRIMARY KEY (`id`) USING BTREE,
KEY `idx_user` (`user_id`) USING BTREE,
KEY `idx_visibility` (`visibility`) USING BTREE
KEY `idx_post_user_id` (`user_id`) USING BTREE,
KEY `idx_post_visibility` (`visibility`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1080017989 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='冒泡/文章';
-- ----------------------------
@ -169,8 +169,8 @@ CREATE TABLE `p_post_attachment_bill` (
`deleted_on` bigint unsigned NOT NULL DEFAULT '0' COMMENT '删除时间',
`is_del` tinyint unsigned NOT NULL DEFAULT '0' COMMENT '是否删除 0 为未删除、1 为已删除',
PRIMARY KEY (`id`) USING BTREE,
KEY `idx_post` (`post_id`) USING BTREE,
KEY `idx_user` (`user_id`) USING BTREE
KEY `idx_post_attachment_bill_post_id` (`post_id`) USING BTREE,
KEY `idx_post_attachment_bill_user_id` (`user_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=5000002 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='冒泡/文章附件账单';
-- ----------------------------
@ -186,8 +186,8 @@ CREATE TABLE `p_post_collection` (
`deleted_on` bigint unsigned NOT NULL DEFAULT '0' COMMENT '删除时间',
`is_del` tinyint unsigned NOT NULL DEFAULT '0' COMMENT '是否删除 0 为未删除、1 为已删除',
PRIMARY KEY (`id`) USING BTREE,
KEY `idx_post` (`post_id`) USING BTREE,
KEY `idx_user` (`user_id`) USING BTREE
KEY `idx_post_collection_post_id` (`post_id`) USING BTREE,
KEY `idx_post_collection_user_id` (`user_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=6000012 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='冒泡/文章收藏';
-- ----------------------------
@ -206,8 +206,8 @@ CREATE TABLE `p_post_content` (
`deleted_on` bigint unsigned NOT NULL DEFAULT '0' COMMENT '删除时间',
`is_del` tinyint unsigned NOT NULL DEFAULT '0' COMMENT '是否删除 0 为未删除、1 为已删除',
PRIMARY KEY (`id`) USING BTREE,
KEY `idx_post` (`post_id`) USING BTREE,
KEY `idx_user` (`user_id`) USING BTREE
KEY `idx_post_content_post_id` (`post_id`) USING BTREE,
KEY `idx_post_content_user_id` (`user_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=180022546 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='冒泡/文章内容';
-- ----------------------------
@ -223,8 +223,8 @@ CREATE TABLE `p_post_star` (
`deleted_on` bigint unsigned NOT NULL DEFAULT '0' COMMENT '删除时间',
`is_del` tinyint unsigned NOT NULL DEFAULT '0' COMMENT '是否删除 0 为未删除、1 为已删除',
PRIMARY KEY (`id`) USING BTREE,
KEY `idx_post` (`post_id`) USING BTREE,
KEY `idx_user` (`user_id`) USING BTREE
KEY `idx_post_star_post_id` (`post_id`) USING BTREE,
KEY `idx_post_star_user_id` (`user_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=6000028 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='冒泡/文章点赞';
-- ----------------------------
@ -241,9 +241,9 @@ CREATE TABLE `p_tag` (
`deleted_on` bigint unsigned NOT NULL DEFAULT '0' COMMENT '删除时间',
`is_del` tinyint unsigned NOT NULL DEFAULT '0' COMMENT '是否删除 0 为未删除、1 为已删除',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE KEY `idx_tag` (`tag`) USING BTREE,
KEY `idx_user` (`user_id`) USING BTREE,
KEY `idx_num` (`quote_num`) USING BTREE
UNIQUE KEY `idx_tag_tag` (`tag`) USING BTREE,
KEY `idx_tag_user_id` (`user_id`) USING BTREE,
KEY `idx_tag_quote_num` (`quote_num`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=9000065 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='标签';
-- ----------------------------
@ -266,8 +266,8 @@ CREATE TABLE `p_user` (
`deleted_on` bigint unsigned NOT NULL DEFAULT '0' COMMENT '删除时间',
`is_del` tinyint unsigned NOT NULL DEFAULT '0' COMMENT '是否删除 0 为未删除、1 为已删除',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE KEY `idx_username` (`username`) USING BTREE,
KEY `idx_phone` (`phone`) USING BTREE
UNIQUE KEY `idx_user_username` (`username`) USING BTREE,
KEY `idx_user_phone` (`phone`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=100058 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='用户';
-- ----------------------------
@ -283,14 +283,14 @@ CREATE TABLE `p_contact` (
`status` tinyint NOT NULL DEFAULT '0' COMMENT '好友状态: 1请求好友, 2已好友, 3拒绝好友, 4已删好友',
`is_top` tinyint NOT NULL DEFAULT '0' COMMENT '是否置顶, 0否, 1是',
`is_black` tinyint NOT NULL DEFAULT '0' COMMENT '是否为黑名单, 0否, 1是',
`is_del` tinyint NOT NULL DEFAULT '0' COMMENT '是否删除好友, 0否, 1是',
`is_delete` tinyint NOT NULL DEFAULT '0' COMMENT '是否删除好友, 0否, 1是',
`notice_enable` tinyint NOT NULL DEFAULT '0' COMMENT '是否有消息提醒, 0否, 1是',
`created_on` bigint unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
`modified_on` bigint unsigned NOT NULL DEFAULT '0' COMMENT '修改时间',
`deleted_on` bigint unsigned NOT NULL DEFAULT '0' COMMENT '删除时间',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE KEY `idx_user_friend_id` (`user_id`,`friend_id`) USING BTREE,
KEY `idx_user_friend_status` (`user_id`, `friend_id`, `status`) USING BTREE
UNIQUE KEY `idx_contact_user_friend` (`user_id`,`friend_id`) USING BTREE,
KEY `idx_contact_user_friend_status` (`user_id`, `friend_id`, `status`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='联系人';
-- ----------------------------
@ -301,7 +301,7 @@ CREATE TABLE `p_contact_group` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '联系人ID',
`user_id` int NOT NULL DEFAULT '0' COMMENT '用户id',
`name` varchar(32) NOT NULL DEFAULT '' COMMENT '分组名称',
`is_del` tinyint NOT NULL DEFAULT '1' COMMENT '是否删除, 0否, 1是',
`is_delete` tinyint NOT NULL DEFAULT '1' COMMENT '是否删除, 0否, 1是',
`created_on` bigint unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
`modified_on` bigint unsigned NOT NULL DEFAULT '0' COMMENT '修改时间',
`deleted_on` bigint unsigned NOT NULL DEFAULT '0' COMMENT '删除时间',
@ -323,9 +323,9 @@ CREATE TABLE `p_wallet_recharge` (
`deleted_on` bigint unsigned NOT NULL DEFAULT '0' COMMENT '删除时间',
`is_del` tinyint unsigned NOT NULL DEFAULT '0' COMMENT '是否删除 0 为未删除、1 为已删除',
PRIMARY KEY (`id`) USING BTREE,
KEY `idx_user` (`user_id`) USING BTREE,
KEY `idx_trade_no` (`trade_no`) USING BTREE,
KEY `idx_trade_status` (`trade_status`) USING BTREE
KEY `idx_wallet_recharge_user_id` (`user_id`) USING BTREE,
KEY `idx_wallet_recharge_trade_no` (`trade_no`) USING BTREE,
KEY `idx_wallet_recharge_trade_status` (`trade_status`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=10023 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='钱包流水';
-- ----------------------------
@ -344,7 +344,7 @@ CREATE TABLE `p_wallet_statement` (
`deleted_on` bigint unsigned NOT NULL DEFAULT '0' COMMENT '删除时间',
`is_del` tinyint unsigned NOT NULL DEFAULT '0' COMMENT '是否删除 0 为未删除、1 为已删除',
PRIMARY KEY (`id`) USING BTREE,
KEY `idx_user` (`user_id`) USING BTREE
KEY `idx_wallet_statement_user_id` (`user_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=10010 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='钱包流水';
SET FOREIGN_KEY_CHECKS = 1;

@ -1 +1,285 @@
-- TODO: WIP
SET client_encoding = 'UTF8';
SET standard_conforming_strings = off;
SET check_function_bodies = false;
SET client_min_messages = warning;
SET escape_string_warning = off;
DROP TABLE IF EXISTS p_attachment;
CREATE TABLE p_attachment (
id BIGSERIAL PRIMARY KEY,
user_id BIGINT NOT NULL DEFAULT 0,
file_size BIGINT NOT NULL,
img_width BIGINT NOT NULL DEFAULT 0,
img_height BIGINT NOT NULL DEFAULT 0,
"type" SMALLINT NOT NULL DEFAULT 1, -- 1图片、2视频、3其他附件
content VARCHAR(255) NOT NULL DEFAULT '',
created_on BIGINT NOT NULL DEFAULT 0,
modified_on BIGINT NOT NULL DEFAULT 0,
deleted_on BIGINT NOT NULL DEFAULT 0,
is_del SMALLINT NOT NULL DEFAULT 0 -- 是否删除 0为未删除、1为已删除
);
CREATE INDEX idx_attachment_user_id ON p_attachment USING btree (id);
DROP TABLE IF EXISTS p_captcha;
CREATE TABLE p_captcha (
id BIGSERIAL PRIMARY KEY,
phone VARCHAR(16),
captcha VARCHAR(16),
use_times INTEGER NOT NULL DEFAULT 0,
expired_on BIGINT NOT NULL DEFAULT 0,
created_on BIGINT NOT NULL DEFAULT 0,
modified_on BIGINT NOT NULL DEFAULT 0,
deleted_on BIGINT NOT NULL DEFAULT 0,
is_del SMALLINT NOT NULL DEFAULT 0 -- 是否删除 0为未删除、1为已删除'
);
CREATE INDEX idx_captcha_phone ON p_captcha USING btree (phone);
CREATE INDEX idx_captcha_expired_on ON p_captcha USING btree (expired_on);
CREATE INDEX idx_captcha_use_times ON p_captcha USING btree (use_times);
DROP TABLE IF EXISTS p_comment;
CREATE TABLE p_comment (
id BIGSERIAL PRIMARY KEY,
post_id BIGINT NOT NULL DEFAULT 0,
user_id BIGINT NOT NULL DEFAULT 0,
ip VARCHAR(64) NOT NULL DEFAULT '',
ip_loc VARCHAR(64) NOT NULL DEFAULT '',
created_on BIGINT NOT NULL DEFAULT 0,
modified_on BIGINT NOT NULL DEFAULT 0,
deleted_on BIGINT NOT NULL DEFAULT 0,
is_del SMALLINT NOT NULL DEFAULT 0
);
CREATE INDEX idx_comment_post_id ON p_comment USING btree (post_id);
CREATE INDEX idx_comment_user_id ON p_comment USING btree (user_id);
DROP TABLE IF EXISTS p_comment_content;
CREATE TABLE p_comment_content (
id BIGSERIAL PRIMARY KEY,
comment_id BIGINT NOT NULL DEFAULT 0,
user_id BIGINT NOT NULL DEFAULT 0,
content VARCHAR(255) NOT NULL DEFAULT '',
"type" SMALLINT NOT NULL DEFAULT 2, -- 类型1标题2文字段落3图片地址4视频地址5语音地址6链接地址,
sort BIGINT NOT NULL DEFAULT 100,
created_on BIGINT NOT NULL DEFAULT 0,
modified_on BIGINT NOT NULL DEFAULT 0,
deleted_on BIGINT NOT NULL DEFAULT 0,
is_del SMALLINT NOT NULL DEFAULT 0
);
CREATE INDEX idx_comment_content_comment_id ON p_comment_content USING btree (comment_id);
CREATE INDEX idx_comment_content_user_id ON p_comment_content USING btree (user_id);
CREATE INDEX idx_comment_content_type ON p_comment_content USING btree ("type");
CREATE INDEX idx_comment_content_sort ON p_comment_content USING btree (sort);
DROP TABLE IF EXISTS p_comment_reply;
CREATE TABLE p_comment_reply (
id BIGSERIAL PRIMARY KEY,
comment_id BIGINT NOT NULL DEFAULT 0,
user_id BIGINT NOT NULL DEFAULT 0,
at_user_id BIGINT NOT NULL DEFAULT 0,
content VARCHAR(255) NOT NULL DEFAULT '',
ip VARCHAR(64) NOT NULL DEFAULT '',
ip_loc VARCHAR(64) NOT NULL DEFAULT '',
created_on BIGINT NOT NULL DEFAULT 0,
modified_on BIGINT NOT NULL DEFAULT 0,
deleted_on BIGINT NOT NULL DEFAULT 0,
is_del SMALLINT NOT NULL DEFAULT 0
);
CREATE INDEX idx_comment_reply_comment_id ON p_comment_reply USING btree (comment_id);
DROP TABLE IF EXISTS p_message;
CREATE TABLE p_message (
id BIGSERIAL PRIMARY KEY,
sender_user_id BIGINT NOT NULL DEFAULT 0,
receiver_user_id BIGINT NOT NULL DEFAULT 0,
type SMALLINT NOT NULL DEFAULT 1,
brief VARCHAR(255) NOT NULL DEFAULT '',
content VARCHAR(255) NOT NULL DEFAULT '',
post_id BIGINT NOT NULL DEFAULT 0,
comment_id BIGINT NOT NULL DEFAULT 0,
reply_id BIGINT NOT NULL DEFAULT 0,
is_read SMALLINT NOT NULL DEFAULT 0,
created_on BIGINT NOT NULL DEFAULT 0,
modified_on BIGINT NOT NULL DEFAULT 0,
deleted_on BIGINT NOT NULL DEFAULT 0,
is_del SMALLINT NOT NULL DEFAULT 0
);
CREATE INDEX idx_message_receiver_user_id ON p_message USING btree (receiver_user_id);
CREATE INDEX idx_message_is_read ON p_message USING btree (is_read);
CREATE INDEX idx_message_type ON p_message USING btree ("type");
CREATE SEQUENCE IF NOT EXISTS post_id_seq AS BIGINT MINVALUE 1080017989 NO MAXVALUE;
DROP TABLE IF EXISTS p_post;
CREATE TABLE p_post (
id BIGINT NOT NULL DEFAULT nextval('post_id_seq'::regclass),
user_id BIGINT NOT NULL DEFAULT 0,
comment_count BIGINT NOT NULL DEFAULT 0,
collection_count BIGINT NOT NULL DEFAULT 0,
upvote_count BIGINT NOT NULL DEFAULT 0,
visibility SMALLINT NOT NULL DEFAULT 0, -- 可见性 0公开 1私密 2好友可见
is_top SMALLINT NOT NULL DEFAULT 0, -- 是否置顶
is_essence SMALLINT NOT NULL DEFAULT 0, -- 是否精华
is_lock SMALLINT NOT NULL DEFAULT 0, -- 是否锁定
latest_replied_on BIGINT NOT NULL DEFAULT 0, -- 最新回复时间
tags VARCHAR(255) NOT NULL DEFAULT '',
attachment_price BIGINT NOT NULL DEFAULT 0, -- 附件价格(分)
ip VARCHAR(64) NOT NULL DEFAULT '', -- IP地址
ip_loc VARCHAR(64) NOT NULL DEFAULT '', -- IP城市地址
created_on BIGINT NOT NULL DEFAULT 0,
modified_on BIGINT NOT NULL DEFAULT 0,
deleted_on BIGINT NOT NULL DEFAULT 0,
is_del SMALLINT NOT NULL DEFAULT 0,
PRIMARY KEY (id)
);
CREATE INDEX idx_post_user_id ON p_post USING btree (user_id);
CREATE INDEX idx_post_visibility ON p_post USING btree (visibility);
DROP TABLE IF EXISTS p_post_attachment_bill;
CREATE TABLE p_post_attachment_bill (
id BIGSERIAL PRIMARY KEY,
post_id BIGINT NOT NULL DEFAULT 0,
user_id BIGINT NOT NULL DEFAULT 0,
paid_amount BIGINT NOT NULL DEFAULT 0, -- 支付金额
created_on BIGINT NOT NULL DEFAULT 0,
modified_on BIGINT NOT NULL DEFAULT 0,
deleted_on BIGINT NOT NULL DEFAULT 0,
is_del SMALLINT NOT NULL DEFAULT 0
);
CREATE INDEX idx_post_attachment_bill_post_id ON p_post_attachment_bill USING btree (post_id);
CREATE INDEX idx_post_attachment_bill_user_id ON p_post_attachment_bill USING btree (user_id);
DROP TABLE IF EXISTS p_post_collection;
CREATE TABLE p_post_collection (
id BIGSERIAL PRIMARY KEY,
post_id BIGINT NOT NULL DEFAULT 0,
user_id BIGINT NOT NULL DEFAULT 0,
created_on BIGINT NOT NULL DEFAULT 0,
modified_on BIGINT NOT NULL DEFAULT 0,
deleted_on BIGINT NOT NULL DEFAULT 0,
is_del SMALLINT NOT NULL DEFAULT 0
);
CREATE INDEX idx_post_collection_post_id ON p_post_collection USING btree (post_id);
CREATE INDEX idx_post_collection_user_id ON p_post_collection USING btree (user_id);
DROP TABLE IF EXISTS p_post_content;
CREATE TABLE p_post_content (
id BIGSERIAL PRIMARY KEY,
post_id BIGINT NOT NULL DEFAULT 0,
user_id BIGINT NOT NULL DEFAULT 0,
content VARCHAR(2000) NOT NULL DEFAULT '',
"type" SMALLINT NOT NULL DEFAULT 2, -- 类型1标题2文字段落3图片地址4视频地址5语音地址6链接地址7附件资源8收费资源
sort SMALLINT NOT NULL DEFAULT 100,
created_on BIGINT NOT NULL DEFAULT 0,
modified_on BIGINT NOT NULL DEFAULT 0,
deleted_on BIGINT NOT NULL DEFAULT 0,
is_del SMALLINT NOT NULL DEFAULT 0
);
CREATE INDEX idx_post_content_post_id ON p_post_content USING btree (post_id);
CREATE INDEX idx_post_content_user_id ON p_post_content USING btree (user_id);
DROP TABLE IF EXISTS p_post_star;
CREATE TABLE p_post_star (
id BIGSERIAL PRIMARY KEY,
post_id BIGINT NOT NULL DEFAULT 0,
user_id BIGINT NOT NULL DEFAULT 0,
created_on BIGINT NOT NULL DEFAULT 0,
modified_on BIGINT NOT NULL DEFAULT 0,
deleted_on BIGINT NOT NULL DEFAULT 0,
is_del SMALLINT NOT NULL DEFAULT 0
);
CREATE INDEX idx_post_star_post_id ON p_post_star USING btree (post_id);
CREATE INDEX idx_post_star_user_id ON p_post_star USING btree (user_id);
DROP TABLE IF EXISTS p_tag;
CREATE TABLE p_tag (
id BIGSERIAL PRIMARY KEY,
user_id BIGINT NOT NULL DEFAULT 0,
tag VARCHAR(255) NOT NULL,
quote_num BIGINT NOT NULL DEFAULT 0, -- 引用数
created_on BIGINT NOT NULL DEFAULT 0,
modified_on BIGINT NOT NULL DEFAULT 0,
deleted_on BIGINT NOT NULL DEFAULT 0,
is_del SMALLINT NOT NULL DEFAULT 0
);
CREATE UNIQUE INDEX idx_tag_tag ON p_tag USING btree (tag);
CREATE INDEX idx_tag_user_id ON p_tag USING btree (user_id);
CREATE INDEX idx_tag_quote_num ON p_tag USING btree (quote_num);
DROP TABLE IF EXISTS p_user;
CREATE TABLE p_user (
id BIGSERIAL PRIMARY KEY,
nickname VARCHAR(32) NOT NULL DEFAULT '',
username VARCHAR(32) NOT NULL DEFAULT '',
phone VARCHAR(16) NOT NULL DEFAULT '', -- 手机号
password VARCHAR(32) NOT NULL DEFAULT '', -- MD5密码
salt VARCHAR(16) NOT NULL DEFAULT '', -- 盐值
status SMALLINT NOT NULL DEFAULT 1, -- 状态1正常2停用
avatar VARCHAR(255) NOT NULL DEFAULT '',
balance BIGINT NOT NULL, -- 用户余额(分)
is_admin BOOLEAN NOT NULL DEFAULT false, -- 是否管理员
created_on BIGINT NOT NULL DEFAULT 0,
modified_on BIGINT NOT NULL DEFAULT 0,
deleted_on BIGINT NOT NULL DEFAULT 0,
is_del SMALLINT NOT NULL DEFAULT 0
);
CREATE UNIQUE INDEX idx_user_username ON p_user USING btree (username);
CREATE INDEX idx_user_phone ON p_user USING btree (phone);
DROP TABLE IF EXISTS p_contact;
CREATE TABLE p_contact (
id BIGSERIAL PRIMARY KEY,
user_id BIGINT NOT NULL,
friend_id BIGINT NOT NULL,
group_id BIGINT NOT NULL DEFAULT 0, -- 好友分组ID:默认为0无分组
remark VARCHAR(32) NOT NULL DEFAULT '', -- 好友备注
status SMALLINT NOT NULL DEFAULT 0, -- 好友状态: 1请求好友, 2已好友, 3拒绝好友, 4已删好友
is_top SMALLINT NOT NULL DEFAULT 0, -- 是否置顶, 0否, 1是
is_black SMALLINT NOT NULL DEFAULT 0, -- 是否为黑名单, 0否, 1是
is_del SMALLINT NOT NULL DEFAULT 0, -- 否删除好友, 0否, 1是
notice_enable SMALLINT NOT NULL DEFAULT 0, -- 是否有消息提醒, 0否, 1是
created_on BIGINT NOT NULL DEFAULT 0,
modified_on BIGINT NOT NULL DEFAULT 0,
deleted_on BIGINT NOT NULL DEFAULT 0
);
CREATE UNIQUE INDEX idx_contact_user_friend ON p_contact USING btree (user_id,friend_id);
CREATE INDEX idx_contact_user_friend_status ON p_contact USING btree (user_id, friend_id, status);
DROP TABLE IF EXISTS p_contact_group;
CREATE TABLE p_contact_group (
id BIGSERIAL PRIMARY KEY,
user_id int NOT NULL DEFAULT 0,
name VARCHAR(32) NOT NULL DEFAULT '', -- 分组名称
is_del SMALLINT NOT NULL DEFAULT 1, -- 是否删除, 0否, 1是
created_on BIGINT NOT NULL DEFAULT 0,
modified_on BIGINT NOT NULL DEFAULT 0,
deleted_on BIGINT NOT NULL DEFAULT 0
);
DROP TABLE IF EXISTS p_wallet_recharge;
CREATE TABLE p_wallet_recharge (
id BIGSERIAL PRIMARY KEY,
user_id BIGINT NOT NULL DEFAULT 0,
amount BIGINT NOT NULL DEFAULT 0, -- 充值金额
trade_no VARCHAR(64) NOT NULL DEFAULT '', -- 支付宝订单号
trade_status VARCHAR(32) NOT NULL DEFAULT '', -- 交易状态
created_on BIGINT NOT NULL DEFAULT 0,
modified_on BIGINT NOT NULL DEFAULT 0,
deleted_on BIGINT NOT NULL DEFAULT 0,
is_del SMALLINT NOT NULL DEFAULT 0 -- 是否删除 0 为未删除、1 为已删除
);
CREATE INDEX idx_wallet_recharge_user_id ON p_wallet_recharge USING btree (user_id);
CREATE INDEX idx_wallet_recharge_trade_no ON p_wallet_recharge USING btree (trade_no);
CREATE INDEX idx_wallet_recharge_trade_status ON p_wallet_recharge USING btree (trade_status);
DROP TABLE IF EXISTS p_wallet_statement;
CREATE TABLE p_wallet_statement (
id BIGSERIAL PRIMARY KEY,
user_id BIGINT NOT NULL DEFAULT 0,
change_amount BIGINT NOT NULL DEFAULT 0, -- 变动金额
balance_snapshot BIGINT NOT NULL DEFAULT 0, -- 资金快照
reason VARCHAR(255) NOT NULL, -- 变动原因
post_id BIGINT NOT NULL DEFAULT 0, -- 关联动态
created_on BIGINT NOT NULL DEFAULT 0,
modified_on BIGINT NOT NULL DEFAULT 0,
deleted_on BIGINT NOT NULL DEFAULT 0,
is_del SMALLINT NOT NULL DEFAULT 0
);
CREATE INDEX idx_wallet_statement_user_id ON p_wallet_statement USING btree (user_id);

@ -101,10 +101,10 @@ CREATE TABLE "p_contact" (
"group_id" integer NOT NULL,
"remark" text(32) NOT NULL,
"status" integer NOT NULL,
"notice_enable" integer NOT NULL,
"is_top" integer NOT NULL,
"is_black" integer NOT NULL,
"is_del" integer NOT NULL,
"notice_enable" integer NOT NULL,
"created_on" integer NOT NULL,
"modified_on" integer NOT NULL,
"deleted_on" integer NOT NULL,
@ -169,7 +169,8 @@ CREATE TABLE "p_post" (
"created_on" integer NOT NULL,
"modified_on" integer NOT NULL,
"deleted_on" integer NOT NULL,
"is_del" integer NOT NULL, `visibility` integer NOT NULL DEFAULT '0',
"is_del" integer NOT NULL,
"visibility" integer NOT NULL,
PRIMARY KEY ("id")
);
@ -313,7 +314,7 @@ CREATE TABLE "p_wallet_statement" (
-- ----------------------------
-- Indexes structure for table p_attachment
-- ----------------------------
CREATE INDEX "main"."idx_user"
CREATE INDEX "idx_attachment_user_id"
ON "p_attachment" (
"user_id" ASC
);
@ -321,15 +322,15 @@ ON "p_attachment" (
-- ----------------------------
-- Indexes structure for table p_captcha
-- ----------------------------
CREATE INDEX "main"."idx_expired_on"
CREATE INDEX "idx_captcha_expired_on"
ON "p_captcha" (
"expired_on" ASC
);
CREATE INDEX "main"."idx_phone"
CREATE INDEX "idx_captcha_phone"
ON "p_captcha" (
"phone" ASC
);
CREATE INDEX "main"."idx_use_times"
CREATE INDEX "idx_captcha_use_times"
ON "p_captcha" (
"use_times" ASC
);
@ -337,32 +338,184 @@ ON "p_captcha" (
-- ----------------------------
-- Indexes structure for table p_comment
-- ----------------------------
CREATE INDEX "main"."idx_post"
CREATE INDEX "idx_comment_post_id"
ON "p_comment" (
"post_id" ASC
);
CREATE INDEX "idx_comment_user_id"
ON "p_comment" (
"user_id" ASC
);
-- ----------------------------
-- Indexes structure for table p_comment_content
-- ----------------------------
CREATE INDEX "idx_comment_content_comment_id"
ON "p_comment_content" (
"comment_id" ASC
);
CREATE INDEX "idx_comment_content_sort"
ON "p_comment_content" (
"sort" ASC
);
CREATE INDEX "idx_comment_content_type"
ON "p_comment_content" (
"type" ASC
);
CREATE INDEX "idx_comment_content_user_id"
ON "p_comment_content" (
"user_id" ASC
);
-- ----------------------------
-- Indexes structure for table p_comment_reply
-- ----------------------------
CREATE INDEX "idx_comment_reply_comment_id"
ON "p_comment_reply" (
"comment_id" ASC
);
-- ----------------------------
-- Indexes structure for table p_contact
-- ----------------------------
CREATE UNIQUE INDEX "main"."idx_user_friend_id"
CREATE UNIQUE INDEX "idx_contact_user_friend"
ON "p_contact" (
"user_id" ASC,
"friend_id" ASC
);
CREATE INDEX "main"."idx_user_friend_status"
CREATE INDEX "idx_contact_user_friend_status"
ON "p_contact" (
"user_id" ASC,
"friend_id" ASC,
"status" ASC
);
-- ----------------------------
-- Indexes structure for table p_message
-- ----------------------------
CREATE INDEX "idx_message_is_read"
ON "p_message" (
"is_read" ASC
);
CREATE INDEX "idx_message_receiver_user_id"
ON "p_message" (
"receiver_user_id" ASC
);
CREATE INDEX "idx_message_type"
ON "p_message" (
"type" ASC
);
-- ----------------------------
-- Indexes structure for table p_post
-- ----------------------------
CREATE INDEX "main"."idx_visibility"
CREATE INDEX "idx_post_user_id"
ON "p_post" (
"user_id" ASC
);
CREATE INDEX "idx_post_visibility"
ON "p_post" (
"visibility" ASC
);
-- ----------------------------
-- Indexes structure for table p_post_attachment_bill
-- ----------------------------
CREATE INDEX "idx_post_attachment_bill_post_id"
ON "p_post_attachment_bill" (
"post_id" ASC
);
CREATE INDEX "idx_post_attachment_bill_user_id"
ON "p_post_attachment_bill" (
"user_id" ASC
);
-- ----------------------------
-- Indexes structure for table p_post_collection
-- ----------------------------
CREATE INDEX "idx_post_collection_post_id"
ON "p_post_collection" (
"post_id" ASC
);
CREATE INDEX "idx_post_collection_user_id"
ON "p_post_collection" (
"user_id" ASC
);
-- ----------------------------
-- Indexes structure for table p_post_content
-- ----------------------------
CREATE INDEX "idx_post_content_post_id"
ON "p_post_content" (
"post_id" ASC
);
CREATE INDEX "idx_post_content_user_id"
ON "p_post_content" (
"user_id" ASC
);
-- ----------------------------
-- Indexes structure for table p_post_star
-- ----------------------------
CREATE INDEX "idx_post_star_post_id"
ON "p_post_star" (
"post_id" ASC
);
CREATE INDEX "idx_post_star_user_id"
ON "p_post_star" (
"user_id" ASC
);
-- ----------------------------
-- Indexes structure for table p_tag
-- ----------------------------
CREATE UNIQUE INDEX "idx_tag"
ON "p_tag" (
"tag" ASC
);
CREATE INDEX "idx_tag_quote_num"
ON "p_tag" (
"quote_num" ASC
);
CREATE INDEX "idx_tag_user_id"
ON "p_tag" (
"user_id" ASC
);
-- ----------------------------
-- Indexes structure for table p_user
-- ----------------------------
CREATE INDEX "idx_user_phone"
ON "p_user" (
"phone" ASC
);
CREATE UNIQUE INDEX "idx_user_username"
ON "p_user" (
"username" ASC
);
-- ----------------------------
-- Indexes structure for table p_wallet_recharge
-- ----------------------------
CREATE INDEX "idx_wallet_recharge_trade_no"
ON "p_wallet_recharge" (
"trade_no" ASC
);
CREATE INDEX "idx_wallet_recharge_trade_status"
ON "p_wallet_recharge" (
"trade_status" ASC
);
CREATE INDEX "idx_wallet_recharge_user_id"
ON "p_wallet_recharge" (
"user_id" ASC
);
-- ----------------------------
-- Indexes structure for table p_wallet_statement
-- ----------------------------
CREATE INDEX "idx_wallet_statement_user_id"
ON "p_wallet_statement" (
"user_id" ASC
);
PRAGMA foreign_keys = true;

Loading…
Cancel
Save