add unique constraint for quests
This commit is contained in:
parent
5aa7a64354
commit
c685dc1a6b
1 changed files with 10 additions and 8 deletions
|
@ -38,9 +38,11 @@ create table if not exists watch_quests (
|
||||||
created_at int not null default (unixepoch()),
|
created_at int not null default (unixepoch()),
|
||||||
last_updated int not null default (unixepoch()),
|
last_updated int not null default (unixepoch()),
|
||||||
foreign key (user) references users (id) on delete cascade on update no action,
|
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
|
foreign key (watch) references watches (id) on delete cascade on update no action,
|
||||||
|
primary key (user, watch)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
-- friend lists; created by trigger at the same time as the user, so no created_at needed
|
-- friend lists; created by trigger at the same time as the user, so no created_at needed
|
||||||
create table if not exists follows (
|
create table if not exists follows (
|
||||||
user blob not null primary key,
|
user blob not null primary key,
|
||||||
|
@ -50,22 +52,22 @@ create table if not exists follows (
|
||||||
);
|
);
|
||||||
|
|
||||||
create table if not exists watch_notes (
|
create table if not exists watch_notes (
|
||||||
|
id blob not null primary key, -- a user can have multiple notes about the same thing
|
||||||
user blob not null,
|
user blob not null,
|
||||||
watch blob not null,
|
watch blob not null,
|
||||||
note blob,
|
note blob,
|
||||||
public boolean not null,
|
public boolean not null,
|
||||||
created_at int not null default (unixepoch()),
|
|
||||||
last_updated int not null default (unixepoch()),
|
last_updated int not null default (unixepoch()),
|
||||||
foreign key (user) references users (id) on delete cascade on update no action,
|
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
|
foreign key (watch) references watches (id) on delete cascade on update no action
|
||||||
);
|
);
|
||||||
|
|
||||||
-- indices, not needed for follows
|
-- indices, not needed for follows
|
||||||
create index if not exists user_username_dex on users (lower(username));
|
create index if not exists users_username_dex on users (lower(username));
|
||||||
create index if not exists user_email_dex on users (lower(email));
|
create index if not exists users_email_dex on users (lower(email));
|
||||||
create index if not exists watch_title_dex on watches (lower(title));
|
create index if not exists watches_title_dex on watches (lower(title));
|
||||||
create index if not exists watch_added_by_dex on watches (added_by);
|
create index if not exists watches_added_by_dex on watches (added_by);
|
||||||
create index if not exists quests_user_dex on watch_quests (user);
|
create index if not exists quests_user_dex on watch_quests (user);
|
||||||
create index if not exists quests_watch_dex on watch_quests (watch);
|
create index if not exists quests_watch_dex on watch_quests (watch);
|
||||||
create index if not exists note_user_dex on watch_notes (user);
|
create index if not exists notes_user_dex on watch_notes (user);
|
||||||
create index if not exists note_watch_dex on watch_notes (watch);
|
create index if not exists notes_watch_dex on watch_notes (watch);
|
||||||
|
|
Loading…
Reference in a new issue