diff --git a/src/db/migrations/0016_nervous_hydra.sql b/src/db/migrations/0016_nervous_hydra.sql new file mode 100644 index 0000000..a0368c8 --- /dev/null +++ b/src/db/migrations/0016_nervous_hydra.sql @@ -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 $$; diff --git a/src/db/migrations/0017_goofy_blob.sql b/src/db/migrations/0017_goofy_blob.sql new file mode 100644 index 0000000..40e16fb --- /dev/null +++ b/src/db/migrations/0017_goofy_blob.sql @@ -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); \ No newline at end of file diff --git a/src/db/migrations/meta/0016_snapshot.json b/src/db/migrations/meta/0016_snapshot.json new file mode 100644 index 0000000..baf9a90 --- /dev/null +++ b/src/db/migrations/meta/0016_snapshot.json @@ -0,0 +1,1062 @@ +{ + "id": "faa5deb9-63b8-4703-b041-aea159afaf3c", + "prevId": "85856aad-2b1f-46f5-8e04-762c2dd9dad3", + "version": "5", + "dialect": "pg", + "tables": { + "artists": { + "name": "artists", + "schema": "wxyc_schema", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "genre_id": { + "name": "genre_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "artist_name": { + "name": "artist_name", + "type": "varchar(128)", + "primaryKey": false, + "notNull": true + }, + "code_letters": { + "name": "code_letters", + "type": "varchar(2)", + "primaryKey": false, + "notNull": true + }, + "code_artist_number": { + "name": "code_artist_number", + "type": "smallint", + "primaryKey": false, + "notNull": true + }, + "add_date": { + "name": "add_date", + "type": "date", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "last_modified": { + "name": "last_modified", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "artist_name_trgm_idx": { + "name": "artist_name_trgm_idx", + "columns": [ + "artist_name" + ], + "isUnique": false + }, + "code_letters_idx": { + "name": "code_letters_idx", + "columns": [ + "code_letters" + ], + "isUnique": false + } + }, + "foreignKeys": { + "artists_genre_id_genres_id_fk": { + "name": "artists_genre_id_genres_id_fk", + "tableFrom": "artists", + "tableTo": "genres", + "schemaTo": "wxyc_schema", + "columnsFrom": [ + "genre_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "bins": { + "name": "bins", + "schema": "wxyc_schema", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "dj_id": { + "name": "dj_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "album_id": { + "name": "album_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "track_title": { + "name": "track_title", + "type": "varchar(128)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "bins_dj_id_djs_id_fk": { + "name": "bins_dj_id_djs_id_fk", + "tableFrom": "bins", + "tableTo": "djs", + "schemaTo": "wxyc_schema", + "columnsFrom": [ + "dj_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "bins_album_id_library_id_fk": { + "name": "bins_album_id_library_id_fk", + "tableFrom": "bins", + "tableTo": "library", + "schemaTo": "wxyc_schema", + "columnsFrom": [ + "album_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "djs": { + "name": "djs", + "schema": "wxyc_schema", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "cognito_user_name": { + "name": "cognito_user_name", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "real_name": { + "name": "real_name", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "dj_name": { + "name": "dj_name", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "shows_covered": { + "name": "shows_covered", + "type": "smallint", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "add_date": { + "name": "add_date", + "type": "date", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "djs_cognito_user_name_unique": { + "name": "djs_cognito_user_name_unique", + "nullsNotDistinct": false, + "columns": [ + "cognito_user_name" + ] + } + } + }, + "flowsheet": { + "name": "flowsheet", + "schema": "wxyc_schema", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "show_id": { + "name": "show_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "album_id": { + "name": "album_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "rotation_id": { + "name": "rotation_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "track_title": { + "name": "track_title", + "type": "varchar(128)", + "primaryKey": false, + "notNull": false + }, + "album_title": { + "name": "album_title", + "type": "varchar(128)", + "primaryKey": false, + "notNull": false + }, + "artist_name": { + "name": "artist_name", + "type": "varchar(128)", + "primaryKey": false, + "notNull": false + }, + "record_label": { + "name": "record_label", + "type": "varchar(128)", + "primaryKey": false, + "notNull": false + }, + "play_order": { + "name": "play_order", + "type": "serial", + "primaryKey": false, + "notNull": true + }, + "request_flag": { + "name": "request_flag", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "message": { + "name": "message", + "type": "varchar(250)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "flowsheet_show_id_shows_id_fk": { + "name": "flowsheet_show_id_shows_id_fk", + "tableFrom": "flowsheet", + "tableTo": "shows", + "schemaTo": "wxyc_schema", + "columnsFrom": [ + "show_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "flowsheet_album_id_library_id_fk": { + "name": "flowsheet_album_id_library_id_fk", + "tableFrom": "flowsheet", + "tableTo": "library", + "schemaTo": "wxyc_schema", + "columnsFrom": [ + "album_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "flowsheet_rotation_id_rotation_id_fk": { + "name": "flowsheet_rotation_id_rotation_id_fk", + "tableFrom": "flowsheet", + "tableTo": "rotation", + "schemaTo": "wxyc_schema", + "columnsFrom": [ + "rotation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "format": { + "name": "format", + "schema": "wxyc_schema", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "format_name": { + "name": "format_name", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "add_date": { + "name": "add_date", + "type": "date", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "genres": { + "name": "genres", + "schema": "wxyc_schema", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "genre_name": { + "name": "genre_name", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "plays": { + "name": "plays", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "add_date": { + "name": "add_date", + "type": "date", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "last_modified": { + "name": "last_modified", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "library": { + "name": "library", + "schema": "wxyc_schema", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "artist_id": { + "name": "artist_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "genre_id": { + "name": "genre_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "format_id": { + "name": "format_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "alternate_artist_name": { + "name": "alternate_artist_name", + "type": "varchar(128)", + "primaryKey": false, + "notNull": false + }, + "album_title": { + "name": "album_title", + "type": "varchar(128)", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "varchar(128)", + "primaryKey": false, + "notNull": false + }, + "code_number": { + "name": "code_number", + "type": "smallint", + "primaryKey": false, + "notNull": true + }, + "disc_quantity": { + "name": "disc_quantity", + "type": "smallint", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "plays": { + "name": "plays", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "add_date": { + "name": "add_date", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "last_modified": { + "name": "last_modified", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "title_trgm_idx": { + "name": "title_trgm_idx", + "columns": [ + "album_title" + ], + "isUnique": false + }, + "genre_id_idx": { + "name": "genre_id_idx", + "columns": [ + "genre_id" + ], + "isUnique": false + }, + "format_id_idx": { + "name": "format_id_idx", + "columns": [ + "format_id" + ], + "isUnique": false + }, + "artist_id_idx": { + "name": "artist_id_idx", + "columns": [ + "artist_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "library_artist_id_artists_id_fk": { + "name": "library_artist_id_artists_id_fk", + "tableFrom": "library", + "tableTo": "artists", + "schemaTo": "wxyc_schema", + "columnsFrom": [ + "artist_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "library_genre_id_genres_id_fk": { + "name": "library_genre_id_genres_id_fk", + "tableFrom": "library", + "tableTo": "genres", + "schemaTo": "wxyc_schema", + "columnsFrom": [ + "genre_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "library_format_id_format_id_fk": { + "name": "library_format_id_format_id_fk", + "tableFrom": "library", + "tableTo": "format", + "schemaTo": "wxyc_schema", + "columnsFrom": [ + "format_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "reviews": { + "name": "reviews", + "schema": "wxyc_schema", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "album_id": { + "name": "album_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "review": { + "name": "review", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "add_date": { + "name": "add_date", + "type": "date", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "last_modified": { + "name": "last_modified", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "author": { + "name": "author", + "type": "varchar(32)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "reviews_album_id_library_id_fk": { + "name": "reviews_album_id_library_id_fk", + "tableFrom": "reviews", + "tableTo": "library", + "schemaTo": "wxyc_schema", + "columnsFrom": [ + "album_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "reviews_album_id_unique": { + "name": "reviews_album_id_unique", + "nullsNotDistinct": false, + "columns": [ + "album_id" + ] + } + } + }, + "rotation": { + "name": "rotation", + "schema": "wxyc_schema", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "album_id": { + "name": "album_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "play_freq": { + "name": "play_freq", + "type": "freq_enum", + "primaryKey": false, + "notNull": true + }, + "add_date": { + "name": "add_date", + "type": "date", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "kill_date": { + "name": "kill_date", + "type": "date", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "album_id_idx": { + "name": "album_id_idx", + "columns": [ + "album_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "rotation_album_id_library_id_fk": { + "name": "rotation_album_id_library_id_fk", + "tableFrom": "rotation", + "tableTo": "library", + "schemaTo": "wxyc_schema", + "columnsFrom": [ + "album_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "schedule": { + "name": "schedule", + "schema": "wxyc_schema", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "day": { + "name": "day", + "type": "smallint", + "primaryKey": false, + "notNull": true + }, + "start_time": { + "name": "start_time", + "type": "time", + "primaryKey": false, + "notNull": true + }, + "show_duration": { + "name": "show_duration", + "type": "smallint", + "primaryKey": false, + "notNull": true + }, + "specialty_id": { + "name": "specialty_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "assigned_dj_id": { + "name": "assigned_dj_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "assigned_dj_id2": { + "name": "assigned_dj_id2", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "schedule_specialty_id_specialty_shows_id_fk": { + "name": "schedule_specialty_id_specialty_shows_id_fk", + "tableFrom": "schedule", + "tableTo": "specialty_shows", + "schemaTo": "wxyc_schema", + "columnsFrom": [ + "specialty_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "schedule_assigned_dj_id_djs_id_fk": { + "name": "schedule_assigned_dj_id_djs_id_fk", + "tableFrom": "schedule", + "tableTo": "djs", + "schemaTo": "wxyc_schema", + "columnsFrom": [ + "assigned_dj_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "schedule_assigned_dj_id2_djs_id_fk": { + "name": "schedule_assigned_dj_id2_djs_id_fk", + "tableFrom": "schedule", + "tableTo": "djs", + "schemaTo": "wxyc_schema", + "columnsFrom": [ + "assigned_dj_id2" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "shift_covers": { + "name": "shift_covers", + "schema": "wxyc_schema", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "schedule_id": { + "name": "schedule_id", + "type": "serial", + "primaryKey": false, + "notNull": true + }, + "shift_timestamp": { + "name": "shift_timestamp", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "cover_dj_id": { + "name": "cover_dj_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "covered": { + "name": "covered", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "shift_covers_schedule_id_schedule_id_fk": { + "name": "shift_covers_schedule_id_schedule_id_fk", + "tableFrom": "shift_covers", + "tableTo": "schedule", + "schemaTo": "wxyc_schema", + "columnsFrom": [ + "schedule_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "shift_covers_cover_dj_id_djs_id_fk": { + "name": "shift_covers_cover_dj_id_djs_id_fk", + "tableFrom": "shift_covers", + "tableTo": "djs", + "schemaTo": "wxyc_schema", + "columnsFrom": [ + "cover_dj_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "show_djs": { + "name": "show_djs", + "schema": "wxyc_schema", + "columns": { + "show_id": { + "name": "show_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "dj_id": { + "name": "dj_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": true + } + }, + "indexes": {}, + "foreignKeys": { + "show_djs_show_id_shows_id_fk": { + "name": "show_djs_show_id_shows_id_fk", + "tableFrom": "show_djs", + "tableTo": "shows", + "schemaTo": "wxyc_schema", + "columnsFrom": [ + "show_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "show_djs_dj_id_djs_id_fk": { + "name": "show_djs_dj_id_djs_id_fk", + "tableFrom": "show_djs", + "tableTo": "djs", + "schemaTo": "wxyc_schema", + "columnsFrom": [ + "dj_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "shows": { + "name": "shows", + "schema": "wxyc_schema", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "primary_dj_id": { + "name": "primary_dj_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "specialty_id": { + "name": "specialty_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "show_name": { + "name": "show_name", + "type": "varchar(128)", + "primaryKey": false, + "notNull": false + }, + "start_time": { + "name": "start_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "end_time": { + "name": "end_time", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "shows_primary_dj_id_djs_id_fk": { + "name": "shows_primary_dj_id_djs_id_fk", + "tableFrom": "shows", + "tableTo": "djs", + "schemaTo": "wxyc_schema", + "columnsFrom": [ + "primary_dj_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "shows_specialty_id_specialty_shows_id_fk": { + "name": "shows_specialty_id_specialty_shows_id_fk", + "tableFrom": "shows", + "tableTo": "specialty_shows", + "schemaTo": "wxyc_schema", + "columnsFrom": [ + "specialty_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "specialty_shows": { + "name": "specialty_shows", + "schema": "wxyc_schema", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "specialty_name": { + "name": "specialty_name", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "add_date": { + "name": "add_date", + "type": "date", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "last_modified": { + "name": "last_modified", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + } + }, + "enums": { + "freq_enum": { + "name": "freq_enum", + "values": { + "S": "S", + "L": "L", + "M": "M", + "H": "H" + } + } + }, + "schemas": { + "wxyc_schema": "wxyc_schema" + }, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/src/db/migrations/meta/0017_snapshot.json b/src/db/migrations/meta/0017_snapshot.json new file mode 100644 index 0000000..cd59538 --- /dev/null +++ b/src/db/migrations/meta/0017_snapshot.json @@ -0,0 +1,1062 @@ +{ + "id": "efa6d89c-b67c-4261-bc5c-c624150ec72b", + "prevId": "faa5deb9-63b8-4703-b041-aea159afaf3c", + "version": "5", + "dialect": "pg", + "tables": { + "artists": { + "name": "artists", + "schema": "wxyc_schema", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "genre_id": { + "name": "genre_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "artist_name": { + "name": "artist_name", + "type": "varchar(128)", + "primaryKey": false, + "notNull": true + }, + "code_letters": { + "name": "code_letters", + "type": "varchar(2)", + "primaryKey": false, + "notNull": true + }, + "code_artist_number": { + "name": "code_artist_number", + "type": "smallint", + "primaryKey": false, + "notNull": true + }, + "add_date": { + "name": "add_date", + "type": "date", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "last_modified": { + "name": "last_modified", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "artist_name_trgm_idx": { + "name": "artist_name_trgm_idx", + "columns": [ + "artist_name" + ], + "isUnique": false + }, + "code_letters_idx": { + "name": "code_letters_idx", + "columns": [ + "code_letters" + ], + "isUnique": false + } + }, + "foreignKeys": { + "artists_genre_id_genres_id_fk": { + "name": "artists_genre_id_genres_id_fk", + "tableFrom": "artists", + "columnsFrom": [ + "genre_id" + ], + "tableTo": "genres", + "schemaTo": "wxyc_schema", + "columnsTo": [ + "id" + ], + "onUpdate": "no action", + "onDelete": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "bins": { + "name": "bins", + "schema": "wxyc_schema", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "dj_id": { + "name": "dj_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "album_id": { + "name": "album_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "track_title": { + "name": "track_title", + "type": "varchar(128)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "bins_dj_id_djs_id_fk": { + "name": "bins_dj_id_djs_id_fk", + "tableFrom": "bins", + "columnsFrom": [ + "dj_id" + ], + "tableTo": "djs", + "schemaTo": "wxyc_schema", + "columnsTo": [ + "id" + ], + "onUpdate": "no action", + "onDelete": "no action" + }, + "bins_album_id_library_id_fk": { + "name": "bins_album_id_library_id_fk", + "tableFrom": "bins", + "columnsFrom": [ + "album_id" + ], + "tableTo": "library", + "schemaTo": "wxyc_schema", + "columnsTo": [ + "id" + ], + "onUpdate": "no action", + "onDelete": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "djs": { + "name": "djs", + "schema": "wxyc_schema", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "cognito_user_name": { + "name": "cognito_user_name", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "real_name": { + "name": "real_name", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "dj_name": { + "name": "dj_name", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "shows_covered": { + "name": "shows_covered", + "type": "smallint", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "add_date": { + "name": "add_date", + "type": "date", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "djs_cognito_user_name_unique": { + "name": "djs_cognito_user_name_unique", + "columns": [ + "cognito_user_name" + ], + "nullsNotDistinct": false + } + } + }, + "flowsheet": { + "name": "flowsheet", + "schema": "wxyc_schema", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "show_id": { + "name": "show_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "album_id": { + "name": "album_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "rotation_id": { + "name": "rotation_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "track_title": { + "name": "track_title", + "type": "varchar(128)", + "primaryKey": false, + "notNull": false + }, + "album_title": { + "name": "album_title", + "type": "varchar(128)", + "primaryKey": false, + "notNull": false + }, + "artist_name": { + "name": "artist_name", + "type": "varchar(128)", + "primaryKey": false, + "notNull": false + }, + "record_label": { + "name": "record_label", + "type": "varchar(128)", + "primaryKey": false, + "notNull": false + }, + "play_order": { + "name": "play_order", + "type": "serial", + "primaryKey": false, + "notNull": true + }, + "request_flag": { + "name": "request_flag", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "message": { + "name": "message", + "type": "varchar(250)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "flowsheet_show_id_shows_id_fk": { + "name": "flowsheet_show_id_shows_id_fk", + "tableFrom": "flowsheet", + "columnsFrom": [ + "show_id" + ], + "tableTo": "shows", + "schemaTo": "wxyc_schema", + "columnsTo": [ + "id" + ], + "onUpdate": "no action", + "onDelete": "no action" + }, + "flowsheet_album_id_library_id_fk": { + "name": "flowsheet_album_id_library_id_fk", + "tableFrom": "flowsheet", + "columnsFrom": [ + "album_id" + ], + "tableTo": "library", + "schemaTo": "wxyc_schema", + "columnsTo": [ + "id" + ], + "onUpdate": "no action", + "onDelete": "no action" + }, + "flowsheet_rotation_id_rotation_id_fk": { + "name": "flowsheet_rotation_id_rotation_id_fk", + "tableFrom": "flowsheet", + "columnsFrom": [ + "rotation_id" + ], + "tableTo": "rotation", + "schemaTo": "wxyc_schema", + "columnsTo": [ + "id" + ], + "onUpdate": "no action", + "onDelete": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "format": { + "name": "format", + "schema": "wxyc_schema", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "format_name": { + "name": "format_name", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "add_date": { + "name": "add_date", + "type": "date", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "genres": { + "name": "genres", + "schema": "wxyc_schema", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "genre_name": { + "name": "genre_name", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "plays": { + "name": "plays", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "add_date": { + "name": "add_date", + "type": "date", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "last_modified": { + "name": "last_modified", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "library": { + "name": "library", + "schema": "wxyc_schema", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "artist_id": { + "name": "artist_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "genre_id": { + "name": "genre_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "format_id": { + "name": "format_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "alternate_artist_name": { + "name": "alternate_artist_name", + "type": "varchar(128)", + "primaryKey": false, + "notNull": false + }, + "album_title": { + "name": "album_title", + "type": "varchar(128)", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "varchar(128)", + "primaryKey": false, + "notNull": false + }, + "code_number": { + "name": "code_number", + "type": "smallint", + "primaryKey": false, + "notNull": true + }, + "disc_quantity": { + "name": "disc_quantity", + "type": "smallint", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "plays": { + "name": "plays", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "add_date": { + "name": "add_date", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "last_modified": { + "name": "last_modified", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "title_trgm_idx": { + "name": "title_trgm_idx", + "columns": [ + "album_title" + ], + "isUnique": false + }, + "genre_id_idx": { + "name": "genre_id_idx", + "columns": [ + "genre_id" + ], + "isUnique": false + }, + "format_id_idx": { + "name": "format_id_idx", + "columns": [ + "format_id" + ], + "isUnique": false + }, + "artist_id_idx": { + "name": "artist_id_idx", + "columns": [ + "artist_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "library_artist_id_artists_id_fk": { + "name": "library_artist_id_artists_id_fk", + "tableFrom": "library", + "columnsFrom": [ + "artist_id" + ], + "tableTo": "artists", + "schemaTo": "wxyc_schema", + "columnsTo": [ + "id" + ], + "onUpdate": "no action", + "onDelete": "no action" + }, + "library_genre_id_genres_id_fk": { + "name": "library_genre_id_genres_id_fk", + "tableFrom": "library", + "columnsFrom": [ + "genre_id" + ], + "tableTo": "genres", + "schemaTo": "wxyc_schema", + "columnsTo": [ + "id" + ], + "onUpdate": "no action", + "onDelete": "no action" + }, + "library_format_id_format_id_fk": { + "name": "library_format_id_format_id_fk", + "tableFrom": "library", + "columnsFrom": [ + "format_id" + ], + "tableTo": "format", + "schemaTo": "wxyc_schema", + "columnsTo": [ + "id" + ], + "onUpdate": "no action", + "onDelete": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "reviews": { + "name": "reviews", + "schema": "wxyc_schema", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "album_id": { + "name": "album_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "review": { + "name": "review", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "add_date": { + "name": "add_date", + "type": "date", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "last_modified": { + "name": "last_modified", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "author": { + "name": "author", + "type": "varchar(32)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "reviews_album_id_library_id_fk": { + "name": "reviews_album_id_library_id_fk", + "tableFrom": "reviews", + "columnsFrom": [ + "album_id" + ], + "tableTo": "library", + "schemaTo": "wxyc_schema", + "columnsTo": [ + "id" + ], + "onUpdate": "no action", + "onDelete": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "reviews_album_id_unique": { + "name": "reviews_album_id_unique", + "columns": [ + "album_id" + ], + "nullsNotDistinct": false + } + } + }, + "rotation": { + "name": "rotation", + "schema": "wxyc_schema", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "album_id": { + "name": "album_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "play_freq": { + "name": "play_freq", + "type": "freq_enum", + "primaryKey": false, + "notNull": true + }, + "add_date": { + "name": "add_date", + "type": "date", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "kill_date": { + "name": "kill_date", + "type": "date", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "album_id_idx": { + "name": "album_id_idx", + "columns": [ + "album_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "rotation_album_id_library_id_fk": { + "name": "rotation_album_id_library_id_fk", + "tableFrom": "rotation", + "columnsFrom": [ + "album_id" + ], + "tableTo": "library", + "schemaTo": "wxyc_schema", + "columnsTo": [ + "id" + ], + "onUpdate": "no action", + "onDelete": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "schedule": { + "name": "schedule", + "schema": "wxyc_schema", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "day": { + "name": "day", + "type": "smallint", + "primaryKey": false, + "notNull": true + }, + "start_time": { + "name": "start_time", + "type": "time", + "primaryKey": false, + "notNull": true + }, + "show_duration": { + "name": "show_duration", + "type": "smallint", + "primaryKey": false, + "notNull": true + }, + "specialty_id": { + "name": "specialty_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "assigned_dj_id": { + "name": "assigned_dj_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "assigned_dj_id2": { + "name": "assigned_dj_id2", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "schedule_specialty_id_specialty_shows_id_fk": { + "name": "schedule_specialty_id_specialty_shows_id_fk", + "tableFrom": "schedule", + "columnsFrom": [ + "specialty_id" + ], + "tableTo": "specialty_shows", + "schemaTo": "wxyc_schema", + "columnsTo": [ + "id" + ], + "onUpdate": "no action", + "onDelete": "no action" + }, + "schedule_assigned_dj_id_djs_id_fk": { + "name": "schedule_assigned_dj_id_djs_id_fk", + "tableFrom": "schedule", + "columnsFrom": [ + "assigned_dj_id" + ], + "tableTo": "djs", + "schemaTo": "wxyc_schema", + "columnsTo": [ + "id" + ], + "onUpdate": "no action", + "onDelete": "no action" + }, + "schedule_assigned_dj_id2_djs_id_fk": { + "name": "schedule_assigned_dj_id2_djs_id_fk", + "tableFrom": "schedule", + "columnsFrom": [ + "assigned_dj_id2" + ], + "tableTo": "djs", + "schemaTo": "wxyc_schema", + "columnsTo": [ + "id" + ], + "onUpdate": "no action", + "onDelete": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "shift_covers": { + "name": "shift_covers", + "schema": "wxyc_schema", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "schedule_id": { + "name": "schedule_id", + "type": "serial", + "primaryKey": false, + "notNull": true + }, + "shift_timestamp": { + "name": "shift_timestamp", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "cover_dj_id": { + "name": "cover_dj_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "covered": { + "name": "covered", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "shift_covers_schedule_id_schedule_id_fk": { + "name": "shift_covers_schedule_id_schedule_id_fk", + "tableFrom": "shift_covers", + "columnsFrom": [ + "schedule_id" + ], + "tableTo": "schedule", + "schemaTo": "wxyc_schema", + "columnsTo": [ + "id" + ], + "onUpdate": "no action", + "onDelete": "no action" + }, + "shift_covers_cover_dj_id_djs_id_fk": { + "name": "shift_covers_cover_dj_id_djs_id_fk", + "tableFrom": "shift_covers", + "columnsFrom": [ + "cover_dj_id" + ], + "tableTo": "djs", + "schemaTo": "wxyc_schema", + "columnsTo": [ + "id" + ], + "onUpdate": "no action", + "onDelete": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "show_djs": { + "name": "show_djs", + "schema": "wxyc_schema", + "columns": { + "show_id": { + "name": "show_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "dj_id": { + "name": "dj_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": true + } + }, + "indexes": {}, + "foreignKeys": { + "show_djs_show_id_shows_id_fk": { + "name": "show_djs_show_id_shows_id_fk", + "tableFrom": "show_djs", + "columnsFrom": [ + "show_id" + ], + "tableTo": "shows", + "schemaTo": "wxyc_schema", + "columnsTo": [ + "id" + ], + "onUpdate": "no action", + "onDelete": "no action" + }, + "show_djs_dj_id_djs_id_fk": { + "name": "show_djs_dj_id_djs_id_fk", + "tableFrom": "show_djs", + "columnsFrom": [ + "dj_id" + ], + "tableTo": "djs", + "schemaTo": "wxyc_schema", + "columnsTo": [ + "id" + ], + "onUpdate": "no action", + "onDelete": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "shows": { + "name": "shows", + "schema": "wxyc_schema", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "primary_dj_id": { + "name": "primary_dj_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "specialty_id": { + "name": "specialty_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "show_name": { + "name": "show_name", + "type": "varchar(128)", + "primaryKey": false, + "notNull": false + }, + "start_time": { + "name": "start_time", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "end_time": { + "name": "end_time", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "shows_primary_dj_id_djs_id_fk": { + "name": "shows_primary_dj_id_djs_id_fk", + "tableFrom": "shows", + "columnsFrom": [ + "primary_dj_id" + ], + "tableTo": "djs", + "schemaTo": "wxyc_schema", + "columnsTo": [ + "id" + ], + "onUpdate": "no action", + "onDelete": "no action" + }, + "shows_specialty_id_specialty_shows_id_fk": { + "name": "shows_specialty_id_specialty_shows_id_fk", + "tableFrom": "shows", + "columnsFrom": [ + "specialty_id" + ], + "tableTo": "specialty_shows", + "schemaTo": "wxyc_schema", + "columnsTo": [ + "id" + ], + "onUpdate": "no action", + "onDelete": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "specialty_shows": { + "name": "specialty_shows", + "schema": "wxyc_schema", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "specialty_name": { + "name": "specialty_name", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "add_date": { + "name": "add_date", + "type": "date", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "last_modified": { + "name": "last_modified", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + } + }, + "enums": { + "freq_enum": { + "name": "freq_enum", + "values": { + "S": "S", + "L": "L", + "M": "M", + "H": "H" + } + } + }, + "schemas": { + "wxyc_schema": "wxyc_schema" + }, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/src/db/migrations/meta/_journal.json b/src/db/migrations/meta/_journal.json index 2b50e63..dd774a0 100644 --- a/src/db/migrations/meta/_journal.json +++ b/src/db/migrations/meta/_journal.json @@ -1,97 +1 @@ -{ - "version": "5", - "dialect": "pg", - "entries": [ - { - "idx": 0, - "version": "5", - "when": 1690316707315, - "tag": "0000_rare_prima", - "breakpoints": true - }, - { - "idx": 2, - "version": "5", - "when": 1690319148223, - "tag": "0002_glossy_satana", - "breakpoints": true - }, - { - "idx": 3, - "version": "5", - "when": 1691528003949, - "tag": "0003_real_nico_minoru", - "breakpoints": true - }, - { - "idx": 4, - "version": "5", - "when": 1691621609255, - "tag": "0004_thin_alice", - "breakpoints": true - }, - { - "idx": 6, - "version": "5", - "when": 1691775177202, - "tag": "0006_dashing_kylun", - "breakpoints": true - }, - { - "idx": 7, - "version": "5", - "when": 1691853822183, - "tag": "0007_happy_black_panther", - "breakpoints": true - }, - { - "idx": 9, - "version": "5", - "when": 1691871291859, - "tag": "0009_lame_texas_twister", - "breakpoints": true - }, - { - "idx": 10, - "version": "5", - "when": 1691871444204, - "tag": "0010_polite_black_tarantula", - "breakpoints": true - }, - { - "idx": 11, - "version": "5", - "when": 1691871522939, - "tag": "0011_milky_living_mummy", - "breakpoints": true - }, - { - "idx": 12, - "version": "5", - "when": 1691871754362, - "tag": "0012_chubby_bromley", - "breakpoints": true - }, - { - "idx": 13, - "version": "5", - "when": 1692296615441, - "tag": "0013_majestic_power_pack", - "breakpoints": true - }, - { - "idx": 14, - "version": "5", - "when": 1699567178920, - "tag": "0014_zippy_secret_warriors", - "breakpoints": true - }, - { - "idx": 15, - "version": "5", - "when": 1702495916392, - "tag": "0015_nostalgic_dorian_gray", - "breakpoints": true - } - ] -} \ No newline at end of file +{"version":"5","dialect":"pg","entries":[{"idx":0,"version":"5","when":1690316707315,"tag":"0000_rare_prima","breakpoints":true},{"idx":2,"version":"5","when":1690319148223,"tag":"0002_glossy_satana","breakpoints":true},{"idx":3,"version":"5","when":1691528003949,"tag":"0003_real_nico_minoru","breakpoints":true},{"idx":4,"version":"5","when":1691621609255,"tag":"0004_thin_alice","breakpoints":true},{"idx":6,"version":"5","when":1691775177202,"tag":"0006_dashing_kylun","breakpoints":true},{"idx":7,"version":"5","when":1691853822183,"tag":"0007_happy_black_panther","breakpoints":true},{"idx":9,"version":"5","when":1691871291859,"tag":"0009_lame_texas_twister","breakpoints":true},{"idx":10,"version":"5","when":1691871444204,"tag":"0010_polite_black_tarantula","breakpoints":true},{"idx":11,"version":"5","when":1691871522939,"tag":"0011_milky_living_mummy","breakpoints":true},{"idx":12,"version":"5","when":1691871754362,"tag":"0012_chubby_bromley","breakpoints":true},{"idx":13,"version":"5","when":1692296615441,"tag":"0013_majestic_power_pack","breakpoints":true},{"idx":14,"version":"5","when":1699567178920,"tag":"0014_zippy_secret_warriors","breakpoints":true},{"idx":15,"version":"5","when":1702495916392,"tag":"0015_nostalgic_dorian_gray","breakpoints":true},{"idx":16,"version":"5","when":1717631890141,"tag":"0016_nervous_hydra","breakpoints":true},{"idx":17,"version":"5","when":1717635516542,"tag":"0017_goofy_blob","breakpoints":true}]} \ No newline at end of file diff --git a/src/db/schema.ts b/src/db/schema.ts index 17ae793..1f504bb 100644 --- a/src/db/schema.ts +++ b/src/db/schema.ts @@ -245,9 +245,9 @@ export type LibraryArtistViewEntry = { album_title: string; format_name: string; genre_name: string; - rotation: string; + play_freq: string | null; add_date: Date; - label: string; + label: string | null; }; export const library_artist_view = wxyc_schema.view('library_artist_view').as((qb) => { return qb @@ -260,7 +260,7 @@ export const library_artist_view = wxyc_schema.view('library_artist_view').as((q album_title: library.album_title, format_name: format.format_name, genre_name: genres.genre_name, - rotation: rotation.play_freq, + play_freq: rotation.play_freq, add_date: library.add_date, label: library.label, }) diff --git a/src/services/flowsheet.service.ts b/src/services/flowsheet.service.ts index 97f1ab1..b815cb9 100644 --- a/src/services/flowsheet.service.ts +++ b/src/services/flowsheet.service.ts @@ -69,57 +69,68 @@ export const getEntriesByRange = async (startId: number, endId: number) => { }; export const addTrack = async (entry: NewFSEntry): Promise => { - if (entry.artist_name || entry.album_title || entry.record_label) { - const qb = new QueryBuilder(); - let query = qb.select().from(library_artist_view).$dynamic(); - - query = withArtistName(withAlbumTitle(withLabel(query, entry.record_label), entry.album_title), entry.artist_name); - const matching_albums: LibraryArtistViewEntry[] = await db.execute(query); - - if (matching_albums.length > 0) { - const matching_album_ids = matching_albums.map((album: LibraryArtistViewEntry) => { - return album.id; - }); - - await db - .update(library) - .set({ last_modified: sql`current_timestamp()`, plays: sql`${library.plays} + 1` }) - .where(inArray(library.id, matching_album_ids)); - } - } + /* + TODO: logic for updating album playcount + */ + // if (entry.artist_name || entry.album_title || entry.record_label) { + // const qb = new QueryBuilder(); + // let query = qb.select().from(library_artist_view).$dynamic(); + // query = withAlbumTitle(withArtistName(query, entry.artist_name), entry.album_title); + // console.log(query.toSQL()); + // // query = withAlbumTitle(query, entry.album_title); + // // console.log(query.toSQL()); + // query = withLabel(query, entry.record_label); + // console.log(query.toSQL()); + + // const matching_albums: LibraryArtistViewEntry[] = await db.execute(query); + + // if (matching_albums.length > 0) { + // const matching_album_ids = matching_albums.map((album: LibraryArtistViewEntry) => { + // return album.id; + // }); + + // await db + // .update(library) + // .set({ last_modified: sql`current_timestamp()`, plays: sql`${library.plays} + 1` }) + // .where(inArray(library.id, matching_album_ids)); + // } + // } const response = await db.insert(flowsheet).values(entry).returning(); return response[0]; }; export const removeTrack = async (entry_id: number): Promise => { - const entry = await db.select().from(flowsheet).where(eq(flowsheet.id, entry_id)).limit(1); - - if (entry.length === 0) { - throw new Error('Entry not found'); - } - - const qb = new QueryBuilder(); - const query = withArtistName( - withAlbumTitle( - withLabel(qb.select().from(library_artist_view).$dynamic(), entry[0].record_label), - entry[0].album_title - ), - entry[0].artist_name - ); - - const matching_albums: LibraryArtistViewEntry[] = await db.execute(query); - - if (matching_albums.length > 0) { - const matching_album_ids = matching_albums.map((album: LibraryArtistViewEntry) => { - return album.id; - }); - - await db - .update(library) - .set({ last_modified: sql`current_timestamp()`, plays: sql`${library.plays} - 1` }) - .where(inArray(library.id, matching_album_ids)); - } + /* + TODO: logic for updating album playcount + */ + // const entry = await db.select().from(flowsheet).where(eq(flowsheet.id, entry_id)).limit(1); + + // if (entry.length === 0) { + // throw new Error('Entry not found'); + // } + + // const qb = new QueryBuilder(); + // const query = withArtistName( + // withAlbumTitle( + // withLabel(qb.select().from(library_artist_view).$dynamic(), entry[0].record_label), + // entry[0].album_title + // ), + // entry[0].artist_name + // ); + + // const matching_albums: LibraryArtistViewEntry[] = await db.execute(query); + + // if (matching_albums.length > 0) { + // const matching_album_ids = matching_albums.map((album: LibraryArtistViewEntry) => { + // return album.id; + // }); + + // await db + // .update(library) + // .set({ last_modified: sql`current_timestamp()`, plays: sql`${library.plays} - 1` }) + // .where(inArray(library.id, matching_album_ids)); + // } const response = await db.delete(flowsheet).where(eq(flowsheet.id, entry_id)).returning(); return response[0];