summaryrefslogtreecommitdiff
path: root/backend/migrations/2024-08-31-084439_initial_setup/up.sql
diff options
context:
space:
mode:
authorJoe Carstairs <me@joeac.net>2024-09-09 21:54:04 +0100
committerJoe Carstairs <me@joeac.net>2024-09-09 21:54:04 +0100
commite0d7cd9bbf02e7d52aadfb8d56f774a8a4099adf (patch)
tree35e842d6189ada933cf5fdc4a06cf0b8f4d3f03c /backend/migrations/2024-08-31-084439_initial_setup/up.sql
parent5042dabb88006cd26b9a06fe4484c1db797ef414 (diff)
Improves backend schema
Diffstat (limited to 'backend/migrations/2024-08-31-084439_initial_setup/up.sql')
-rw-r--r--backend/migrations/2024-08-31-084439_initial_setup/up.sql7
1 files changed, 6 insertions, 1 deletions
diff --git a/backend/migrations/2024-08-31-084439_initial_setup/up.sql b/backend/migrations/2024-08-31-084439_initial_setup/up.sql
index f2461a5..a43f6dd 100644
--- a/backend/migrations/2024-08-31-084439_initial_setup/up.sql
+++ b/backend/migrations/2024-08-31-084439_initial_setup/up.sql
@@ -26,11 +26,16 @@ CREATE TABLE categories(
initial_period INTEGER NOT NULL
);
-CREATE TABLE category_transactions(
+CREATE TABLE transaction_categorisations(
id INTEGER NOT NULL PRIMARY KEY,
description TEXT NOT NULL,
quantity INTEGER NOT NULL,
+ transaction_id INTEGER NOT NULL,
category_id INTEGER NOT NULL,
+ FOREIGN KEY (transaction_id)
+ REFERENCES transactions (id)
+ ON UPDATE CASCADE
+ ON DELETE RESTRICT,
FOREIGN KEY (category_id)
REFERENCES categories (id)
ON UPDATE CASCADE