diff options
| author | Joe Carstairs <me@joeac.net> | 2024-09-09 21:54:04 +0100 |
|---|---|---|
| committer | Joe Carstairs <me@joeac.net> | 2024-09-09 21:54:04 +0100 |
| commit | e0d7cd9bbf02e7d52aadfb8d56f774a8a4099adf (patch) | |
| tree | 35e842d6189ada933cf5fdc4a06cf0b8f4d3f03c /backend/migrations | |
| parent | 5042dabb88006cd26b9a06fe4484c1db797ef414 (diff) | |
Improves backend schema
Diffstat (limited to 'backend/migrations')
| -rw-r--r-- | backend/migrations/2024-08-31-084439_initial_setup/down.sql | 2 | ||||
| -rw-r--r-- | backend/migrations/2024-08-31-084439_initial_setup/up.sql | 7 |
2 files changed, 7 insertions, 2 deletions
diff --git a/backend/migrations/2024-08-31-084439_initial_setup/down.sql b/backend/migrations/2024-08-31-084439_initial_setup/down.sql index 5e68c99..8cf4b1e 100644 --- a/backend/migrations/2024-08-31-084439_initial_setup/down.sql +++ b/backend/migrations/2024-08-31-084439_initial_setup/down.sql @@ -1,6 +1,6 @@ DROP TABLE accounts; DROP TABLE budget_updates; DROP TABLE categories; -DROP TABLE category_transactions; +DROP TABLE transaction_categorisations; DROP TABLE category_transfers; DROP TABLE transactions; 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 |
