refactor: decide to not create separate table for subscriptions
This commit is contained in:
parent
3e79bec974
commit
064365fb4f
7 changed files with 119 additions and 129 deletions
|
|
@ -29,41 +29,32 @@ create table devices (
|
|||
unique (user_id, device_id)
|
||||
);
|
||||
|
||||
create table subscriptions (
|
||||
id integer primary key not null,
|
||||
|
||||
url text unique not null
|
||||
);
|
||||
|
||||
create table device_subscriptions (
|
||||
id integer primary key not null,
|
||||
|
||||
device_id bigint not null
|
||||
references devices (id)
|
||||
on delete cascade,
|
||||
subscription_id bigint not null
|
||||
references subscriptions (id)
|
||||
on delete cascade
|
||||
|
||||
podcast_url text not null,
|
||||
|
||||
time_changed bigint not null default 0,
|
||||
deleted boolean not null default false,
|
||||
|
||||
unique (device_id, subscription_id)
|
||||
unique (device_id, podcast_url)
|
||||
);
|
||||
|
||||
create table episode_actions (
|
||||
id integer primary key not null,
|
||||
|
||||
subscription_id bigint not null
|
||||
references subscriptions (id)
|
||||
on delete set null,
|
||||
|
||||
-- Can be null, as the device is not always provided
|
||||
device_id bigint
|
||||
references devices (id)
|
||||
on delete set null,
|
||||
|
||||
podcast_url text not null,
|
||||
episode_url text not null,
|
||||
|
||||
timestamp bigint,
|
||||
action text not null,
|
||||
started integer,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue