From a02155d539012e1ccb34c2d0c1c694bedb5000b2 Mon Sep 17 00:00:00 2001 From: iridiumR Date: Tue, 23 May 2023 19:30:58 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=E8=A1=A8=E7=BB=93?= =?UTF-8?q?=E6=9E=84=EF=BC=8C=E6=B7=BB=E5=8A=A0=20drop=20=E8=84=9A?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/create_table.sql | 27 +++++++++++++++++++-------- scripts/drop_table.sql | 5 +++++ 2 files changed, 24 insertions(+), 8 deletions(-) create mode 100644 scripts/drop_table.sql diff --git a/scripts/create_table.sql b/scripts/create_table.sql index b5aa279..4e633ff 100644 --- a/scripts/create_table.sql +++ b/scripts/create_table.sql @@ -1,7 +1,7 @@ -- 账户表 CREATE TABLE account ( - a_id SERIAL PRIMARY KEY, - meta JSONB + a_id SERIAL PRIMARY KEY, --账户号 + meta JSONB -- 元数据 ); -- {"name":"name", -- "balance": 0.00, @@ -13,8 +13,8 @@ CREATE TABLE account ( -- 类别表 CREATE TABLE category ( - c_id SERIAL PRIMARY KEY, - meta JSONB + c_id SERIAL PRIMARY KEY, -- 类别号 + meta JSONB -- 元数据 ); -- {"name":"name", -- "type":"in"/"out", @@ -26,13 +26,14 @@ CREATE TABLE category ( -- 流水表 CREATE TABLE transaction ( - t_id SERIAL PRIMARY KEY, - c_id INTEGER REFERENCES category(c_id), - a_id INTEGER REFERENCES account(a_id), - meta JSONB + t_id SERIAL PRIMARY KEY, -- 流水号 + c_id INTEGER REFERENCES category(c_id), -- 关联账户号 + a_id INTEGER REFERENCES account(a_id), -- 关联类别号 + meta JSONB -- 元数据 ); -- {"discription":"something",(可选) -- "type":"in"/"out"/"transfer", + -- "transfer_dist":a_id,(可选) -- "reimburse":{ (报销) -- "finish": true, @@ -40,4 +41,14 @@ CREATE TABLE transaction ( -- } -- "":"something"} +-- 转账表 记录转账信息 +CREATE TABLE account_transaction( + at_id SERIAL PRIMARY KEY, -- 转账号 + src INTEGER REFERENCES category(c_id), -- 源账户号 + dst INTEGER REFERENCES category(c_id), -- 目的账户号 + meta JSONB -- 元数据 +); + + + diff --git a/scripts/drop_table.sql b/scripts/drop_table.sql new file mode 100644 index 0000000..92d280d --- /dev/null +++ b/scripts/drop_table.sql @@ -0,0 +1,5 @@ +DROP TABLE transaction; +DROP TABLE account_transaction; +DROP TABLE category; +DROP TABLE account; +