forked from
rocksky.app/rocksky
A decentralized music tracking and discovery platform built on AT Protocol 馃幍
1CREATE SCHEMA xata_private;
2
3--
4-- Name: xid; Type: DOMAIN; Schema: xata_private; Owner: -
5--
6
7CREATE DOMAIN xata_private.xid AS character(20)
8 CONSTRAINT xid_check CHECK ((VALUE ~ '^[a-v0-9]{20}$'::text));
9
10CREATE FUNCTION xata_private.xid(_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP) RETURNS xata_private.xid
11 LANGUAGE plpgsql SECURITY DEFINER
12 AS $$
13DECLARE
14 _t INT;
15 _m INT;
16 _p INT;
17 _c INT;
18BEGIN
19 _t := floor(EXTRACT(epoch FROM _at));
20 _m := xata_private._xid_machine_id();
21 _p := pg_backend_pid();
22 _c := nextval('xata_private.xid_serial')::INT;
23
24 return xata_private.xid_encode(ARRAY [
25 (_t >> 24) & 255, (_t >> 16) & 255, (_t >> 8) & 255 , _t & 255,
26 (_m >> 16) & 255, (_m >> 8) & 255 , _m & 255,
27 (_p >> 8) & 255, _p & 255,
28 (_c >> 16) & 255, (_c >> 8) & 255 , _c & 255
29 ]);
30END;
31$$;
32
33CREATE FUNCTION xata_private._xid_machine_id() RETURNS integer
34 LANGUAGE plpgsql IMMUTABLE
35 AS $$
36BEGIN
37 RETURN (SELECT system_identifier & 16777215 FROM pg_control_system());
38END;
39$$;
40
41CREATE FUNCTION xata_private.xid_encode(_id integer[]) RETURNS xata_private.xid
42 LANGUAGE plpgsql
43 AS $$
44DECLARE
45 _encoding CHAR(1)[] = '{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v}';
46BEGIN
47 RETURN _encoding[1 + (_id[1] >> 3)]
48 || _encoding[1 + ((_id[2] >> 6) & 31 | (_id[1] << 2) & 31)]
49 || _encoding[1 + ((_id[2] >> 1) & 31)]
50 || _encoding[1 + ((_id[3] >> 4) & 31 | (_id[2] << 4) & 31)]
51 || _encoding[1 + (_id[4] >> 7 | (_id[3] << 1) & 31)]
52 || _encoding[1 + ((_id[4] >> 2) & 31)]
53 || _encoding[1 + (_id[5] >> 5 | (_id[4] << 3) & 31)]
54 || _encoding[1 + (_id[5] & 31)]
55 || _encoding[1 + (_id[6] >> 3)]
56 || _encoding[1 + ((_id[7] >> 6) & 31 | (_id[6] << 2) & 31)]
57 || _encoding[1 + ((_id[7] >> 1) & 31)]
58 || _encoding[1 + ((_id[8] >> 4) & 31 | (_id[7] << 4) & 31)]
59 || _encoding[1 + (_id[9] >> 7 | (_id[8] << 1) & 31)]
60 || _encoding[1 + ((_id[9] >> 2) & 31)]
61 || _encoding[1 + ((_id[10] >> 5) | (_id[9] << 3) & 31)]
62 || _encoding[1 + (_id[10] & 31)]
63 || _encoding[1 + (_id[11] >> 3)]
64 || _encoding[1 + ((_id[12] >> 6) & 31 | (_id[11] << 2) & 31)]
65 || _encoding[1 + ((_id[12] >> 1) & 31)]
66 || _encoding[1 + ((_id[12] << 4) & 31)];
67END;
68$$;
69
70CREATE SEQUENCE xata_private.xid_serial
71 START WITH 0
72 INCREMENT BY 1
73 MINVALUE 0
74 MAXVALUE 16777215
75 CACHE 1
76 CYCLE;
77
78CREATE OR REPLACE FUNCTION xata_id()
79RETURNS text AS $$
80SELECT 'rec_' || xata_private.xid();
81$$ LANGUAGE sql IMMUTABLE;
82
83CREATE TABLE "album_tracks" (
84 "xata_id" text PRIMARY KEY DEFAULT xata_id() NOT NULL,
85 "album_id" text NOT NULL,
86 "track_id" text NOT NULL,
87 "xata_createdat" timestamp DEFAULT now() NOT NULL,
88 "xata_updatedat" timestamp DEFAULT now() NOT NULL,
89 "xata_version" integer
90);
91--> statement-breakpoint
92CREATE TABLE "albums" (
93 "xata_id" text PRIMARY KEY DEFAULT xata_id() NOT NULL,
94 "title" text NOT NULL,
95 "artist" text NOT NULL,
96 "release_date" text,
97 "year" integer,
98 "album_art" text,
99 "uri" text,
100 "artist_uri" text,
101 "apple_music_link" text,
102 "spotify_link" text,
103 "tidal_link" text,
104 "youtube_link" text,
105 "sha256" text NOT NULL,
106 "xata_createdat" timestamp DEFAULT now() NOT NULL,
107 "xata_updatedat" timestamp DEFAULT now() NOT NULL,
108 "xata_version" integer,
109 CONSTRAINT "albums_uri_unique" UNIQUE("uri"),
110 CONSTRAINT "albums_apple_music_link_unique" UNIQUE("apple_music_link"),
111 CONSTRAINT "albums_spotify_link_unique" UNIQUE("spotify_link"),
112 CONSTRAINT "albums_tidal_link_unique" UNIQUE("tidal_link"),
113 CONSTRAINT "albums_youtube_link_unique" UNIQUE("youtube_link"),
114 CONSTRAINT "albums_sha256_unique" UNIQUE("sha256")
115);
116--> statement-breakpoint
117CREATE TABLE "api_keys" (
118 "xata_id" text PRIMARY KEY DEFAULT xata_id() NOT NULL,
119 "name" text NOT NULL,
120 "api_key" text NOT NULL,
121 "shared_secret" text NOT NULL,
122 "description" text,
123 "enabled" boolean DEFAULT true NOT NULL,
124 "user_id" text NOT NULL,
125 "xata_createdat" timestamp DEFAULT now() NOT NULL,
126 "xata_updatedat" timestamp DEFAULT now() NOT NULL
127);
128--> statement-breakpoint
129CREATE TABLE "artist_albums" (
130 "xata_id" text PRIMARY KEY DEFAULT xata_id() NOT NULL,
131 "artist_id" text NOT NULL,
132 "album_id" text NOT NULL,
133 "xata_createdat" timestamp DEFAULT now() NOT NULL,
134 "xata_updatedat" timestamp DEFAULT now() NOT NULL,
135 "xata_version" integer
136);
137--> statement-breakpoint
138CREATE TABLE "artist_tracks" (
139 "xata_id" text PRIMARY KEY DEFAULT xata_id() NOT NULL,
140 "artist_id" text NOT NULL,
141 "track_id" text NOT NULL,
142 "xata_createdat" timestamp DEFAULT now() NOT NULL,
143 "xata_updatedat" timestamp DEFAULT now() NOT NULL,
144 "xata_version" integer
145);
146--> statement-breakpoint
147CREATE TABLE "artists" (
148 "xata_id" text PRIMARY KEY DEFAULT xata_id() NOT NULL,
149 "name" text NOT NULL,
150 "biography" text,
151 "born" timestamp,
152 "born_in" text,
153 "died" timestamp,
154 "picture" text,
155 "sha256" text NOT NULL,
156 "uri" text,
157 "apple_music_link" text,
158 "spotify_link" text,
159 "tidal_link" text,
160 "youtube_link" text,
161 "genres" text[],
162 "xata_createdat" timestamp DEFAULT now() NOT NULL,
163 "xata_updatedat" timestamp DEFAULT now() NOT NULL,
164 "xata_version" integer,
165 CONSTRAINT "artists_sha256_unique" UNIQUE("sha256"),
166 CONSTRAINT "artists_uri_unique" UNIQUE("uri")
167);
168--> statement-breakpoint
169CREATE TABLE "dropbox_accounts" (
170 "xata_id" text PRIMARY KEY DEFAULT xata_id() NOT NULL,
171 "email" text NOT NULL,
172 "is_beta_user" boolean DEFAULT false NOT NULL,
173 "user_id" text NOT NULL,
174 "xata_version" text,
175 "xata_createdat" timestamp DEFAULT now() NOT NULL,
176 "xata_updatedat" timestamp DEFAULT now() NOT NULL,
177 CONSTRAINT "dropbox_accounts_email_unique" UNIQUE("email")
178);
179--> statement-breakpoint
180CREATE TABLE "dropbox_directories" (
181 "xata_id" text PRIMARY KEY DEFAULT xata_id() NOT NULL,
182 "name" text NOT NULL,
183 "path" text NOT NULL,
184 "parent_id" text,
185 "dropbox_id" text NOT NULL,
186 "file_id" text NOT NULL,
187 "xata_version" text,
188 "xata_createdat" timestamp DEFAULT now() NOT NULL,
189 "xata_updatedat" timestamp DEFAULT now() NOT NULL,
190 CONSTRAINT "dropbox_directories_file_id_unique" UNIQUE("file_id")
191);
192--> statement-breakpoint
193CREATE TABLE "dropbox_paths" (
194 "xata_id" text PRIMARY KEY DEFAULT xata_id() NOT NULL,
195 "path" text NOT NULL,
196 "name" text NOT NULL,
197 "dropbox_id" text NOT NULL,
198 "track_id" text NOT NULL,
199 "directory_id" text,
200 "file_id" text NOT NULL,
201 "xata_version" text,
202 "xata_createdat" timestamp DEFAULT now() NOT NULL,
203 "xata_updatedat" timestamp DEFAULT now() NOT NULL,
204 CONSTRAINT "dropbox_paths_file_id_unique" UNIQUE("file_id")
205);
206--> statement-breakpoint
207CREATE TABLE "dropbox_tokens" (
208 "xata_id" text PRIMARY KEY DEFAULT xata_id() NOT NULL,
209 "refresh_token" text NOT NULL,
210 "xata_createdat" timestamp DEFAULT now() NOT NULL,
211 "xata_updatedat" timestamp DEFAULT now() NOT NULL
212);
213--> statement-breakpoint
214CREATE TABLE "dropbox" (
215 "xata_id" text PRIMARY KEY DEFAULT xata_id() NOT NULL,
216 "user_id" text NOT NULL,
217 "dropbox_token_id" text NOT NULL,
218 "xata_version" text,
219 "xata_createdat" timestamp DEFAULT now() NOT NULL,
220 "xata_updatedat" timestamp DEFAULT now() NOT NULL
221);
222--> statement-breakpoint
223CREATE TABLE "feeds" (
224 "xata_id" text PRIMARY KEY DEFAULT xata_id() NOT NULL,
225 "display_name" text NOT NULL,
226 "description" text,
227 "did" text NOT NULL,
228 "uri" text NOT NULL,
229 "avatar" text,
230 "user_id" text NOT NULL,
231 "xata_version" integer,
232 "xata_createdat" timestamp DEFAULT now() NOT NULL,
233 "xata_updatedat" timestamp DEFAULT now() NOT NULL,
234 CONSTRAINT "feeds_did_unique" UNIQUE("did"),
235 CONSTRAINT "feeds_uri_unique" UNIQUE("uri")
236);
237--> statement-breakpoint
238CREATE TABLE "google_drive_accounts" (
239 "xata_id" text PRIMARY KEY DEFAULT xata_id() NOT NULL,
240 "email" text NOT NULL,
241 "is_beta_user" boolean DEFAULT false NOT NULL,
242 "user_id" text NOT NULL,
243 "xata_version" text,
244 "xata_createdat" timestamp DEFAULT now() NOT NULL,
245 "xata_updatedat" timestamp DEFAULT now() NOT NULL,
246 CONSTRAINT "google_drive_accounts_email_unique" UNIQUE("email")
247);
248--> statement-breakpoint
249CREATE TABLE "google_drive_directories" (
250 "xata_id" text PRIMARY KEY DEFAULT xata_id() NOT NULL,
251 "name" text NOT NULL,
252 "path" text NOT NULL,
253 "parent_id" text,
254 "google_drive_id" text NOT NULL,
255 "file_id" text NOT NULL,
256 "xata_version" text,
257 "xata_createdat" timestamp DEFAULT now() NOT NULL,
258 "xata_updatedat" timestamp DEFAULT now() NOT NULL,
259 CONSTRAINT "google_drive_directories_file_id_unique" UNIQUE("file_id")
260);
261--> statement-breakpoint
262CREATE TABLE "google_drive_paths" (
263 "xata_id" text PRIMARY KEY DEFAULT xata_id() NOT NULL,
264 "google_drive_id" text NOT NULL,
265 "track_id" text NOT NULL,
266 "name" text NOT NULL,
267 "directory_id" text,
268 "file_id" text NOT NULL,
269 "xata_version" text,
270 "xata_createdat" timestamp DEFAULT now() NOT NULL,
271 "xata_updatedat" timestamp DEFAULT now() NOT NULL,
272 CONSTRAINT "google_drive_paths_file_id_unique" UNIQUE("file_id")
273);
274--> statement-breakpoint
275CREATE TABLE "google_drive_tokens" (
276 "xata_id" text PRIMARY KEY DEFAULT xata_id() NOT NULL,
277 "refresh_token" text NOT NULL,
278 "xata_createdat" timestamp DEFAULT now() NOT NULL,
279 "xata_updatedat" timestamp DEFAULT now() NOT NULL
280);
281--> statement-breakpoint
282CREATE TABLE "google_drive" (
283 "xata_id" text PRIMARY KEY DEFAULT xata_id() NOT NULL,
284 "google_drive_token_id" text NOT NULL,
285 "user_id" text NOT NULL,
286 "xata_version" text,
287 "xata_createdat" timestamp DEFAULT now() NOT NULL,
288 "xata_updatedat" timestamp DEFAULT now() NOT NULL
289);
290--> statement-breakpoint
291CREATE TABLE "loved_tracks" (
292 "xata_id" text PRIMARY KEY DEFAULT xata_id() NOT NULL,
293 "user_id" text NOT NULL,
294 "track_id" text NOT NULL,
295 "uri" text,
296 "xata_createdat" timestamp DEFAULT now() NOT NULL,
297 CONSTRAINT "loved_tracks_uri_unique" UNIQUE("uri")
298);
299--> statement-breakpoint
300CREATE TABLE "playlist_tracks" (
301 "xata_id" text PRIMARY KEY DEFAULT xata_id() NOT NULL,
302 "playlist_id" text NOT NULL,
303 "track_id" text NOT NULL,
304 "xata_createdat" timestamp DEFAULT now() NOT NULL
305);
306--> statement-breakpoint
307CREATE TABLE "playlists" (
308 "xata_id" text PRIMARY KEY DEFAULT xata_id() NOT NULL,
309 "name" text NOT NULL,
310 "picture" text,
311 "description" text,
312 "uri" text,
313 "spotify_link" text,
314 "tidal_link" text,
315 "apple_music_link" text,
316 "created_by" text NOT NULL,
317 "xata_createdat" timestamp DEFAULT now() NOT NULL,
318 "xata_updatedat" timestamp DEFAULT now() NOT NULL,
319 CONSTRAINT "playlists_uri_unique" UNIQUE("uri")
320);
321--> statement-breakpoint
322CREATE TABLE "profile_shouts" (
323 "xata_id" text PRIMARY KEY DEFAULT xata_id() NOT NULL,
324 "user_id" text NOT NULL,
325 "shout_id" text NOT NULL,
326 "xata_createdat" timestamp DEFAULT now() NOT NULL
327);
328--> statement-breakpoint
329CREATE TABLE "queue_tracks" (
330 "xata_id" text PRIMARY KEY DEFAULT xata_id() NOT NULL,
331 "user_id" text NOT NULL,
332 "track_id" text NOT NULL,
333 "position" integer NOT NULL,
334 "file_uri" text NOT NULL,
335 "xata_version" integer DEFAULT 0 NOT NULL,
336 "xata_createdat" timestamp DEFAULT now() NOT NULL,
337 "xata_updatedat" timestamp DEFAULT now() NOT NULL
338);
339--> statement-breakpoint
340CREATE TABLE "scrobbles" (
341 "xata_id" text PRIMARY KEY DEFAULT xata_id() NOT NULL,
342 "user_id" text,
343 "track_id" text,
344 "album_id" text,
345 "artist_id" text,
346 "uri" text,
347 "xata_createdat" timestamp DEFAULT now() NOT NULL,
348 "xata_updatedat" timestamp DEFAULT now() NOT NULL,
349 "xata_version" integer,
350 "timestamp" timestamp DEFAULT now() NOT NULL,
351 CONSTRAINT "scrobbles_uri_unique" UNIQUE("uri")
352);
353--> statement-breakpoint
354CREATE TABLE "shout_likes" (
355 "xata_id" text PRIMARY KEY DEFAULT xata_id() NOT NULL,
356 "user_id" text NOT NULL,
357 "shout_id" text NOT NULL,
358 "xata_createdat" timestamp DEFAULT now() NOT NULL,
359 "uri" text NOT NULL,
360 CONSTRAINT "shout_likes_uri_unique" UNIQUE("uri")
361);
362--> statement-breakpoint
363CREATE TABLE "shout_reports" (
364 "xata_id" text PRIMARY KEY DEFAULT xata_id() NOT NULL,
365 "user_id" text NOT NULL,
366 "shout_id" text NOT NULL,
367 "xata_createdat" timestamp DEFAULT now() NOT NULL
368);
369--> statement-breakpoint
370CREATE TABLE "shouts" (
371 "xata_id" text PRIMARY KEY DEFAULT xata_id() NOT NULL,
372 "content" text NOT NULL,
373 "track_id" text,
374 "artist_id" text,
375 "album_id" text,
376 "scrobble_id" text,
377 "uri" text NOT NULL,
378 "author_id" text NOT NULL,
379 "parent_id" text,
380 "xata_createdat" timestamp DEFAULT now() NOT NULL,
381 "xata_updatedat" timestamp DEFAULT now() NOT NULL,
382 CONSTRAINT "shouts_uri_unique" UNIQUE("uri")
383);
384--> statement-breakpoint
385CREATE TABLE "spotify_accounts" (
386 "xata_id" text PRIMARY KEY DEFAULT xata_id() NOT NULL,
387 "xata_version" integer,
388 "email" text NOT NULL,
389 "user_id" text NOT NULL,
390 "is_beta_user" boolean DEFAULT false NOT NULL,
391 "spotify_app_id" text,
392 "xata_createdat" timestamp DEFAULT now() NOT NULL,
393 "xata_updatedat" timestamp DEFAULT now() NOT NULL
394);
395--> statement-breakpoint
396CREATE TABLE "spotify_apps" (
397 "xata_id" text PRIMARY KEY DEFAULT xata_id() NOT NULL,
398 "xata_version" integer,
399 "spotify_app_id" text NOT NULL,
400 "spotify_secret" text NOT NULL,
401 "xata_createdat" timestamp DEFAULT now() NOT NULL,
402 "xata_updatedat" timestamp DEFAULT now() NOT NULL,
403 CONSTRAINT "spotify_apps_spotify_app_id_unique" UNIQUE("spotify_app_id")
404);
405--> statement-breakpoint
406CREATE TABLE "spotify_tokens" (
407 "xata_id" text PRIMARY KEY DEFAULT xata_id() NOT NULL,
408 "xata_version" integer,
409 "access_token" text NOT NULL,
410 "refresh_token" text NOT NULL,
411 "user_id" text NOT NULL,
412 "spotify_app_id" text NOT NULL,
413 "xata_createdat" timestamp DEFAULT now() NOT NULL,
414 "xata_updatedat" timestamp DEFAULT now() NOT NULL
415);
416--> statement-breakpoint
417CREATE TABLE "tracks" (
418 "xata_id" text PRIMARY KEY DEFAULT xata_id() NOT NULL,
419 "title" text NOT NULL,
420 "artist" text NOT NULL,
421 "album_artist" text NOT NULL,
422 "album_art" text,
423 "album" text NOT NULL,
424 "track_number" integer,
425 "duration" integer NOT NULL,
426 "mb_id" text,
427 "youtube_link" text,
428 "spotify_link" text,
429 "apple_music_link" text,
430 "tidal_link" text,
431 "sha256" text NOT NULL,
432 "disc_number" integer,
433 "lyrics" text,
434 "composer" text,
435 "genre" text,
436 "label" text,
437 "copyright_message" text,
438 "uri" text,
439 "album_uri" text,
440 "artist_uri" text,
441 "xata_createdat" timestamp DEFAULT now() NOT NULL,
442 "xata_updatedat" timestamp DEFAULT now() NOT NULL,
443 "xata_version" integer,
444 CONSTRAINT "tracks_mb_id_unique" UNIQUE("mb_id"),
445 CONSTRAINT "tracks_youtube_link_unique" UNIQUE("youtube_link"),
446 CONSTRAINT "tracks_spotify_link_unique" UNIQUE("spotify_link"),
447 CONSTRAINT "tracks_apple_music_link_unique" UNIQUE("apple_music_link"),
448 CONSTRAINT "tracks_tidal_link_unique" UNIQUE("tidal_link"),
449 CONSTRAINT "tracks_sha256_unique" UNIQUE("sha256"),
450 CONSTRAINT "tracks_uri_unique" UNIQUE("uri")
451);
452--> statement-breakpoint
453CREATE TABLE "user_albums" (
454 "xata_id" text PRIMARY KEY DEFAULT xata_id() NOT NULL,
455 "user_id" text NOT NULL,
456 "album_id" text NOT NULL,
457 "xata_createdat" timestamp DEFAULT now() NOT NULL,
458 "xata_updatedat" timestamp DEFAULT now() NOT NULL,
459 "xata_version" integer,
460 "scrobbles" integer,
461 "uri" text NOT NULL,
462 CONSTRAINT "user_albums_uri_unique" UNIQUE("uri")
463);
464--> statement-breakpoint
465CREATE TABLE "user_artists" (
466 "xata_id" text PRIMARY KEY DEFAULT xata_id() NOT NULL,
467 "user_id" text NOT NULL,
468 "artist_id" text NOT NULL,
469 "xata_createdat" timestamp DEFAULT now() NOT NULL,
470 "xata_updatedat" timestamp DEFAULT now() NOT NULL,
471 "xata_version" integer,
472 "scrobbles" integer,
473 "uri" text NOT NULL,
474 CONSTRAINT "user_artists_uri_unique" UNIQUE("uri")
475);
476--> statement-breakpoint
477CREATE TABLE "user_playlists" (
478 "xata_id" text PRIMARY KEY DEFAULT xata_id() NOT NULL,
479 "user_id" text NOT NULL,
480 "playlist_id" text NOT NULL,
481 "xata_createdat" timestamp DEFAULT now() NOT NULL,
482 "uri" text,
483 CONSTRAINT "user_playlists_uri_unique" UNIQUE("uri")
484);
485--> statement-breakpoint
486CREATE TABLE "user_tracks" (
487 "xata_id" text PRIMARY KEY DEFAULT xata_id() NOT NULL,
488 "user_id" text NOT NULL,
489 "track_id" text NOT NULL,
490 "xata_createdat" timestamp DEFAULT now() NOT NULL,
491 "xata_updatedat" timestamp DEFAULT now() NOT NULL,
492 "xata_version" integer,
493 "uri" text NOT NULL,
494 "scrobbles" integer,
495 CONSTRAINT "user_tracks_uri_unique" UNIQUE("uri")
496);
497--> statement-breakpoint
498CREATE TABLE "users" (
499 "xata_id" text PRIMARY KEY DEFAULT xata_id() NOT NULL,
500 "did" text NOT NULL,
501 "display_name" text,
502 "handle" text NOT NULL,
503 "avatar" text NOT NULL,
504 "xata_createdat" timestamp DEFAULT now() NOT NULL,
505 "xata_updatedat" timestamp DEFAULT now() NOT NULL,
506 "xata_version" integer,
507 CONSTRAINT "users_did_unique" UNIQUE("did"),
508 CONSTRAINT "users_handle_unique" UNIQUE("handle")
509);
510--> statement-breakpoint
511CREATE TABLE "webscrobblers" (
512 "xata_id" text PRIMARY KEY DEFAULT xata_id() NOT NULL,
513 "name" text NOT NULL,
514 "uuid" text NOT NULL,
515 "description" text,
516 "enabled" boolean DEFAULT true NOT NULL,
517 "user_id" text NOT NULL,
518 "xata_createdat" timestamp DEFAULT now() NOT NULL,
519 "xata_updatedat" timestamp DEFAULT now() NOT NULL
520);
521--> statement-breakpoint
522ALTER TABLE "album_tracks" ADD CONSTRAINT "album_tracks_album_id_albums_xata_id_fk" FOREIGN KEY ("album_id") REFERENCES "public"."albums"("xata_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
523ALTER TABLE "album_tracks" ADD CONSTRAINT "album_tracks_track_id_tracks_xata_id_fk" FOREIGN KEY ("track_id") REFERENCES "public"."tracks"("xata_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
524ALTER TABLE "api_keys" ADD CONSTRAINT "api_keys_user_id_users_xata_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("xata_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
525ALTER TABLE "artist_albums" ADD CONSTRAINT "artist_albums_artist_id_artists_xata_id_fk" FOREIGN KEY ("artist_id") REFERENCES "public"."artists"("xata_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
526ALTER TABLE "artist_albums" ADD CONSTRAINT "artist_albums_album_id_albums_xata_id_fk" FOREIGN KEY ("album_id") REFERENCES "public"."albums"("xata_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
527ALTER TABLE "artist_tracks" ADD CONSTRAINT "artist_tracks_artist_id_artists_xata_id_fk" FOREIGN KEY ("artist_id") REFERENCES "public"."artists"("xata_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
528ALTER TABLE "artist_tracks" ADD CONSTRAINT "artist_tracks_track_id_tracks_xata_id_fk" FOREIGN KEY ("track_id") REFERENCES "public"."tracks"("xata_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
529ALTER TABLE "dropbox_accounts" ADD CONSTRAINT "dropbox_accounts_user_id_users_xata_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("xata_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
530ALTER TABLE "dropbox_directories" ADD CONSTRAINT "dropbox_directories_parent_id_dropbox_directories_xata_id_fk" FOREIGN KEY ("parent_id") REFERENCES "public"."dropbox_directories"("xata_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
531ALTER TABLE "dropbox_paths" ADD CONSTRAINT "dropbox_paths_directory_id_dropbox_directories_xata_id_fk" FOREIGN KEY ("directory_id") REFERENCES "public"."dropbox_directories"("xata_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
532ALTER TABLE "dropbox" ADD CONSTRAINT "dropbox_user_id_users_xata_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("xata_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
533ALTER TABLE "dropbox" ADD CONSTRAINT "dropbox_dropbox_token_id_dropbox_tokens_xata_id_fk" FOREIGN KEY ("dropbox_token_id") REFERENCES "public"."dropbox_tokens"("xata_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
534ALTER TABLE "feeds" ADD CONSTRAINT "feeds_user_id_users_xata_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("xata_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
535ALTER TABLE "google_drive_accounts" ADD CONSTRAINT "google_drive_accounts_user_id_users_xata_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("xata_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
536ALTER TABLE "google_drive_directories" ADD CONSTRAINT "google_drive_directories_parent_id_google_drive_directories_xata_id_fk" FOREIGN KEY ("parent_id") REFERENCES "public"."google_drive_directories"("xata_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
537ALTER TABLE "google_drive_paths" ADD CONSTRAINT "google_drive_paths_directory_id_google_drive_directories_xata_id_fk" FOREIGN KEY ("directory_id") REFERENCES "public"."google_drive_directories"("xata_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
538ALTER TABLE "google_drive" ADD CONSTRAINT "google_drive_google_drive_token_id_google_drive_tokens_xata_id_fk" FOREIGN KEY ("google_drive_token_id") REFERENCES "public"."google_drive_tokens"("xata_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
539ALTER TABLE "google_drive" ADD CONSTRAINT "google_drive_user_id_users_xata_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("xata_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
540ALTER TABLE "loved_tracks" ADD CONSTRAINT "loved_tracks_user_id_users_xata_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("xata_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
541ALTER TABLE "loved_tracks" ADD CONSTRAINT "loved_tracks_track_id_tracks_xata_id_fk" FOREIGN KEY ("track_id") REFERENCES "public"."tracks"("xata_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
542ALTER TABLE "playlist_tracks" ADD CONSTRAINT "playlist_tracks_playlist_id_playlists_xata_id_fk" FOREIGN KEY ("playlist_id") REFERENCES "public"."playlists"("xata_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
543ALTER TABLE "playlist_tracks" ADD CONSTRAINT "playlist_tracks_track_id_tracks_xata_id_fk" FOREIGN KEY ("track_id") REFERENCES "public"."tracks"("xata_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
544ALTER TABLE "playlists" ADD CONSTRAINT "playlists_created_by_users_xata_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."users"("xata_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
545ALTER TABLE "profile_shouts" ADD CONSTRAINT "profile_shouts_user_id_users_xata_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("xata_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
546ALTER TABLE "profile_shouts" ADD CONSTRAINT "profile_shouts_shout_id_shouts_xata_id_fk" FOREIGN KEY ("shout_id") REFERENCES "public"."shouts"("xata_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
547ALTER TABLE "queue_tracks" ADD CONSTRAINT "queue_tracks_user_id_users_xata_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("xata_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
548ALTER TABLE "queue_tracks" ADD CONSTRAINT "queue_tracks_track_id_tracks_xata_id_fk" FOREIGN KEY ("track_id") REFERENCES "public"."tracks"("xata_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
549ALTER TABLE "scrobbles" ADD CONSTRAINT "scrobbles_user_id_users_xata_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("xata_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
550ALTER TABLE "scrobbles" ADD CONSTRAINT "scrobbles_track_id_tracks_xata_id_fk" FOREIGN KEY ("track_id") REFERENCES "public"."tracks"("xata_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
551ALTER TABLE "scrobbles" ADD CONSTRAINT "scrobbles_album_id_albums_xata_id_fk" FOREIGN KEY ("album_id") REFERENCES "public"."albums"("xata_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
552ALTER TABLE "scrobbles" ADD CONSTRAINT "scrobbles_artist_id_artists_xata_id_fk" FOREIGN KEY ("artist_id") REFERENCES "public"."artists"("xata_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
553ALTER TABLE "shout_likes" ADD CONSTRAINT "shout_likes_user_id_users_xata_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("xata_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
554ALTER TABLE "shout_likes" ADD CONSTRAINT "shout_likes_shout_id_shouts_xata_id_fk" FOREIGN KEY ("shout_id") REFERENCES "public"."shouts"("xata_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
555ALTER TABLE "shout_reports" ADD CONSTRAINT "shout_reports_user_id_users_xata_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("xata_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
556ALTER TABLE "shout_reports" ADD CONSTRAINT "shout_reports_shout_id_shouts_xata_id_fk" FOREIGN KEY ("shout_id") REFERENCES "public"."shouts"("xata_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
557ALTER TABLE "shouts" ADD CONSTRAINT "shouts_track_id_tracks_xata_id_fk" FOREIGN KEY ("track_id") REFERENCES "public"."tracks"("xata_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
558ALTER TABLE "shouts" ADD CONSTRAINT "shouts_artist_id_users_xata_id_fk" FOREIGN KEY ("artist_id") REFERENCES "public"."users"("xata_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
559ALTER TABLE "shouts" ADD CONSTRAINT "shouts_album_id_albums_xata_id_fk" FOREIGN KEY ("album_id") REFERENCES "public"."albums"("xata_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
560ALTER TABLE "shouts" ADD CONSTRAINT "shouts_scrobble_id_scrobbles_xata_id_fk" FOREIGN KEY ("scrobble_id") REFERENCES "public"."scrobbles"("xata_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
561ALTER TABLE "shouts" ADD CONSTRAINT "shouts_author_id_users_xata_id_fk" FOREIGN KEY ("author_id") REFERENCES "public"."users"("xata_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
562ALTER TABLE "shouts" ADD CONSTRAINT "shouts_parent_id_shouts_xata_id_fk" FOREIGN KEY ("parent_id") REFERENCES "public"."shouts"("xata_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
563ALTER TABLE "spotify_accounts" ADD CONSTRAINT "spotify_accounts_user_id_users_xata_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("xata_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
564ALTER TABLE "spotify_tokens" ADD CONSTRAINT "spotify_tokens_user_id_users_xata_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("xata_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
565ALTER TABLE "user_albums" ADD CONSTRAINT "user_albums_user_id_users_xata_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("xata_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
566ALTER TABLE "user_albums" ADD CONSTRAINT "user_albums_album_id_albums_xata_id_fk" FOREIGN KEY ("album_id") REFERENCES "public"."albums"("xata_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
567ALTER TABLE "user_artists" ADD CONSTRAINT "user_artists_user_id_users_xata_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("xata_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
568ALTER TABLE "user_artists" ADD CONSTRAINT "user_artists_artist_id_artists_xata_id_fk" FOREIGN KEY ("artist_id") REFERENCES "public"."artists"("xata_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
569ALTER TABLE "user_playlists" ADD CONSTRAINT "user_playlists_user_id_users_xata_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("xata_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
570ALTER TABLE "user_playlists" ADD CONSTRAINT "user_playlists_playlist_id_playlists_xata_id_fk" FOREIGN KEY ("playlist_id") REFERENCES "public"."playlists"("xata_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
571ALTER TABLE "user_tracks" ADD CONSTRAINT "user_tracks_user_id_users_xata_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("xata_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
572ALTER TABLE "user_tracks" ADD CONSTRAINT "user_tracks_track_id_tracks_xata_id_fk" FOREIGN KEY ("track_id") REFERENCES "public"."tracks"("xata_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
573ALTER TABLE "webscrobblers" ADD CONSTRAINT "webscrobblers_user_id_users_xata_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("xata_id") ON DELETE no action ON UPDATE no action;