Repository navigation
Expand file tree
/
Copy pathdatabase.sql
More file actions
78 lines (73 loc) · 3.25 KB
/
Copy pathdatabase.sql
File metadata and controls
78 lines (73 loc) · 3.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
-- Tokens Table
create table public."Tokens" (
"Id" bigint generated by default as identity not null,
"RefreshToken" text not null default ''::text,
"ExpiresAt" timestamp with time zone not null,
"CreatedAt" timestamp with time zone not null default now(),
constraint Tokens_pkey primary key ("Id")
) TABLESPACE pg_default;
-- SpotifyState Table
create table public."SpotifyStates" (
"Id" bigint generated by default as identity not null,
"State" text not null default ''::text,
"CreatedAt" timestamp with time zone not null default now(),
constraint SpotifyState_pkey primary key ("Id")
) TABLESPACE pg_default;
-- Users Table
create table public."Users" (
"Id" bigint generated by default as identity not null,
"Username" character varying not null default ''::character varying,
"Email" character varying not null default ''::character varying,
"CreatedAt" timestamp with time zone not null default (now() AT TIME ZONE 'utc'::text),
"PasswordHash" text not null default ''::text,
"RefreshToken" text null,
"SpotifyId" text null,
"Token" text null default ''::text,
"TokenExpiresAt" timestamp with time zone null default now(),
constraint Users_pkey primary key ("Id"),
constraint Users_email_key unique ("Email")
) TABLESPACE pg_default;
-- Rooms Table
create table public."Rooms" (
"Id" bigint generated by default as identity not null,
"UserId" bigint not null,
"Name" character varying not null default ''::character varying,
"Slug" character varying not null default ''::character varying,
"PasswordHash" text not null default ''::text,
"IsActive" boolean not null default true,
"SpotifyPlaylistId" text null default ''::text,
"CreatedAt" timestamp with time zone not null default now(),
"Market" text not null default ''::text,
"LastUpdate" timestamp with time zone not null default now(),
constraint Rooms_pkey primary key ("Id"),
constraint Rooms_Slug_key unique ("Slug"),
constraint Rooms_UserId_fkey foreign KEY ("UserId") references "Users" ("Id") on delete CASCADE
) TABLESPACE pg_default;
-- Songs Table
create table public."Songs" (
"Id" bigint generated by default as identity not null,
"RoomId" bigint not null,
"SongId" text not null default ''::text,
"Title" text not null default ''::text,
"Artist" text not null default ''::text,
"Album" text not null default ''::text,
"AlbumArtUrl" text not null default ''::text,
"DurationMs" bigint not null,
"AddedAt" timestamp with time zone not null default now(),
"Status" integer not null default 0,
"Uri" text not null default ''::text,
"Explicit" boolean not null default false,
constraint Songs_pkey primary key ("Id"),
constraint Songs_RoomId_fkey foreign KEY ("RoomId") references "Rooms" ("Id") on delete CASCADE
) TABLESPACE pg_default;
-- RoomCodes Table
create table public."RoomCodes" (
"Id" bigint generated by default as identity not null,
"Code" text not null default ''::text,
"RoomId" bigint not null,
"CreatedAt" timestamp with time zone null default now(),
"ExpiresAt" timestamp with time zone null default now(),
constraint RoomCodes_pkey primary key ("Id"),
constraint RoomCodes_Code_key unique ("Code"),
constraint RoomCodes_RoomId_fkey foreign KEY ("RoomId") references "Rooms" ("Id") on delete CASCADE
) TABLESPACE pg_default;