整理格式

This commit is contained in:
iridiumR 2023-06-05 20:47:58 +08:00
parent dd3c3f6244
commit 57e02c7bc9
No known key found for this signature in database
GPG key ID: 49735733EB1A32C8

View file

@ -1,11 +1,10 @@
-- 账户表 -- 账户表
CREATE TABLE account ( CREATE TABLE account (
a_id SERIAL PRIMARY KEY, -- 账户号 a_id SERIAL PRIMARY KEY, -- 账户号
balance MONEY, -- 余额 balance MONEY, -- 余额
meta JSONB -- 元数据 meta JSONB -- 元数据
); );
-- {"name":"name", -- {"name":"name",
-- time:"2022-02-02",
-- “budget": [ -- “budget": [
-- {"time":"2022-02","value":20.32}, -- {"time":"2022-02","value":20.32},
-- {"time":"2022-01","value":30.32} -- {"time":"2022-01","value":30.32}
@ -14,8 +13,8 @@ CREATE TABLE account (
-- 类别表 -- 类别表
CREATE TABLE category ( CREATE TABLE category (
c_id SERIAL PRIMARY KEY, -- 类别号 c_id SERIAL PRIMARY KEY, -- 类别号
meta JSONB -- 元数据 meta JSONB -- 元数据
); );
-- {"name":"name", -- {"name":"name",
-- "type":"in"/"out", -- "type":"in"/"out",
@ -27,19 +26,18 @@ CREATE TABLE category (
-- 流水表 -- 流水表
CREATE TABLE transaction ( CREATE TABLE transaction (
t_id SERIAL PRIMARY KEY, -- 流水号 t_id SERIAL PRIMARY KEY, -- 流水号
a_id INTEGER REFERENCES account(a_id) NOT NULL, -- 关联账户号 a_id INTEGER REFERENCES account(a_id) NOT NULL, -- 关联账户号
c_id INTEGER REFERENCES category(c_id), -- 关联类别号 c_id INTEGER REFERENCES category(c_id), -- 关联类别号
s_id INTEGER REFERENCES account(a_id), -- 源账户号 s_id INTEGER REFERENCES account(a_id), -- 源账户号
time TIMESTAMP, time TIMESTAMP,
amount MONEY, amount MONEY,
meta JSONB -- 元数据 meta JSONB -- 元数据
); );
-- {"discription":"something",(可选) -- {"discription":"something",
-- "type":"in"/"out"/"transfer"/"init"/"modify", -- "type":"in"/"out"/"transfer"/"init",
-- "reimburse":{
-- "reimburse":{ (报销) -- "finish": true/false,
-- "finish": true,
-- "ref":t_id -- "ref":t_id
-- } -- }
-- "":"something"} -- "":"something"}