updatse
This commit is contained in:
parent
8a19a733d6
commit
52ef924f12
28 changed files with 577 additions and 170 deletions
|
@ -1,2 +1,2 @@
|
|||
-- This file should undo anything in `up.sql`
|
||||
DROP TABLE users;
|
||||
drop table users;
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
-- Your SQL goes here
|
||||
CREATE TABLE IF NOT EXISTS users
|
||||
create table if not exists users
|
||||
(
|
||||
id VARCHAR(24) DEFAULT nanoid(24),
|
||||
name VARCHAR(255) NOT NULL,
|
||||
email VARCHAR(255) NOT NULL,
|
||||
password TEXT NOT NULL,
|
||||
id varchar(24) default nanoid(24),
|
||||
name varchar(255) not null,
|
||||
email varchar(255) not null,
|
||||
password text not null,
|
||||
|
||||
updated_at TIMESTAMP,
|
||||
created_at TIMESTAMP DEFAULT now() NOT NULL,
|
||||
updated_at timestamp,
|
||||
created_at timestamp default now() not null,
|
||||
|
||||
PRIMARY KEY (id)
|
||||
primary key (id)
|
||||
);
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
-- This file should undo anything in `up.sql`
|
||||
DROP TABLE playlists;
|
||||
drop table playlists;
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
CREATE TABLE IF NOT EXISTS playlists
|
||||
create table if not exists playlists
|
||||
(
|
||||
id VARCHAR(24) DEFAULT nanoid(24),
|
||||
name VARCHAR(255) NOT NULL,
|
||||
id varchar(24) default nanoid(24),
|
||||
name varchar(255) not null,
|
||||
public bool default false,
|
||||
|
||||
creator_id VARCHAR(24) NOT NULL,
|
||||
creator_id varchar(24) not null,
|
||||
|
||||
created_at TIMESTAMP DEFAULT now() NOT NULL,
|
||||
updated_at TIMESTAMP,
|
||||
created_at timestamp default now() not null,
|
||||
updated_at timestamp,
|
||||
|
||||
PRIMARY KEY (id),
|
||||
FOREIGN KEY (creator_id)
|
||||
REFERENCES users (id)
|
||||
primary key (id),
|
||||
foreign key (creator_id)
|
||||
references users (id)
|
||||
on delete cascade
|
||||
);
|
||||
|
||||
CREATE INDEX ON playlists (creator_id);
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
-- This file should undo anything in `up.sql`
|
||||
DROP TABLE tracks;
|
||||
drop table tracks;
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
-- Your SQL goes here
|
||||
CREATE TABLE IF NOT EXISTS tracks
|
||||
create table if not exists tracks
|
||||
(
|
||||
id VARCHAR(24) DEFAULT nanoid(24),
|
||||
title VARCHAR(255) NOT NULL,
|
||||
duration_ms INT NOT NULL DEFAULT 0,
|
||||
id varchar(24) default nanoid(24),
|
||||
title varchar(255) not null,
|
||||
duration_ms int not null default 0,
|
||||
|
||||
created_at TIMESTAMP DEFAULT now() NOT NULL,
|
||||
updated_at TIMESTAMP,
|
||||
created_at timestamp default now() not null,
|
||||
updated_at timestamp,
|
||||
|
||||
-- music services
|
||||
spotify_id VARCHAR(21) UNIQUE,
|
||||
tidal_id VARCHAR(10) UNIQUE,
|
||||
spotify_id varchar(21) unique,
|
||||
tidal_id varchar(10) unique,
|
||||
|
||||
PRIMARY KEY (id)
|
||||
primary key (id)
|
||||
);
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
-- This file should undo anything in `up.sql`
|
||||
DROP TABLE playlists_tracks;
|
||||
drop table playlists_tracks;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
CREATE TABLE IF NOT EXISTS playlists_tracks (
|
||||
playlist_id VARCHAR(24) REFERENCES playlists(id),
|
||||
track_id VARCHAR(24) REFERENCES tracks(id),
|
||||
PRIMARY KEY (playlist_id, track_id)
|
||||
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,
|
||||
primary key (playlist_id, track_id)
|
||||
);
|
||||
|
|
2
migrations/2023-12-31-104738_artists/down.sql
Normal file
2
migrations/2023-12-31-104738_artists/down.sql
Normal file
|
@ -0,0 +1,2 @@
|
|||
-- This file should undo anything in `up.sql`
|
||||
drop table artists;
|
15
migrations/2023-12-31-104738_artists/up.sql
Normal file
15
migrations/2023-12-31-104738_artists/up.sql
Normal file
|
@ -0,0 +1,15 @@
|
|||
-- Your SQL goes here
|
||||
create table if not exists artists
|
||||
(
|
||||
id varchar(24) default nanoid(24),
|
||||
name varchar(255) NOT NULL,
|
||||
|
||||
created_at TIMESTAMP DEFAULT now() NOT NULL,
|
||||
updated_at TIMESTAMP,
|
||||
|
||||
-- music services
|
||||
spotify_id VARCHAR(21) UNIQUE,
|
||||
tidal_id VARCHAR(10) UNIQUE,
|
||||
|
||||
primary key (id)
|
||||
);
|
2
migrations/2023-12-31-104741_artists_tracks/down.sql
Normal file
2
migrations/2023-12-31-104741_artists_tracks/down.sql
Normal file
|
@ -0,0 +1,2 @@
|
|||
-- This file should undo anything in `up.sql`
|
||||
drop table artists_tracks;
|
8
migrations/2023-12-31-104741_artists_tracks/up.sql
Normal file
8
migrations/2023-12-31-104741_artists_tracks/up.sql
Normal file
|
@ -0,0 +1,8 @@
|
|||
-- Your SQL goes here
|
||||
create table if not exists artists_tracks
|
||||
(
|
||||
artist_id varchar(24) references artists (id) on delete cascade,
|
||||
track_id varchar(24) references tracks (id) on delete cascade,
|
||||
|
||||
primary key (artist_id, track_id)
|
||||
);
|
Loading…
Add table
Add a link
Reference in a new issue