aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/database/migrations/0001_initial.sql
diff options
context:
space:
mode:
authorLeonardo Bishop <me@leonardobishop.com>2025-01-17 13:21:24 +0000
committerLeonardo Bishop <me@leonardobishop.com>2025-01-17 13:21:24 +0000
commitc00b690bd6f600554a1404e692bd9e4373325d27 (patch)
tree4488b625e1c24af52fced6f60ac1b3ddff1383bc /pkg/database/migrations/0001_initial.sql
Initial commit
Diffstat (limited to 'pkg/database/migrations/0001_initial.sql')
-rw-r--r--pkg/database/migrations/0001_initial.sql17
1 files changed, 17 insertions, 0 deletions
diff --git a/pkg/database/migrations/0001_initial.sql b/pkg/database/migrations/0001_initial.sql
new file mode 100644
index 0000000..eea0a73
--- /dev/null
+++ b/pkg/database/migrations/0001_initial.sql
@@ -0,0 +1,17 @@
+-- +goose Up
+CREATE TABLE users (
+ id int GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
+ username varchar(20) UNIQUE NOT NULL,
+ password char(60) NOT NULL
+);
+
+CREATE TABLE favourites (
+ id int GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
+ user_id int NOT NULL,
+ event_guid uuid,
+ event_id int,
+ UNIQUE(user_id, event_guid, event_id),
+ CONSTRAINT chk_favourites CHECK (event_guid IS NOT NULL OR event_id IS NOT NULL),
+ FOREIGN KEY (user_id) REFERENCES users(id)
+);
+