Fix NBA simulator missing from dropdown and enum not applied to prod DB
- Add nba_bracket SelectItem to simulator type dropdown in admin sport edit page - Add 0046 to _journal.json (it was missing, causing Drizzle to never run the ALTER TYPE on prod) - Add remediation migration 0047 with IF NOT EXISTS to safely add nba_bracket enum value on next deploy - Improve error message in updateSport action to surface actual DB error instead of always blaming the slug Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
e5431ebd0b
commit
5a48327102
3 changed files with 34 additions and 2 deletions
|
|
@ -121,7 +121,13 @@ export async function action({ request, params }: Route.ActionArgs) {
|
||||||
return redirect("/admin/sports");
|
return redirect("/admin/sports");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error updating sport:", 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}`,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
12
drizzle/0047_fix_nba_bracket_simulator_type.sql
Normal file
12
drizzle/0047_fix_nba_bracket_simulator_type.sql
Normal file
|
|
@ -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 $$;
|
||||||
|
|
@ -323,6 +323,20 @@
|
||||||
"when": 1773710000000,
|
"when": 1773710000000,
|
||||||
"tag": "0045_add_ncaaw_bracket_simulator_type",
|
"tag": "0045_add_ncaaw_bracket_simulator_type",
|
||||||
"breakpoints": true
|
"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
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue