This commit is contained in:
Miguel da Mota 2024-01-07 15:43:56 +01:00
parent 292ff60720
commit fa8ed2b599
19 changed files with 349 additions and 216 deletions

View file

@ -45,7 +45,7 @@ CREATE EXTENSION IF NOT EXISTS pgcrypto;
-- allowing for customization to meet specific needs.
DROP FUNCTION IF EXISTS nanoid(int, text, float);
CREATE OR REPLACE FUNCTION nanoid(
size int DEFAULT 21, -- The number of symbols in the NanoId String. Must be greater than 0.
size int DEFAULT 24, -- The number of symbols in the NanoId String. Must be greater than 0.
alphabet text DEFAULT '_-0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', -- The symbols used in the NanoId String. Must contain between 1 and 255 symbols.
additionalBytesFactor float DEFAULT 1.6 -- The additional bytes factor used for calculating the step size. Must be equal or greater then 1.
)

View file

@ -1,10 +1,14 @@
create type playlist_type as enum ('playlist', 'folder');
create table if not exists playlists
(
id varchar(24) default nanoid(24),
name varchar(255) not null,
public bool default false not null,
type playlist_type default 'playlist' not null,
creator_id varchar(24) not null,
parent_id varchar(24) references playlists (id) on delete set null,
created_at timestamp default now(),
updated_at timestamp,

View file

@ -2,5 +2,6 @@ create table if not exists playlists_tracks
(
playlist_id varchar(24) references playlists (id) on delete cascade,
track_id varchar(24) references tracks (id) on delete cascade,
added_at timestamp default now() not null,
primary key (playlist_id, track_id)
);