Skip to content

Commit

Permalink
Add playlists table.
Browse files Browse the repository at this point in the history
  • Loading branch information
FireMasterK committed Aug 14, 2023
1 parent b3c0635 commit dc7801b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/main/resources/changelog/version/0-1-init-crdb.sql
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,9 @@ CREATE TABLE IF NOT EXISTS users_subscribed (
CREATE INDEX IF NOT EXISTS pubsub_subbed_at_idx ON pubsub (subbed_at ASC) USING HASH;

--rollback DROP INDEX IF EXISTS pubsub_subbed_at_idx;

CREATE INDEX IF NOT EXISTS playlists_playlist_id_idx ON playlists (playlist_id ASC) STORING (name, short_description, thumbnail, owner);
CREATE INDEX IF NOT EXISTS playlists_owner_idx ON playlists (owner ASC) STORING (name, short_description, thumbnail, playlist_id);

--rollback DROP INDEX IF EXISTS playlists_playlist_id_idx;
--rollback DROP INDEX IF EXISTS playlists_owner_idx;
6 changes: 6 additions & 0 deletions src/main/resources/changelog/version/0-1-init-pg.sql
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,9 @@ CREATE INDEX IF NOT EXISTS users_subscribed_channel_idx ON users_subscribed (cha
CREATE INDEX IF NOT EXISTS pubsub_subbed_at_idx ON pubsub (subbed_at ASC);

--rollback DROP INDEX IF EXISTS pubsub_subbed_at_idx;

CREATE INDEX IF NOT EXISTS playlists_playlist_id_idx ON playlists (playlist_id ASC);
CREATE INDEX IF NOT EXISTS playlists_owner_idx ON playlists (owner ASC);

--rollback DROP INDEX IF EXISTS playlists_playlist_id_idx;
--rollback DROP INDEX IF EXISTS playlists_owner_idx;
13 changes: 13 additions & 0 deletions src/main/resources/changelog/version/0-1-init.sql
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,16 @@ CREATE TABLE IF NOT EXISTS pubsub (
CREATE INDEX IF NOT EXISTS pubsub_id_idx ON pubsub (id ASC);

--rollback DROP TABLE IF EXISTS pubsub;

CREATE TABLE IF NOT EXISTS playlists (
id SERIAL NOT NULL,
name VARCHAR(200) NULL,
playlist_id UUID NOT NULL UNIQUE DEFAULT gen_random_uuid(),
short_description VARCHAR(100) NULL,
thumbnail VARCHAR(300) NULL,
owner INT8 NOT NULL,
CONSTRAINT playlists_pkey PRIMARY KEY (id),
CONSTRAINT fk_playlists_owner FOREIGN KEY (owner) REFERENCES users(id)
);

--rollback DROP TABLE IF EXISTS playlists;

0 comments on commit dc7801b

Please sign in to comment.