create initial db migrations
This commit is contained in:
parent
15a5249cda
commit
65a32f1f20
2 changed files with 50 additions and 0 deletions
10
migrations/20230426221940_init.down.sql
Normal file
10
migrations/20230426221940_init.down.sql
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
-- indices
|
||||||
|
drop index if exists witch_dex;
|
||||||
|
drop index if exists watch_dex;
|
||||||
|
drop index if exists ww_dex;
|
||||||
|
-- tables
|
||||||
|
drop table if exists witch_watch;
|
||||||
|
drop table if exists covens;
|
||||||
|
drop table if exists witches;
|
||||||
|
drop table if exists watches;
|
||||||
|
|
40
migrations/20230426221940_init.up.sql
Normal file
40
migrations/20230426221940_init.up.sql
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
-- note: sqlite-specific migration due to the types of the columns
|
||||||
|
|
||||||
|
-- users
|
||||||
|
create table if not exists witches (
|
||||||
|
id blob not null primary key,
|
||||||
|
last_seen int, -- date in 64-bit unix epoch
|
||||||
|
name text,
|
||||||
|
email text
|
||||||
|
);
|
||||||
|
|
||||||
|
-- table of things to watch
|
||||||
|
create table if not exists watches (
|
||||||
|
id blob not null primary key,
|
||||||
|
typ int not null, -- enum for movie or tv or whatev
|
||||||
|
title text not null,
|
||||||
|
imdb text -- possible url for imdb entry
|
||||||
|
);
|
||||||
|
|
||||||
|
-- table of what people want to watch
|
||||||
|
create table if not exists witch_watch (
|
||||||
|
id blob not null primary key,
|
||||||
|
witch blob not null,
|
||||||
|
watch blob not null,
|
||||||
|
public boolean not null,
|
||||||
|
watched boolean not null,
|
||||||
|
foreign key (witch) references witches (id) on delete cascade on update no action,
|
||||||
|
foreign key (watch) references watches (id) on delete cascade on update no action
|
||||||
|
);
|
||||||
|
|
||||||
|
-- friend lists; this should really be a graph db, maybe the whole thing should be
|
||||||
|
create table if not exists covens (
|
||||||
|
witch blob not null primary key,
|
||||||
|
coven blob, -- possibly empty friends list in some format the application will understand
|
||||||
|
foreign key (witch) references witches (id) on delete cascade on update no action
|
||||||
|
);
|
||||||
|
|
||||||
|
-- indices, not needed for covens
|
||||||
|
create index if not exists witch_dex on witches ( id, name, email );
|
||||||
|
create index if not exists watch_dex on watches ( id, title, typ );
|
||||||
|
create index if not exists ww_dex on witch_watch ( id, witch, watch );
|
Loading…
Reference in a new issue