From ba1f9119e8eaf193844610c3fa0f95ba6dd613ee Mon Sep 17 00:00:00 2001 From: Joe Ardent Date: Tue, 9 Apr 2024 17:44:37 -0700 Subject: [PATCH] make date-related columns "text". --- migrations/20240116054222_users_and_invites.up.sql | 8 ++++---- migrations/20240116054243_watches_and_quests.up.sql | 12 ++++++------ migrations/20240116054253_stars_and_credits.up.sql | 4 ++-- migrations/20240116054301_follows.up.sql | 2 +- migrations/20240409233522_views.down.sql | 2 ++ migrations/20240409233522_views.up.sql | 5 +++-- 6 files changed, 18 insertions(+), 15 deletions(-) diff --git a/migrations/20240116054222_users_and_invites.up.sql b/migrations/20240116054222_users_and_invites.up.sql index 3ddd60c..2c79591 100644 --- a/migrations/20240116054222_users_and_invites.up.sql +++ b/migrations/20240116054222_users_and_invites.up.sql @@ -3,11 +3,11 @@ create table if not exists users ( username text not null unique, displayname text, email text, - last_seen datetime, + last_seen text, pwhash blob not null, invited_by blob not null, is_active boolean not null default true, - last_updated datetime not null default CURRENT_TIMESTAMP, + last_updated text not null default CURRENT_TIMESTAMP, foreign key (invited_by) references users (id) ); create index if not exists users_username_dex on users (lower(username)); @@ -25,9 +25,9 @@ END; create table if not exists invites ( id blob not null primary key default (julid_new()), owner blob not null, - expires_at datetime, + expires_at text, remaining int not null default 1, - last_updated datetime not null default CURRENT_TIMESTAMP, + last_updated text not null default CURRENT_TIMESTAMP, foreign key (owner) references users (id) on delete cascade on update no action ); create index if not exists invites_owner_dex on invites (owner); diff --git a/migrations/20240116054243_watches_and_quests.up.sql b/migrations/20240116054243_watches_and_quests.up.sql index 76fa7b0..ba4491b 100644 --- a/migrations/20240116054243_watches_and_quests.up.sql +++ b/migrations/20240116054243_watches_and_quests.up.sql @@ -5,9 +5,9 @@ create table if not exists watches ( title text not null, metadata_url text, -- possible url for imdb or other metadata-esque site to show the user length int, - release_date date, + release_date text, added_by blob not null, -- ID of the user that added it - last_updated datetime not null default CURRENT_TIMESTAMP, + last_updated text not null default CURRENT_TIMESTAMP, foreign key (added_by) references users (id) ); create index if not exists watches_title_dex on watches (lower(title)); @@ -26,9 +26,9 @@ create table if not exists watch_quests ( priority int, -- 1-5 how much do you want to watch it public boolean not null default true, watched boolean not null default false, - when_watched datetime, - created_at datetime not null default CURRENT_TIMESTAMP, - last_updated datetime not null default CURRENT_TIMESTAMP, + when_watched text, + created_at text not null default CURRENT_TIMESTAMP, + last_updated text not null default CURRENT_TIMESTAMP, foreign key (user) references users (id) on delete cascade on update no action, foreign key (watch) references watches (id) on delete cascade on update no action, primary key (user, watch) @@ -50,7 +50,7 @@ create table if not exists watch_notes ( watch blob not null, note blob, public boolean not null, - last_updated datetime not null default CURRENT_TIMESTAMP, + last_updated text not null default CURRENT_TIMESTAMP, foreign key (user) references users (id) on delete cascade on update no action, foreign key (watch) references watches (id) on delete cascade on update no action ); diff --git a/migrations/20240116054253_stars_and_credits.up.sql b/migrations/20240116054253_stars_and_credits.up.sql index 7590513..b70ef2e 100644 --- a/migrations/20240116054253_stars_and_credits.up.sql +++ b/migrations/20240116054253_stars_and_credits.up.sql @@ -2,8 +2,8 @@ create table if not exists stars ( id blob not null primary key default (julid_new()), name text not null, metadata_url text, - born date, - died date + born text, + died text ); create index if not exists stars_name_dex on stars (lower(name)); diff --git a/migrations/20240116054301_follows.up.sql b/migrations/20240116054301_follows.up.sql index a1c29a4..e24dd55 100644 --- a/migrations/20240116054301_follows.up.sql +++ b/migrations/20240116054301_follows.up.sql @@ -1,7 +1,7 @@ create table if not exists follows ( follower blob not null, followee blob not null, - created_at datetime not null default CURRENT_TIMESTAMP, + created_at text not null default CURRENT_TIMESTAMP, foreign key (follower) references users (id) on delete cascade on update no action, foreign key (followee) references users (id) on delete cascade on update no action, unique (follower, followee) diff --git a/migrations/20240409233522_views.down.sql b/migrations/20240409233522_views.down.sql index e4302ca..c77f738 100644 --- a/migrations/20240409233522_views.down.sql +++ b/migrations/20240409233522_views.down.sql @@ -1,2 +1,4 @@ +drop view if exists i; +drop view if exists u; drop view if exists s; drop view if exists w; diff --git a/migrations/20240409233522_views.up.sql b/migrations/20240409233522_views.up.sql index 7700e81..729e1e7 100644 --- a/migrations/20240409233522_views.up.sql +++ b/migrations/20240409233522_views.up.sql @@ -1,3 +1,4 @@ create view if not exists w as select julid_string(id) id, kind, title, metadata_url, length, release_date, last_updated from watches; - -create view if not exists s as select julid_string(id) id, name, born, died; +create view if not exists s as select julid_string(id) id, name, born, died from stars; +create view if not exists u as select julid_string(id) id, username, displayname, email, last_seen, last_updated from users; +create view if not exists i as select julid_string(id) id, julid_string(owner) owner, expires_at, remaining, last_updated from invites;