Skip to content

Commit

Permalink
Merge pull request #21 from WXYC/fix-postgresql-play_freq-err
Browse files Browse the repository at this point in the history
  • Loading branch information
AyBruno authored Jun 6, 2024
2 parents 2fa7151 + 5f16d43 commit 824c856
Show file tree
Hide file tree
Showing 7 changed files with 2,285 additions and 145 deletions.
80 changes: 80 additions & 0 deletions src/db/migrations/0016_nervous_hydra.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
ALTER TABLE "wxyc_schema"."artists" DROP CONSTRAINT "artists_genre_id_genres_id_fk";
--> statement-breakpoint
ALTER TABLE "wxyc_schema"."bins" DROP CONSTRAINT "bins_dj_id_djs_id_fk";
--> statement-breakpoint
ALTER TABLE "wxyc_schema"."flowsheet" DROP CONSTRAINT "flowsheet_show_id_shows_id_fk";
--> statement-breakpoint
ALTER TABLE "wxyc_schema"."library" DROP CONSTRAINT "library_artist_id_artists_id_fk";
--> statement-breakpoint
ALTER TABLE "wxyc_schema"."reviews" DROP CONSTRAINT "reviews_album_id_library_id_fk";
--> statement-breakpoint
ALTER TABLE "wxyc_schema"."rotation" DROP CONSTRAINT "rotation_album_id_library_id_fk";
--> statement-breakpoint
ALTER TABLE "wxyc_schema"."schedule" DROP CONSTRAINT "schedule_specialty_id_specialty_shows_id_fk";
--> statement-breakpoint
ALTER TABLE "wxyc_schema"."shift_covers" DROP CONSTRAINT "shift_covers_schedule_id_schedule_id_fk";
--> statement-breakpoint
ALTER TABLE "wxyc_schema"."show_djs" DROP CONSTRAINT "show_djs_show_id_shows_id_fk";
--> statement-breakpoint
ALTER TABLE "wxyc_schema"."shows" DROP CONSTRAINT "shows_primary_dj_id_djs_id_fk";
--> statement-breakpoint
ALTER TABLE "wxyc_schema"."flowsheet" ALTER COLUMN "message" SET DATA TYPE varchar(250);--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "wxyc_schema"."artists" ADD CONSTRAINT "artists_genre_id_genres_id_fk" FOREIGN KEY ("genre_id") REFERENCES "wxyc_schema"."genres"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "wxyc_schema"."bins" ADD CONSTRAINT "bins_dj_id_djs_id_fk" FOREIGN KEY ("dj_id") REFERENCES "wxyc_schema"."djs"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "wxyc_schema"."flowsheet" ADD CONSTRAINT "flowsheet_show_id_shows_id_fk" FOREIGN KEY ("show_id") REFERENCES "wxyc_schema"."shows"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "wxyc_schema"."library" ADD CONSTRAINT "library_artist_id_artists_id_fk" FOREIGN KEY ("artist_id") REFERENCES "wxyc_schema"."artists"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "wxyc_schema"."reviews" ADD CONSTRAINT "reviews_album_id_library_id_fk" FOREIGN KEY ("album_id") REFERENCES "wxyc_schema"."library"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "wxyc_schema"."rotation" ADD CONSTRAINT "rotation_album_id_library_id_fk" FOREIGN KEY ("album_id") REFERENCES "wxyc_schema"."library"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "wxyc_schema"."schedule" ADD CONSTRAINT "schedule_specialty_id_specialty_shows_id_fk" FOREIGN KEY ("specialty_id") REFERENCES "wxyc_schema"."specialty_shows"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "wxyc_schema"."shift_covers" ADD CONSTRAINT "shift_covers_schedule_id_schedule_id_fk" FOREIGN KEY ("schedule_id") REFERENCES "wxyc_schema"."schedule"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "wxyc_schema"."show_djs" ADD CONSTRAINT "show_djs_show_id_shows_id_fk" FOREIGN KEY ("show_id") REFERENCES "wxyc_schema"."shows"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "wxyc_schema"."shows" ADD CONSTRAINT "shows_primary_dj_id_djs_id_fk" FOREIGN KEY ("primary_dj_id") REFERENCES "wxyc_schema"."djs"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
21 changes: 21 additions & 0 deletions src/db/migrations/0017_goofy_blob.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
-- Custom SQL migration file, put you code below! --
DROP VIEW IF EXISTS "wxyc_schema"."library_artist_view";

CREATE VIEW "wxyc_schema"."library_artist_view" AS
SELECT "library"."id",
"artists"."code_letters",
"artists"."code_artist_number",
"library"."code_number",
"artists"."artist_name",
"library"."album_title",
"library"."label",
"format"."format_name",
"genres"."genre_name",
"rotation"."play_freq",
"library"."add_date"
FROM "wxyc_schema"."library"
INNER JOIN "wxyc_schema"."artists" ON "artists"."id" = "library"."artist_id"
INNER JOIN "wxyc_schema"."genres" ON "genres"."id" = "library"."genre_id"
INNER JOIN "wxyc_schema"."format" ON "format"."id" = "library"."format_id"
LEFT JOIN "wxyc_schema"."rotation"
ON "rotation"."album_id" = "library"."id" AND ("rotation"."kill_date" > CURRENT_DATE OR "rotation"."kill_date" IS NULL);
Loading

0 comments on commit 824c856

Please sign in to comment.