Initial commit
This commit is contained in:
14
apps/server/drizzle/0002_red_susan_delgado.sql
Normal file
14
apps/server/drizzle/0002_red_susan_delgado.sql
Normal file
@@ -0,0 +1,14 @@
|
||||
CREATE TABLE "track_artists" (
|
||||
"track_id" uuid NOT NULL,
|
||||
"artist_id" uuid NOT NULL,
|
||||
"position" integer DEFAULT 0 NOT NULL,
|
||||
"role" text DEFAULT 'main' NOT NULL,
|
||||
CONSTRAINT "track_artists_track_id_artist_id_pk" PRIMARY KEY("track_id","artist_id")
|
||||
);
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE "track_artists" ADD CONSTRAINT "track_artists_track_id_tracks_id_fk" FOREIGN KEY ("track_id") REFERENCES "public"."tracks"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "track_artists" ADD CONSTRAINT "track_artists_artist_id_artists_id_fk" FOREIGN KEY ("artist_id") REFERENCES "public"."artists"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
CREATE INDEX "track_artists_artist_idx" ON "track_artists" USING btree ("artist_id");--> statement-breakpoint
|
||||
-- Backfill: make the existing single artist of each track a main credit.
|
||||
INSERT INTO "track_artists" ("track_id", "artist_id", "position", "role")
|
||||
SELECT "id", "artist_id", 0, 'main' FROM "tracks" WHERE "artist_id" IS NOT NULL;
|
||||
Reference in New Issue
Block a user