29 lines
No EOL
1 KiB
SQL
29 lines
No EOL
1 KiB
SQL
CREATE SCHEMA "song_link";
|
|
--> statement-breakpoint
|
|
CREATE TYPE "entity_type" AS ENUM('song', 'album');--> statement-breakpoint
|
|
CREATE TABLE "song_link"."entities" (
|
|
"id" serial PRIMARY KEY,
|
|
"type" "entity_type" NOT NULL,
|
|
"title" text NOT NULL,
|
|
"page_url" text NOT NULL,
|
|
"artist_name" text NOT NULL,
|
|
"thumbnail" text NOT NULL,
|
|
"thumbnail_w" integer NOT NULL,
|
|
"thumbnail_h" integer NOT NULL,
|
|
"duration" integer,
|
|
"albumUrl" text,
|
|
"release_year" integer
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "song_link"."unique_ids" (
|
|
"id" text PRIMARY KEY,
|
|
"entity_id" integer NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "song_link"."urls" (
|
|
"url" text PRIMARY KEY,
|
|
"unique_id" text NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
ALTER TABLE "song_link"."unique_ids" ADD CONSTRAINT "unique_ids_entity_id_entities_id_fkey" FOREIGN KEY ("entity_id") REFERENCES "song_link"."entities"("id");--> statement-breakpoint
|
|
ALTER TABLE "song_link"."urls" ADD CONSTRAINT "urls_unique_id_unique_ids_id_fkey" FOREIGN KEY ("unique_id") REFERENCES "song_link"."unique_ids"("id"); |