From e0d7cd9bbf02e7d52aadfb8d56f774a8a4099adf Mon Sep 17 00:00:00 2001
From: Joe Carstairs <me@joeac.net>
Date: Mon, 9 Sep 2024 21:54:04 +0100
Subject: Improves backend schema

---
 backend/migrations/2024-08-31-084439_initial_setup/up.sql | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

(limited to 'backend/migrations/2024-08-31-084439_initial_setup/up.sql')

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
-- 
cgit v1.2.3

