Refactored src and dst account to just account in preparation for a "counter party", instead of a full account.
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
CREATE TABLE account_members (
|
||||
account_id UUID NOT NULL CONSTRAINT fk_account_members_account REFERENCES accounts (id),
|
||||
user_id UUID NOT NULL CONSTRAINT fk_account_members_user REFERENCES users (id),
|
||||
PRIMARY KEY (account_id, user_id)
|
||||
);
|
||||
@@ -0,0 +1,4 @@
|
||||
CREATE TABLE counter_parties (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid (),
|
||||
label TEXT
|
||||
);
|
||||
@@ -1,7 +1,8 @@
|
||||
CREATE TABLE transactions (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid (),
|
||||
description TEXT NOT NULL,
|
||||
account_id UUID NOT NULL CONSTRAINT fk_transactions_account REFERENCES accounts (id),
|
||||
amount_cents BIGINT NOT NULL CHECK (amount_cents >= 0),
|
||||
direction TEXT NOT NULL CHECK (direction IN ('in', 'out')),
|
||||
date TIMESTAMPTZ NOT NULL DEFAULT now()
|
||||
date TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
description TEXT NOT NULL
|
||||
);
|
||||
@@ -1,10 +1,9 @@
|
||||
CREATE TABLE recurring_transactions (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid (),
|
||||
name TEXT NOT NULL,
|
||||
account_id UUID NOT NULL CONSTRAINT fk_recurring_transactions_account REFERENCES accounts (id),
|
||||
amount_cents BIGINT NOT NULL CHECK (amount_cents >= 0),
|
||||
direction TEXT NOT NULL CHECK (direction IN ('in', 'out')),
|
||||
source_account_id UUID CONSTRAINT fk_recurring_transactions_source_account REFERENCES accounts (id),
|
||||
destination_account_id UUID CONSTRAINT fk_recurring_transactions_destination_account REFERENCES accounts (id),
|
||||
starts_at TIMESTAMPTZ NOT NULL,
|
||||
ends_at TIMESTAMPTZ,
|
||||
recurrence_every INTEGER NOT NULL CHECK (recurrence_every > 0),
|
||||
|
||||
@@ -18,34 +18,36 @@ VALUES (
|
||||
INSERT INTO
|
||||
transactions (
|
||||
id,
|
||||
description,
|
||||
account_id,
|
||||
amount_cents,
|
||||
direction,
|
||||
date
|
||||
date,
|
||||
description
|
||||
)
|
||||
VALUES (
|
||||
'00000000-0000-0000-0000-000000000001',
|
||||
'Salary',
|
||||
'00000000-0000-0000-0000-000000000001',
|
||||
320000,
|
||||
'in',
|
||||
'2026-09-01T09:00:00Z'
|
||||
'2026-09-01T09:00:00Z',
|
||||
'Salary'
|
||||
),
|
||||
(
|
||||
'00000000-0000-0000-0000-000000000002',
|
||||
'Groceries',
|
||||
'00000000-0000-0000-0000-000000000001',
|
||||
8450,
|
||||
'out',
|
||||
'2026-09-18T17:30:00Z'
|
||||
'2026-09-18T17:30:00Z',
|
||||
'Groceries'
|
||||
);
|
||||
|
||||
INSERT INTO
|
||||
recurring_transactions (
|
||||
id,
|
||||
name,
|
||||
account_id,
|
||||
amount_cents,
|
||||
direction,
|
||||
source_account_id,
|
||||
destination_account_id,
|
||||
starts_at,
|
||||
ends_at,
|
||||
recurrence_every,
|
||||
@@ -55,10 +57,9 @@ INSERT INTO
|
||||
VALUES (
|
||||
'00000000-0000-0000-0000-000000000101',
|
||||
'Salary',
|
||||
'00000000-0000-0000-0000-000000000001',
|
||||
320000,
|
||||
'in',
|
||||
'00000000-0000-0000-0000-000000000001',
|
||||
NULL,
|
||||
'2026-10-01T09:00:00Z',
|
||||
NULL,
|
||||
1,
|
||||
@@ -68,10 +69,9 @@ VALUES (
|
||||
(
|
||||
'00000000-0000-0000-0000-000000000102',
|
||||
'Rent',
|
||||
'00000000-0000-0000-0000-000000000001',
|
||||
125000,
|
||||
'out',
|
||||
NULL,
|
||||
'00000000-0000-0000-0000-000000000001',
|
||||
'2026-10-01T09:00:00Z',
|
||||
NULL,
|
||||
1,
|
||||
|
||||
Reference in New Issue
Block a user