diff options
| author | Leonardo Bishop <me@leonardobishop.com> | 2025-01-20 02:56:25 +0000 |
|---|---|---|
| committer | Leonardo Bishop <me@leonardobishop.com> | 2025-01-20 02:56:25 +0000 |
| commit | dc55f9c0097e1c36b85d7666071b840b902920e9 (patch) | |
| tree | c8c8ae10a9e134810b3361aabc8a9d426d813808 /pkg/database/migrations/0001_initial.sql | |
| parent | 5e7ce6cbae81a1b6e46fe6738dc10039a06bec95 (diff) | |
Add calendar support
Diffstat (limited to 'pkg/database/migrations/0001_initial.sql')
| -rw-r--r-- | pkg/database/migrations/0001_initial.sql | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/pkg/database/migrations/0001_initial.sql b/pkg/database/migrations/0001_initial.sql index eea0a73..a1f5fda 100644 --- a/pkg/database/migrations/0001_initial.sql +++ b/pkg/database/migrations/0001_initial.sql @@ -1,8 +1,8 @@ -- +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 + username varchar(20) UNIQUE NOT NULL CONSTRAINT non_blank_username CHECK(length(username) > 0), + password text NOT NULL CONSTRAINT valid_hash CHECK (length(password) = 60) ); CREATE TABLE favourites ( @@ -11,7 +11,16 @@ CREATE TABLE favourites ( 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) + CONSTRAINT require_event_detail CHECK (event_guid IS NOT NULL OR event_id IS NOT NULL), + FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE ); +CREATE TABLE calendars ( + id int GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, + user_id int NOT NULL, + name text NOT NULL CONSTRAINT non_blank_name CHECK(length(name) > 0), + key text NOT NULL, + UNIQUE(user_id), + UNIQUE(name), + FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE +); |
