优化sql脚本执行顺序
This commit is contained in:
424
doc/sql/createtable/user_point_postgres.sql
Normal file
424
doc/sql/createtable/user_point_postgres.sql
Normal file
@@ -0,0 +1,424 @@
|
||||
create table user_benefit
|
||||
(
|
||||
id bigint not null primary key,
|
||||
amount decimal(14, 2) default 0,
|
||||
version int default 1,
|
||||
create_user int8,
|
||||
create_dept int8,
|
||||
create_time timestamp(6),
|
||||
update_user int8,
|
||||
update_time timestamp(6),
|
||||
status integer default 1,
|
||||
is_deleted integer default 0
|
||||
);
|
||||
|
||||
|
||||
comment on table user_benefit is '用户福利值表';
|
||||
comment on column user_benefit.id is '主键';
|
||||
comment on column user_benefit.amount is '金额';
|
||||
comment on column user_benefit.version is '版本号';
|
||||
comment on column user_benefit.create_user is '创建人';
|
||||
comment on column user_benefit.create_dept is '创建部门';
|
||||
comment on column user_benefit.create_time is '创建时间';
|
||||
comment on column user_benefit.update_user is '修改人';
|
||||
comment on column user_benefit.update_time is '修改时间';
|
||||
comment on column user_benefit.status is '状态';
|
||||
comment on column user_benefit.is_deleted is '是否已删除';
|
||||
|
||||
alter table user_benefit
|
||||
owner to postgres;
|
||||
|
||||
create table user_benefit_log
|
||||
(
|
||||
id bigint not null primary key,
|
||||
user_id bigint,
|
||||
user_phone bigint,
|
||||
user_name varchar(128),
|
||||
amount decimal(14, 2) default 0,
|
||||
source_id bigint,
|
||||
user_pack_id bigint,
|
||||
source_detail text,
|
||||
order_id bigint,
|
||||
type int default 1,
|
||||
statistical_date timestamp(6),
|
||||
channel varchar(64),
|
||||
channel_detail text,
|
||||
remark text,
|
||||
create_user int8,
|
||||
create_dept int8,
|
||||
create_time timestamp(6),
|
||||
update_user int8,
|
||||
update_time timestamp(6),
|
||||
status integer default 1,
|
||||
is_deleted integer default 0
|
||||
|
||||
);
|
||||
create index ub_log_date_index
|
||||
on user_benefit_log (is_deleted, user_id , statistical_date , type);
|
||||
|
||||
comment on table user_benefit_log is '用户福利值流水表';
|
||||
comment on column user_benefit_log.id is '主键';
|
||||
comment on column user_benefit_log.user_id is '用户id';
|
||||
comment on column user_benefit_log.user_phone is '用户手机号';
|
||||
comment on column user_benefit_log.user_name is '用户名称';
|
||||
comment on column user_benefit_log.amount is '金额';
|
||||
comment on column user_benefit_log.source_id is '来源id';
|
||||
comment on column user_benefit_log.user_pack_id is '用户积分包id';
|
||||
comment on column user_benefit_log.source_detail is '来源详情';
|
||||
comment on column user_benefit_log.order_id is '订单id';
|
||||
comment on column user_benefit_log.type is '消费类型 1-收入 2-支出';
|
||||
comment on column user_benefit_log.statistical_date is '统计时间';
|
||||
comment on column user_benefit_log.channel is '消费渠道';
|
||||
comment on column user_benefit_log.channel_detail is '消费渠道详情';
|
||||
comment on column user_benefit_log.remark is '备注';
|
||||
comment on column user_benefit_log.create_user is '创建人';
|
||||
comment on column user_benefit_log.create_dept is '创建部门';
|
||||
comment on column user_benefit_log.create_time is '创建时间';
|
||||
comment on column user_benefit_log.update_user is '修改人';
|
||||
comment on column user_benefit_log.update_time is '修改时间';
|
||||
comment on column user_benefit_log.status is '状态';
|
||||
comment on column user_benefit_log.is_deleted is '是否已删除';
|
||||
alter table user_benefit_log
|
||||
owner to postgres;
|
||||
|
||||
|
||||
|
||||
create table user_commission
|
||||
(
|
||||
id bigint not null primary key,
|
||||
amount decimal(14, 2) default 0,
|
||||
version int default 1,
|
||||
create_user int8,
|
||||
create_dept int8,
|
||||
create_time timestamp(6),
|
||||
update_user int8,
|
||||
update_time timestamp(6),
|
||||
status integer default 1,
|
||||
is_deleted integer default 0
|
||||
);
|
||||
|
||||
|
||||
comment on table user_commission is '用户佣金表';
|
||||
comment on column user_commission.id is '主键';
|
||||
comment on column user_commission.amount is '佣金金额';
|
||||
comment on column user_commission.version is '版本号';
|
||||
comment on column user_commission.create_user is '创建人';
|
||||
comment on column user_commission.create_dept is '创建部门';
|
||||
comment on column user_commission.create_time is '创建时间';
|
||||
comment on column user_commission.update_user is '修改人';
|
||||
comment on column user_commission.update_time is '修改时间';
|
||||
comment on column user_commission.status is '状态';
|
||||
comment on column user_commission.is_deleted is '是否已删除';
|
||||
|
||||
alter table user_commission
|
||||
owner to postgres;
|
||||
|
||||
|
||||
create table user_commission_log
|
||||
(
|
||||
id bigint not null primary key,
|
||||
user_id bigint,
|
||||
user_phone bigint,
|
||||
user_name varchar(128),
|
||||
amount decimal(14, 2) default 0,
|
||||
source_id bigint,
|
||||
source_detail text,
|
||||
order_id bigint,
|
||||
type int default 1,
|
||||
statistical_date timestamp(6),
|
||||
channel varchar(64),
|
||||
channel_detail text,
|
||||
remark text,
|
||||
create_user int8,
|
||||
create_dept int8,
|
||||
create_time timestamp(6),
|
||||
update_user int8,
|
||||
update_time timestamp(6),
|
||||
status integer default 1,
|
||||
is_deleted integer default 0
|
||||
);
|
||||
|
||||
create index user_commission_log_index
|
||||
on user_commission_log (is_deleted, user_id, statistical_date, type);
|
||||
|
||||
comment on table user_commission_log is '用户佣金流水表';
|
||||
comment on column user_commission_log.id is '主键';
|
||||
comment on column user_commission_log.user_id is '用户id';
|
||||
comment on column user_commission_log.user_phone is '用户手机号';
|
||||
comment on column user_commission_log.user_name is '用户名称';
|
||||
comment on column user_commission_log.amount is '金额';
|
||||
comment on column user_commission_log.source_id is '来源id';
|
||||
comment on column user_commission_log.source_detail is '来源详情';
|
||||
comment on column user_commission_log.order_id is '订单id';
|
||||
comment on column user_commission_log.type is '消费类型 1-收入 2-支出';
|
||||
comment on column user_commission_log.statistical_date is '统计时间';
|
||||
comment on column user_commission_log.channel is '消费渠道';
|
||||
comment on column user_commission_log.channel_detail is '消费渠道详情';
|
||||
comment on column user_commission_log.remark is '备注';
|
||||
comment on column user_commission_log.create_user is '创建人';
|
||||
comment on column user_commission_log.create_dept is '创建部门';
|
||||
comment on column user_commission_log.create_time is '创建时间';
|
||||
comment on column user_commission_log.update_user is '修改人';
|
||||
comment on column user_commission_log.update_time is '修改时间';
|
||||
comment on column user_commission_log.status is '状态';
|
||||
comment on column user_commission_log.is_deleted is '是否已删除';
|
||||
|
||||
alter table user_commission_log
|
||||
owner to postgres;
|
||||
|
||||
|
||||
create table user_cash
|
||||
(
|
||||
id bigint not null primary key,
|
||||
amount decimal(14, 2) default 0,
|
||||
version int default 1,
|
||||
create_user int8,
|
||||
create_dept int8,
|
||||
create_time timestamp(6),
|
||||
update_user int8,
|
||||
update_time timestamp(6),
|
||||
status integer default 1,
|
||||
is_deleted integer default 0
|
||||
);
|
||||
|
||||
|
||||
comment on table user_cash is '用户现金券表';
|
||||
comment on column user_cash.id is '主键';
|
||||
comment on column user_cash.amount is '面额';
|
||||
comment on column user_cash.version is '版本号';
|
||||
comment on column user_cash.create_user is '创建人';
|
||||
comment on column user_cash.create_dept is '创建部门';
|
||||
comment on column user_cash.create_time is '创建时间';
|
||||
comment on column user_cash.update_user is '修改人';
|
||||
comment on column user_cash.update_time is '修改时间';
|
||||
comment on column user_cash.status is '状态';
|
||||
comment on column user_cash.is_deleted is '是否已删除';
|
||||
|
||||
alter table user_cash
|
||||
owner to postgres;
|
||||
|
||||
|
||||
create table user_cash_log
|
||||
(
|
||||
id bigint not null primary key,
|
||||
user_id bigint,
|
||||
user_phone bigint,
|
||||
user_name varchar(128),
|
||||
amount decimal(14, 2) default 0,
|
||||
source_id bigint,
|
||||
source_detail text,
|
||||
order_id bigint,
|
||||
type int default 1,
|
||||
statistical_date timestamp(6),
|
||||
channel varchar(64),
|
||||
channel_detail text,
|
||||
remark text,
|
||||
create_user int8,
|
||||
create_dept int8,
|
||||
create_time timestamp(6),
|
||||
update_user int8,
|
||||
update_time timestamp(6),
|
||||
status integer default 1,
|
||||
is_deleted integer default 0
|
||||
);
|
||||
|
||||
create index user_cash_log_index
|
||||
on user_cash_log (is_deleted, user_id, statistical_date , type);
|
||||
|
||||
comment on table user_cash_log is '用户现金券流水表';
|
||||
comment on column user_cash_log.id is '主键';
|
||||
comment on column user_cash_log.user_id is '用户id';
|
||||
comment on column user_cash_log.user_phone is '用户手机号';
|
||||
comment on column user_cash_log.user_name is '用户名称';
|
||||
comment on column user_cash_log.amount is '金额';
|
||||
comment on column user_cash_log.source_id is '来源id';
|
||||
comment on column user_cash_log.source_detail is '来源详情';
|
||||
comment on column user_cash_log.order_id is '订单id';
|
||||
comment on column user_cash_log.type is '消费类型 1-收入 2-支出';
|
||||
comment on column user_cash_log.statistical_date is '统计时间';
|
||||
comment on column user_cash_log.channel is '消费渠道';
|
||||
comment on column user_cash_log.channel_detail is '消费渠道详情';
|
||||
comment on column user_cash_log.remark is '备注';
|
||||
comment on column user_cash_log.create_user is '创建人';
|
||||
comment on column user_cash_log.create_dept is '创建部门';
|
||||
comment on column user_cash_log.create_time is '创建时间';
|
||||
comment on column user_cash_log.update_user is '修改人';
|
||||
comment on column user_cash_log.update_time is '修改时间';
|
||||
comment on column user_cash_log.status is '状态';
|
||||
comment on column user_cash_log.is_deleted is '是否已删除';
|
||||
|
||||
alter table user_cash_log
|
||||
owner to postgres;
|
||||
|
||||
|
||||
create table user_mall_integral
|
||||
(
|
||||
id bigint not null primary key,
|
||||
amount decimal(14, 2) default 0,
|
||||
version int default 1,
|
||||
create_user int8,
|
||||
create_dept int8,
|
||||
create_time timestamp(6),
|
||||
update_user int8,
|
||||
update_time timestamp(6),
|
||||
status integer default 1,
|
||||
is_deleted integer default 0
|
||||
);
|
||||
|
||||
|
||||
comment on table user_mall_integral is '用户商城积分表';
|
||||
comment on column user_mall_integral.amount is '面额';
|
||||
comment on column user_mall_integral.version is '版本号';
|
||||
comment on column user_mall_integral.create_user is '创建人';
|
||||
comment on column user_mall_integral.create_dept is '创建部门';
|
||||
comment on column user_mall_integral.create_time is '创建时间';
|
||||
comment on column user_mall_integral.update_user is '修改人';
|
||||
comment on column user_mall_integral.update_time is '修改时间';
|
||||
comment on column user_mall_integral.is_deleted is '是否已删除';
|
||||
|
||||
alter table user_mall_integral
|
||||
owner to postgres;
|
||||
|
||||
|
||||
create table user_mall_integral_log
|
||||
(
|
||||
id bigint not null primary key,
|
||||
user_id bigint,
|
||||
user_phone bigint,
|
||||
user_name varchar(128),
|
||||
amount decimal(14, 2) default 0,
|
||||
source_id bigint,
|
||||
source_detail text,
|
||||
order_id bigint,
|
||||
type int default 1,
|
||||
statistical_date timestamp(6),
|
||||
channel varchar(64),
|
||||
channel_detail text,
|
||||
remark text,
|
||||
create_user int8,
|
||||
create_dept int8,
|
||||
create_time timestamp(6),
|
||||
update_user int8,
|
||||
update_time timestamp(6),
|
||||
status integer default 1,
|
||||
is_deleted integer default 0
|
||||
);
|
||||
|
||||
create index user_mall_integral_log_index
|
||||
on user_mall_integral_log (is_deleted, user_id, statistical_date , type);
|
||||
|
||||
comment on table user_mall_integral_log is '用户商城积分流水表';
|
||||
comment on column user_mall_integral_log.id is '主键';
|
||||
comment on column user_mall_integral_log.user_id is '用户id';
|
||||
comment on column user_mall_integral_log.user_phone is '用户手机号';
|
||||
comment on column user_mall_integral_log.user_name is '用户名称';
|
||||
comment on column user_mall_integral_log.amount is '金额';
|
||||
comment on column user_mall_integral_log.source_id is '来源id';
|
||||
comment on column user_mall_integral_log.source_detail is '来源详情';
|
||||
comment on column user_mall_integral_log.order_id is '订单id';
|
||||
comment on column user_mall_integral_log.type is '消费类型 1-收入 2-支出';
|
||||
comment on column user_mall_integral_log.statistical_date is '统计时间';
|
||||
comment on column user_mall_integral_log.channel is '消费渠道';
|
||||
comment on column user_mall_integral_log.channel_detail is '消费渠道详情';
|
||||
comment on column user_mall_integral_log.remark is '备注';
|
||||
comment on column user_mall_integral_log.create_user is '创建人';
|
||||
comment on column user_mall_integral_log.create_dept is '创建部门';
|
||||
comment on column user_mall_integral_log.create_time is '创建时间';
|
||||
comment on column user_mall_integral_log.update_user is '修改人';
|
||||
comment on column user_mall_integral_log.update_time is '修改时间';
|
||||
comment on column user_mall_integral_log.status is '状态';
|
||||
comment on column user_mall_integral_log.is_deleted is '是否已删除';
|
||||
|
||||
alter table user_mall_integral_log
|
||||
owner to postgres;
|
||||
|
||||
|
||||
|
||||
create table user_gains_day
|
||||
(
|
||||
id bigint not null primary key,
|
||||
statistical_date timestamp(6),
|
||||
user_id bigint,
|
||||
amount decimal(14, 2) default 0,
|
||||
gains_details text,
|
||||
is_credited integer default 0,
|
||||
version int default 1,
|
||||
create_user int8,
|
||||
create_dept int8,
|
||||
create_time timestamp(6),
|
||||
update_user int8,
|
||||
update_time timestamp(6),
|
||||
status integer default 1,
|
||||
is_deleted integer default 0
|
||||
);
|
||||
|
||||
create index ugd_date_index
|
||||
on user_gains_day (is_deleted, statistical_date , is_credited);
|
||||
|
||||
comment on table user_gains_day is '用户每日加速福利值汇总表';
|
||||
comment on column user_gains_day.id is '主键';
|
||||
comment on column user_gains_day.statistical_date is '统计时间';
|
||||
comment on column user_gains_day.user_id is '用户id';
|
||||
comment on column user_gains_day.amount is '金额';
|
||||
comment on column user_gains_day.gains_details is '福利值汇总详情';
|
||||
comment on column user_gains_day.is_credited is '是否已入账 0-未入账 1-已入账';
|
||||
comment on column user_gains_day.version is '版本号';
|
||||
comment on column user_gains_day.create_user is '创建人';
|
||||
comment on column user_gains_day.create_dept is '创建部门';
|
||||
comment on column user_gains_day.create_time is '创建时间';
|
||||
comment on column user_gains_day.update_user is '修改人';
|
||||
comment on column user_gains_day.update_time is '修改时间';
|
||||
comment on column user_gains_day.status is '状态';
|
||||
comment on column user_gains_day.is_deleted is '是否已删除';
|
||||
|
||||
alter table user_gains_day
|
||||
owner to postgres;
|
||||
|
||||
create table user_gains_day_log
|
||||
(
|
||||
id bigint not null primary key,
|
||||
user_id bigint,
|
||||
user_phone bigint,
|
||||
user_name varchar(128),
|
||||
amount decimal(14, 2) default 0,
|
||||
source_id bigint,
|
||||
source_detail text,
|
||||
gains_details text,
|
||||
order_id bigint,
|
||||
statistical_date timestamp(6),
|
||||
is_summary integer default 0,
|
||||
remark text,
|
||||
create_user int8,
|
||||
create_dept int8,
|
||||
create_time timestamp(6),
|
||||
update_user int8,
|
||||
update_time timestamp(6),
|
||||
status integer default 1,
|
||||
is_deleted integer default 0
|
||||
|
||||
);
|
||||
create index ugd_log_date_index
|
||||
on user_gains_day_log (is_deleted, statistical_date , is_summary );
|
||||
|
||||
comment on table user_gains_day_log is '用户每日加速福利值流水表';
|
||||
comment on column user_gains_day_log.id is '主键';
|
||||
comment on column user_gains_day_log.user_id is '用户id';
|
||||
comment on column user_gains_day_log.user_phone is '用户手机号';
|
||||
comment on column user_gains_day_log.user_name is '用户名称';
|
||||
comment on column user_gains_day_log.amount is '金额';
|
||||
comment on column user_gains_day_log.source_id is '来源id';
|
||||
comment on column user_gains_day_log.source_detail is '来源详情';
|
||||
comment on column user_gains_day_log.gains_details is '加速福利详情';
|
||||
comment on column user_gains_day_log.order_id is '订单id';
|
||||
comment on column user_gains_day_log.statistical_date is '统计时间';
|
||||
comment on column user_gains_day_log.is_summary is '是否汇总 0-否 1-是';
|
||||
comment on column user_gains_day_log.remark is '备注';
|
||||
comment on column user_gains_day_log.create_user is '创建人';
|
||||
comment on column user_gains_day_log.create_dept is '创建部门';
|
||||
comment on column user_gains_day_log.create_time is '创建时间';
|
||||
comment on column user_gains_day_log.update_user is '修改人';
|
||||
comment on column user_gains_day_log.update_time is '修改时间';
|
||||
comment on column user_gains_day_log.status is '状态';
|
||||
comment on column user_gains_day_log.is_deleted is '是否已删除';
|
||||
alter table user_gains_day_log
|
||||
owner to postgres;
|
||||
Reference in New Issue
Block a user