From e5a53c03061a8cb87c819b6ea98e6ad924bda421 Mon Sep 17 00:00:00 2001 From: Tsiry Sandratraina Date: Fri, 25 Jul 2025 04:16:27 +0300 Subject: [PATCH] use a custom postgres image with xataid extension enabled --- ...nit.sql => 0000_quiet_mister_sinister.sql} | 166 +++- apps/api/drizzle/meta/0000_snapshot.json | 787 +++++++++++++++++- apps/api/drizzle/meta/_journal.json | 4 +- apps/api/package.json | 3 +- compose.yaml | 2 +- package.json | 3 +- 6 files changed, 930 insertions(+), 35 deletions(-) rename apps/api/drizzle/{0000_init.sql => 0000_quiet_mister_sinister.sql} (69%) diff --git a/apps/api/drizzle/0000_init.sql b/apps/api/drizzle/0000_quiet_mister_sinister.sql similarity index 69% rename from apps/api/drizzle/0000_init.sql rename to apps/api/drizzle/0000_quiet_mister_sinister.sql index fcf11f1e..483b5d88 100644 --- a/apps/api/drizzle/0000_init.sql +++ b/apps/api/drizzle/0000_quiet_mister_sinister.sql @@ -1,5 +1,5 @@ CREATE TABLE "album_tracks" ( - "xata_id" text PRIMARY KEY NOT NULL, + "xata_id" text PRIMARY KEY DEFAULT xata_id(), "album_id" text NOT NULL, "track_id" text NOT NULL, "xata_createdat" timestamp DEFAULT now() NOT NULL, @@ -8,7 +8,7 @@ CREATE TABLE "album_tracks" ( ); --> statement-breakpoint CREATE TABLE "albums" ( - "xata_id" text PRIMARY KEY NOT NULL, + "xata_id" text PRIMARY KEY DEFAULT xata_id(), "title" text NOT NULL, "artist" text NOT NULL, "release_date" text, @@ -33,7 +33,7 @@ CREATE TABLE "albums" ( ); --> statement-breakpoint CREATE TABLE "api_keys" ( - "xata_id" text PRIMARY KEY NOT NULL, + "xata_id" text PRIMARY KEY DEFAULT xata_id(), "name" text NOT NULL, "api_key" text NOT NULL, "shared_secret" text NOT NULL, @@ -45,7 +45,7 @@ CREATE TABLE "api_keys" ( ); --> statement-breakpoint CREATE TABLE "artist_albums" ( - "xata_id" text PRIMARY KEY NOT NULL, + "xata_id" text PRIMARY KEY DEFAULT xata_id(), "artist_id" text NOT NULL, "album_id" text NOT NULL, "xata_createdat" timestamp DEFAULT now() NOT NULL, @@ -54,7 +54,7 @@ CREATE TABLE "artist_albums" ( ); --> statement-breakpoint CREATE TABLE "artist_tracks" ( - "xata_id" text PRIMARY KEY NOT NULL, + "xata_id" text PRIMARY KEY DEFAULT xata_id(), "artist_id" text NOT NULL, "track_id" text NOT NULL, "xata_createdat" timestamp DEFAULT now() NOT NULL, @@ -63,7 +63,7 @@ CREATE TABLE "artist_tracks" ( ); --> statement-breakpoint CREATE TABLE "artists" ( - "xata_id" text PRIMARY KEY NOT NULL, + "xata_id" text PRIMARY KEY DEFAULT xata_id(), "name" text NOT NULL, "biography" text, "born" timestamp, @@ -83,22 +83,115 @@ CREATE TABLE "artists" ( CONSTRAINT "artists_uri_unique" UNIQUE("uri") ); --> statement-breakpoint +CREATE TABLE "dropbox_accounts" ( + "xata_id" text PRIMARY KEY DEFAULT xata_id(), + "email" text NOT NULL, + "is_beta_user" boolean DEFAULT false NOT NULL, + "user_id" text NOT NULL, + "xata_version" text NOT NULL, + "xata_createdat" timestamp DEFAULT now() NOT NULL, + "xata_updatedat" timestamp DEFAULT now() NOT NULL, + CONSTRAINT "dropbox_accounts_email_unique" UNIQUE("email") +); +--> statement-breakpoint +CREATE TABLE "dropbox_directories" ( + "xata_id" text PRIMARY KEY DEFAULT xata_id(), + "name" text NOT NULL, + "path" text NOT NULL, + "parent_id" text, + "dropbox_id" text NOT NULL, + "file_id" text NOT NULL, + "xata_version" text NOT NULL, + "xata_createdat" timestamp DEFAULT now() NOT NULL, + "xata_updatedat" timestamp DEFAULT now() NOT NULL, + CONSTRAINT "dropbox_directories_file_id_unique" UNIQUE("file_id") +); +--> statement-breakpoint +CREATE TABLE "dropbox_paths" ( + "xata_id" text PRIMARY KEY DEFAULT xata_id(), + "path" text NOT NULL, + "name" text NOT NULL, + "dropbox_id" text NOT NULL, + "track_id" text NOT NULL, + "directory_id" text, + "file_id" text NOT NULL, + "xata_version" text NOT NULL, + "xata_createdat" timestamp DEFAULT now() NOT NULL, + "xata_updatedat" timestamp DEFAULT now() NOT NULL, + CONSTRAINT "dropbox_paths_file_id_unique" UNIQUE("file_id") +); +--> statement-breakpoint CREATE TABLE "dropbox_tokens" ( - "xata_id" text PRIMARY KEY NOT NULL, + "xata_id" text PRIMARY KEY DEFAULT xata_id(), "refresh_token" text NOT NULL, "xata_createdat" timestamp DEFAULT now() NOT NULL, "xata_updatedat" timestamp DEFAULT now() NOT NULL ); --> statement-breakpoint +CREATE TABLE "dropbox" ( + "xata_id" text PRIMARY KEY DEFAULT xata_id(), + "user_id" text NOT NULL, + "dropbox_token_id" text NOT NULL, + "xata_version" text NOT NULL, + "xata_createdat" timestamp DEFAULT now() NOT NULL, + "xata_updatedat" timestamp DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "google_drive_accounts" ( + "xata_id" text PRIMARY KEY DEFAULT xata_id(), + "email" text NOT NULL, + "is_beta_user" boolean DEFAULT false NOT NULL, + "user_id" text NOT NULL, + "xata_version" text NOT NULL, + "xata_createdat" timestamp DEFAULT now() NOT NULL, + "xata_updatedat" timestamp DEFAULT now() NOT NULL, + CONSTRAINT "google_drive_accounts_email_unique" UNIQUE("email") +); +--> statement-breakpoint +CREATE TABLE "google_drive_directories" ( + "xata_id" text PRIMARY KEY DEFAULT xata_id(), + "name" text NOT NULL, + "path" text NOT NULL, + "parent_id" text, + "google_drive_id" text NOT NULL, + "file_id" text NOT NULL, + "xata_version" text NOT NULL, + "xata_createdat" timestamp DEFAULT now() NOT NULL, + "xata_updatedat" timestamp DEFAULT now() NOT NULL, + CONSTRAINT "google_drive_directories_file_id_unique" UNIQUE("file_id") +); +--> statement-breakpoint +CREATE TABLE "google_drive_paths" ( + "xata_id" text PRIMARY KEY DEFAULT xata_id(), + "google_drive_id" text NOT NULL, + "track_id" text NOT NULL, + "name" text NOT NULL, + "directory_id" text, + "file_id" text NOT NULL, + "xata_version" text NOT NULL, + "xata_createdat" timestamp DEFAULT now() NOT NULL, + "xata_updatedat" timestamp DEFAULT now() NOT NULL, + CONSTRAINT "google_drive_paths_file_id_unique" UNIQUE("file_id") +); +--> statement-breakpoint CREATE TABLE "google_drive_tokens" ( - "xata_id" text PRIMARY KEY NOT NULL, + "xata_id" text PRIMARY KEY DEFAULT xata_id(), "refresh_token" text NOT NULL, "xata_createdat" timestamp DEFAULT now() NOT NULL, "xata_updatedat" timestamp DEFAULT now() NOT NULL ); --> statement-breakpoint +CREATE TABLE "google_drive" ( + "xata_id" text PRIMARY KEY DEFAULT xata_id(), + "google_drive_token_id" text NOT NULL, + "user_id" text NOT NULL, + "xata_version" text NOT NULL, + "xata_createdat" timestamp DEFAULT now() NOT NULL, + "xata_updatedat" timestamp DEFAULT now() NOT NULL +); +--> statement-breakpoint CREATE TABLE "loved_tracks" ( - "xata_id" text PRIMARY KEY NOT NULL, + "xata_id" text PRIMARY KEY DEFAULT xata_id(), "user_id" text NOT NULL, "track_id" text NOT NULL, "uri" text, @@ -107,14 +200,14 @@ CREATE TABLE "loved_tracks" ( ); --> statement-breakpoint CREATE TABLE "playlist_tracks" ( - "xata_id" text PRIMARY KEY NOT NULL, + "xata_id" text PRIMARY KEY DEFAULT xata_id(), "playlist_id" text NOT NULL, "track_id" text NOT NULL, "xata_createdat" timestamp DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE "playlists" ( - "xata_id" text PRIMARY KEY NOT NULL, + "xata_id" text PRIMARY KEY DEFAULT xata_id(), "name" text NOT NULL, "picture" text, "description" text, @@ -129,14 +222,25 @@ CREATE TABLE "playlists" ( ); --> statement-breakpoint CREATE TABLE "profile_shouts" ( - "xata_id" text PRIMARY KEY NOT NULL, + "xata_id" text PRIMARY KEY DEFAULT xata_id(), "user_id" text NOT NULL, "shout_id" text NOT NULL, "xata_createdat" timestamp DEFAULT now() NOT NULL ); --> statement-breakpoint +CREATE TABLE "queue_tracks" ( + "xata_id" text PRIMARY KEY DEFAULT xata_id(), + "user_id" text NOT NULL, + "track_id" text NOT NULL, + "position" integer NOT NULL, + "file_uri" text NOT NULL, + "xata_version" integer DEFAULT 0 NOT NULL, + "xata_createdat" timestamp DEFAULT now() NOT NULL, + "xata_updatedat" timestamp DEFAULT now() NOT NULL +); +--> statement-breakpoint CREATE TABLE "scrobbles" ( - "xata_id" text PRIMARY KEY NOT NULL, + "xata_id" text PRIMARY KEY DEFAULT xata_id(), "user_id" text, "track_id" text, "album_id" text, @@ -150,7 +254,7 @@ CREATE TABLE "scrobbles" ( ); --> statement-breakpoint CREATE TABLE "shout_likes" ( - "xata_id" text PRIMARY KEY NOT NULL, + "xata_id" text PRIMARY KEY DEFAULT xata_id(), "user_id" text NOT NULL, "shout_id" text NOT NULL, "xata_createdat" timestamp DEFAULT now() NOT NULL, @@ -159,14 +263,14 @@ CREATE TABLE "shout_likes" ( ); --> statement-breakpoint CREATE TABLE "shout_reports" ( - "xata_id" text PRIMARY KEY NOT NULL, + "xata_id" text PRIMARY KEY DEFAULT xata_id(), "user_id" text NOT NULL, "shout_id" text NOT NULL, "xata_createdat" timestamp DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE "shouts" ( - "xata_id" text PRIMARY KEY NOT NULL, + "xata_id" text PRIMARY KEY DEFAULT xata_id(), "content" text NOT NULL, "track_id" text, "artist_id" text, @@ -181,7 +285,7 @@ CREATE TABLE "shouts" ( ); --> statement-breakpoint CREATE TABLE "spotify_accounts" ( - "xata_id" text PRIMARY KEY NOT NULL, + "xata_id" text PRIMARY KEY DEFAULT xata_id(), "xata_version" integer NOT NULL, "email" text NOT NULL, "user_id" text NOT NULL, @@ -191,7 +295,7 @@ CREATE TABLE "spotify_accounts" ( ); --> statement-breakpoint CREATE TABLE "spotify_tokens" ( - "xata_id" text PRIMARY KEY NOT NULL, + "xata_id" text PRIMARY KEY DEFAULT xata_id(), "xata_version" integer NOT NULL, "access_token" text NOT NULL, "refresh_token" text NOT NULL, @@ -201,7 +305,7 @@ CREATE TABLE "spotify_tokens" ( ); --> statement-breakpoint CREATE TABLE "tracks" ( - "xata_id" text PRIMARY KEY NOT NULL, + "xata_id" text PRIMARY KEY DEFAULT xata_id(), "title" text NOT NULL, "artist" text NOT NULL, "album_artist" text NOT NULL, @@ -239,7 +343,7 @@ CREATE TABLE "tracks" ( ); --> statement-breakpoint CREATE TABLE "user_albums" ( - "xata_id" text PRIMARY KEY NOT NULL, + "xata_id" text PRIMARY KEY DEFAULT xata_id(), "user_id" text NOT NULL, "album_id" text NOT NULL, "xata_createdat" timestamp DEFAULT now() NOT NULL, @@ -251,7 +355,7 @@ CREATE TABLE "user_albums" ( ); --> statement-breakpoint CREATE TABLE "user_artists" ( - "xata_id" text PRIMARY KEY NOT NULL, + "xata_id" text PRIMARY KEY DEFAULT xata_id(), "user_id" text NOT NULL, "artist_id" text NOT NULL, "xata_createdat" timestamp DEFAULT now() NOT NULL, @@ -263,7 +367,7 @@ CREATE TABLE "user_artists" ( ); --> statement-breakpoint CREATE TABLE "user_playlists" ( - "xata_id" text PRIMARY KEY NOT NULL, + "xata_id" text PRIMARY KEY DEFAULT xata_id(), "user_id" text NOT NULL, "playlist_id" text NOT NULL, "xata_createdat" timestamp DEFAULT now() NOT NULL, @@ -272,7 +376,7 @@ CREATE TABLE "user_playlists" ( ); --> statement-breakpoint CREATE TABLE "user_tracks" ( - "xata_id" text PRIMARY KEY NOT NULL, + "xata_id" text PRIMARY KEY DEFAULT xata_id(), "user_id" text NOT NULL, "track_id" text NOT NULL, "xata_createdat" timestamp DEFAULT now() NOT NULL, @@ -284,7 +388,7 @@ CREATE TABLE "user_tracks" ( ); --> statement-breakpoint CREATE TABLE "users" ( - "xata_id" text PRIMARY KEY NOT NULL, + "xata_id" text PRIMARY KEY DEFAULT xata_id(), "did" text NOT NULL, "display_name" text NOT NULL, "handle" text NOT NULL, @@ -297,7 +401,7 @@ CREATE TABLE "users" ( ); --> statement-breakpoint CREATE TABLE "webscrobblers" ( - "xata_id" text PRIMARY KEY NOT NULL, + "xata_id" text PRIMARY KEY DEFAULT xata_id(), "name" text NOT NULL, "uuid" text NOT NULL, "description" text, @@ -314,6 +418,16 @@ ALTER TABLE "artist_albums" ADD CONSTRAINT "artist_albums_artist_id_artists_xata ALTER 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 ALTER 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 ALTER 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 +ALTER 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 +ALTER 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 +ALTER 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 +ALTER 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 +ALTER 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 +ALTER 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 +ALTER 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 +ALTER 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 +ALTER 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 +ALTER 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 ALTER 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 ALTER 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 ALTER 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 @@ -321,6 +435,8 @@ ALTER TABLE "playlist_tracks" ADD CONSTRAINT "playlist_tracks_track_id_tracks_xa ALTER 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 ALTER 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 ALTER 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 +ALTER 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 +ALTER 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 ALTER 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 ALTER 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 ALTER 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 diff --git a/apps/api/drizzle/meta/0000_snapshot.json b/apps/api/drizzle/meta/0000_snapshot.json index 50b5d69a..cfb7d870 100644 --- a/apps/api/drizzle/meta/0000_snapshot.json +++ b/apps/api/drizzle/meta/0000_snapshot.json @@ -1,5 +1,5 @@ { - "id": "4c369380-a733-4097-b87a-036a11bbc173", + "id": "49adc24b-83c8-4065-8e13-80045e7f0f27", "prevId": "00000000-0000-0000-0000-000000000000", "version": "7", "dialect": "postgresql", @@ -602,6 +602,274 @@ "checkConstraints": {}, "isRLSEnabled": false }, + "public.dropbox_accounts": { + "name": "dropbox_accounts", + "schema": "", + "columns": { + "xata_id": { + "name": "xata_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "is_beta_user": { + "name": "is_beta_user", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "xata_version": { + "name": "xata_version", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "xata_createdat": { + "name": "xata_createdat", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "xata_updatedat": { + "name": "xata_updatedat", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "dropbox_accounts_user_id_users_xata_id_fk": { + "name": "dropbox_accounts_user_id_users_xata_id_fk", + "tableFrom": "dropbox_accounts", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "xata_id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "dropbox_accounts_email_unique": { + "name": "dropbox_accounts_email_unique", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.dropbox_directories": { + "name": "dropbox_directories", + "schema": "", + "columns": { + "xata_id": { + "name": "xata_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "path": { + "name": "path", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "parent_id": { + "name": "parent_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "dropbox_id": { + "name": "dropbox_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "file_id": { + "name": "file_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "xata_version": { + "name": "xata_version", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "xata_createdat": { + "name": "xata_createdat", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "xata_updatedat": { + "name": "xata_updatedat", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "dropbox_directories_parent_id_dropbox_directories_xata_id_fk": { + "name": "dropbox_directories_parent_id_dropbox_directories_xata_id_fk", + "tableFrom": "dropbox_directories", + "tableTo": "dropbox_directories", + "columnsFrom": [ + "parent_id" + ], + "columnsTo": [ + "xata_id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "dropbox_directories_file_id_unique": { + "name": "dropbox_directories_file_id_unique", + "nullsNotDistinct": false, + "columns": [ + "file_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.dropbox_paths": { + "name": "dropbox_paths", + "schema": "", + "columns": { + "xata_id": { + "name": "xata_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "path": { + "name": "path", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "dropbox_id": { + "name": "dropbox_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "track_id": { + "name": "track_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "directory_id": { + "name": "directory_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "file_id": { + "name": "file_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "xata_version": { + "name": "xata_version", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "xata_createdat": { + "name": "xata_createdat", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "xata_updatedat": { + "name": "xata_updatedat", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "dropbox_paths_directory_id_dropbox_directories_xata_id_fk": { + "name": "dropbox_paths_directory_id_dropbox_directories_xata_id_fk", + "tableFrom": "dropbox_paths", + "tableTo": "dropbox_directories", + "columnsFrom": [ + "directory_id" + ], + "columnsTo": [ + "xata_id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "dropbox_paths_file_id_unique": { + "name": "dropbox_paths_file_id_unique", + "nullsNotDistinct": false, + "columns": [ + "file_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, "public.dropbox_tokens": { "name": "dropbox_tokens", "schema": "", @@ -612,8 +880,326 @@ "primaryKey": true, "notNull": true }, - "refresh_token": { - "name": "refresh_token", + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "xata_createdat": { + "name": "xata_createdat", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "xata_updatedat": { + "name": "xata_updatedat", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.dropbox": { + "name": "dropbox", + "schema": "", + "columns": { + "xata_id": { + "name": "xata_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "dropbox_token_id": { + "name": "dropbox_token_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "xata_version": { + "name": "xata_version", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "xata_createdat": { + "name": "xata_createdat", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "xata_updatedat": { + "name": "xata_updatedat", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "dropbox_user_id_users_xata_id_fk": { + "name": "dropbox_user_id_users_xata_id_fk", + "tableFrom": "dropbox", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "xata_id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "dropbox_dropbox_token_id_dropbox_tokens_xata_id_fk": { + "name": "dropbox_dropbox_token_id_dropbox_tokens_xata_id_fk", + "tableFrom": "dropbox", + "tableTo": "dropbox_tokens", + "columnsFrom": [ + "dropbox_token_id" + ], + "columnsTo": [ + "xata_id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.google_drive_accounts": { + "name": "google_drive_accounts", + "schema": "", + "columns": { + "xata_id": { + "name": "xata_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "is_beta_user": { + "name": "is_beta_user", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "xata_version": { + "name": "xata_version", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "xata_createdat": { + "name": "xata_createdat", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "xata_updatedat": { + "name": "xata_updatedat", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "google_drive_accounts_user_id_users_xata_id_fk": { + "name": "google_drive_accounts_user_id_users_xata_id_fk", + "tableFrom": "google_drive_accounts", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "xata_id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "google_drive_accounts_email_unique": { + "name": "google_drive_accounts_email_unique", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.google_drive_directories": { + "name": "google_drive_directories", + "schema": "", + "columns": { + "xata_id": { + "name": "xata_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "path": { + "name": "path", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "parent_id": { + "name": "parent_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "google_drive_id": { + "name": "google_drive_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "file_id": { + "name": "file_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "xata_version": { + "name": "xata_version", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "xata_createdat": { + "name": "xata_createdat", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "xata_updatedat": { + "name": "xata_updatedat", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "google_drive_directories_parent_id_google_drive_directories_xata_id_fk": { + "name": "google_drive_directories_parent_id_google_drive_directories_xata_id_fk", + "tableFrom": "google_drive_directories", + "tableTo": "google_drive_directories", + "columnsFrom": [ + "parent_id" + ], + "columnsTo": [ + "xata_id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "google_drive_directories_file_id_unique": { + "name": "google_drive_directories_file_id_unique", + "nullsNotDistinct": false, + "columns": [ + "file_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.google_drive_paths": { + "name": "google_drive_paths", + "schema": "", + "columns": { + "xata_id": { + "name": "xata_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "google_drive_id": { + "name": "google_drive_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "track_id": { + "name": "track_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "directory_id": { + "name": "directory_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "file_id": { + "name": "file_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "xata_version": { + "name": "xata_version", "type": "text", "primaryKey": false, "notNull": true @@ -634,9 +1220,31 @@ } }, "indexes": {}, - "foreignKeys": {}, + "foreignKeys": { + "google_drive_paths_directory_id_google_drive_directories_xata_id_fk": { + "name": "google_drive_paths_directory_id_google_drive_directories_xata_id_fk", + "tableFrom": "google_drive_paths", + "tableTo": "google_drive_directories", + "columnsFrom": [ + "directory_id" + ], + "columnsTo": [ + "xata_id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, "compositePrimaryKeys": {}, - "uniqueConstraints": {}, + "uniqueConstraints": { + "google_drive_paths_file_id_unique": { + "name": "google_drive_paths_file_id_unique", + "nullsNotDistinct": false, + "columns": [ + "file_id" + ] + } + }, "policies": {}, "checkConstraints": {}, "isRLSEnabled": false @@ -680,6 +1288,84 @@ "checkConstraints": {}, "isRLSEnabled": false }, + "public.google_drive": { + "name": "google_drive", + "schema": "", + "columns": { + "xata_id": { + "name": "xata_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "google_drive_token_id": { + "name": "google_drive_token_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "xata_version": { + "name": "xata_version", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "xata_createdat": { + "name": "xata_createdat", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "xata_updatedat": { + "name": "xata_updatedat", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "google_drive_google_drive_token_id_google_drive_tokens_xata_id_fk": { + "name": "google_drive_google_drive_token_id_google_drive_tokens_xata_id_fk", + "tableFrom": "google_drive", + "tableTo": "google_drive_tokens", + "columnsFrom": [ + "google_drive_token_id" + ], + "columnsTo": [ + "xata_id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "google_drive_user_id_users_xata_id_fk": { + "name": "google_drive_user_id_users_xata_id_fk", + "tableFrom": "google_drive", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "xata_id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, "public.loved_tracks": { "name": "loved_tracks", "schema": "", @@ -992,6 +1678,97 @@ "checkConstraints": {}, "isRLSEnabled": false }, + "public.queue_tracks": { + "name": "queue_tracks", + "schema": "", + "columns": { + "xata_id": { + "name": "xata_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "track_id": { + "name": "track_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "file_uri": { + "name": "file_uri", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "xata_version": { + "name": "xata_version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "xata_createdat": { + "name": "xata_createdat", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "xata_updatedat": { + "name": "xata_updatedat", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "queue_tracks_user_id_users_xata_id_fk": { + "name": "queue_tracks_user_id_users_xata_id_fk", + "tableFrom": "queue_tracks", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "xata_id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "queue_tracks_track_id_tracks_xata_id_fk": { + "name": "queue_tracks_track_id_tracks_xata_id_fk", + "tableFrom": "queue_tracks", + "tableTo": "tracks", + "columnsFrom": [ + "track_id" + ], + "columnsTo": [ + "xata_id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, "public.scrobbles": { "name": "scrobbles", "schema": "", diff --git a/apps/api/drizzle/meta/_journal.json b/apps/api/drizzle/meta/_journal.json index 872ff62e..7b72c3b3 100644 --- a/apps/api/drizzle/meta/_journal.json +++ b/apps/api/drizzle/meta/_journal.json @@ -5,8 +5,8 @@ { "idx": 0, "version": "7", - "when": 1750169528964, - "tag": "0000_init", + "when": 1753405608015, + "tag": "0000_quiet_mister_sinister", "breakpoints": true } ] diff --git a/apps/api/package.json b/apps/api/package.json index 1c464d4b..13fc9e25 100644 --- a/apps/api/package.json +++ b/apps/api/package.json @@ -17,7 +17,8 @@ "pkl:gen": "tsx ./scripts/pkl.ts", "dev:xrpc": "tsx --watch ./src/server.ts", "prod:xrpc": "tsx ./src/server.ts", - "db:migrate": "drizzle-kit migrate" + "db:migrate": "drizzle-kit migrate", + "db:gen-migration": "drizzle-kit generate" }, "dependencies": { "@atproto/api": "^0.13.31", diff --git a/compose.yaml b/compose.yaml index 5555f32e..aa75075e 100644 --- a/compose.yaml +++ b/compose.yaml @@ -26,7 +26,7 @@ services: - meilisearch_data:/data.ms db: - image: postgres:15 + image: tsiry/postgres-xataid:latest ports: - '5433:5432' environment: diff --git a/package.json b/package.json index eb59724f..7a0c96cf 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "scripts": { "dev": "turbo dev", "db:migrate": "cd apps/api && bun run db:migrate", + "db:gen-migration": "cd apps/api && bun run db:gen-migration", "pkl:eval": "cd apps/api && bun run pkl:eval", "pkl:gen": "cd apps/api && bun run pkl:gen", "lexgen": "cd apps/api && bun run lexgen", @@ -38,4 +39,4 @@ "packages/*", "crates" ] -} +} \ No newline at end of file -- 2.51.2