diff --git a/scripts/sql/init.sql b/scripts/sql/init.sql index c53e667..d01cd2d 100644 --- a/scripts/sql/init.sql +++ b/scripts/sql/init.sql @@ -618,8 +618,8 @@ create table resource_pss ( on delete cascade, type int, live int, - quota int, expire timestamp, + quota int, used int not null default 0, daily_limit int not null default 0, daily_used int not null default 0, @@ -748,7 +748,7 @@ comment on column trade.deleted_at is '删除时间'; drop table if exists bill cascade; create table bill ( id serial primary key, - order_id int not null references trade (id) + trade_id int not null references trade (id) on update cascade on delete cascade, user_id int not null references "user" (id) @@ -766,14 +766,14 @@ create table bill ( updated_at timestamp default current_timestamp, deleted_at timestamp ); -create index bill_order_id_index on bill (order_id); +create index bill_trade_id_index on bill (trade_id); create index bill_product_id_index on bill (product_id); create index bill_deleted_at_index on bill (deleted_at); -- bill表字段注释 comment on table bill is '账单表'; comment on column bill.id is '账单ID'; -comment on column bill.order_id is '订单ID'; +comment on column bill.trade_id is '订单ID'; comment on column bill.user_id is '用户ID'; comment on column bill.product_id is '产品ID'; comment on column bill.info is '产品可读信息'; @@ -789,7 +789,7 @@ comment on column bill.deleted_at is '删除时间'; drop table if exists refund cascade; create table refund ( id serial primary key, - order_id int not null references trade (id) + trade_id int not null references trade (id) on update cascade on delete cascade, product_id int references product (id) -- @@ -800,14 +800,14 @@ create table refund ( updated_at timestamp default current_timestamp, deleted_at timestamp ); -create index refund_order_id_index on refund (order_id); +create index refund_trade_id_index on refund (trade_id); create index refund_product_id_index on refund (product_id); create index refund_deleted_at_index on refund (deleted_at); -- refund表字段注释 comment on table refund is '退款记录表'; comment on column refund.id is '退款ID'; -comment on column refund.order_id is '订单ID'; +comment on column refund.trade_id is '订单ID'; comment on column refund.product_id is '产品ID'; comment on column refund.amount is '退款金额'; comment on column refund.created_at is '创建时间';