000003_remove_users.down.sql
639 bytes
1ALTER TABLE videos DROP COLUMN IF EXISTS watch_timestamp;
2
3CREATE TABLE IF NOT EXISTS users (
4 username text NOT NULL PRIMARY KEY
5 , password text NOT NULL
6);
7
8CREATE TABLE IF NOT EXISTS user_videos (
9 username text NOT NULL REFERENCES users(username)
10 , video_id text NOT NULL REFERENCES videos(id)
11 , watch_timestamp timestamp with time zone
12 , CONSTRAINT user_videos_pkey PRIMARY KEY (username, video_id)
13);
14
15CREATE TABLE IF NOT EXISTS user_subscriptions (
16 username text NOT NULL REFERENCES users(username)
17 , channel_id text NOT NULL REFERENCES channels(id)
18 , CONSTRAINT user_subscriptions_pkey PRIMARY KEY (channel_id, username)
19);