feat: 更新表结构,添加 drop 脚本

This commit is contained in:
iridiumR 2023-05-23 19:30:58 +08:00
parent 33fbd421b9
commit a02155d539
No known key found for this signature in database
GPG key ID: 49735733EB1A32C8
2 changed files with 24 additions and 8 deletions

View file

@ -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 -- 元数据
);

5
scripts/drop_table.sql Normal file
View file

@ -0,0 +1,5 @@
DROP TABLE transaction;
DROP TABLE account_transaction;
DROP TABLE category;
DROP TABLE account;