diff --git a/app/routes/admin.sports.$id.tsx b/app/routes/admin.sports.$id.tsx index 3f8e65b..de0dde1 100644 --- a/app/routes/admin.sports.$id.tsx +++ b/app/routes/admin.sports.$id.tsx @@ -121,7 +121,13 @@ export async function action({ request, params }: Route.ActionArgs) { return redirect("/admin/sports"); } catch (error) { console.error("Error updating sport:", error); - return { error: "Failed to update sport. The slug might already exist." }; + const message = error instanceof Error ? error.message : String(error); + const isUniqueViolation = message.includes("unique") || message.includes("duplicate"); + return { + error: isUniqueViolation + ? "A sport with that slug already exists. Please choose a different slug." + : `Failed to update sport: ${message}`, + }; } } diff --git a/drizzle/0047_fix_nba_bracket_simulator_type.sql b/drizzle/0047_fix_nba_bracket_simulator_type.sql new file mode 100644 index 0000000..f7113c0 --- /dev/null +++ b/drizzle/0047_fix_nba_bracket_simulator_type.sql @@ -0,0 +1,12 @@ +-- Remediation: 0046 was recorded in _drizzle_migrations but was missing from +-- _journal.json, so its ALTER TYPE never executed on production. +-- This migration adds 'nba_bracket' to the simulator_type enum idempotently. +DO $$ BEGIN + IF NOT EXISTS ( + SELECT 1 FROM pg_enum + WHERE enumlabel = 'nba_bracket' + AND enumtypid = (SELECT oid FROM pg_type WHERE typname = 'simulator_type') + ) THEN + ALTER TYPE "public"."simulator_type" ADD VALUE 'nba_bracket'; + END IF; +END $$; diff --git a/drizzle/meta/_journal.json b/drizzle/meta/_journal.json index d4d2f5c..bb9a6fd 100644 --- a/drizzle/meta/_journal.json +++ b/drizzle/meta/_journal.json @@ -323,6 +323,20 @@ "when": 1773710000000, "tag": "0045_add_ncaaw_bracket_simulator_type", "breakpoints": true + }, + { + "idx": 46, + "version": "7", + "when": 1773720000000, + "tag": "0046_add_nba_bracket_simulator_type", + "breakpoints": true + }, + { + "idx": 47, + "version": "7", + "when": 1773730000000, + "tag": "0047_fix_nba_bracket_simulator_type", + "breakpoints": true } ] -} \ No newline at end of file +}