Problem
The admin tiles page promises reordering by position, but bingo_tile.position is unique and the update action writes the submitted position directly. Moving a tile to any existing position causes PostgreSQL's unique-constraint error instead of changing the order; swapping two positions is impossible through the UI.
Reproduction
- Open
/admin/tiles with two tiles at positions 0 and 1.
- Change the position of tile 0 to 1 and save.
- The database rejects the update on the unique
position constraint, currently surfaced as a server error.
Suggested fix
Implement a reorder operation that adjusts the intervening positions in a transaction (or use a temporary unused position for swaps), and return a validation error rather than an unhandled database error for conflicts.
Affected code
src/lib/server/db/schema.ts
src/routes/admin/tiles/+page.server.ts
src/routes/admin/tiles/+page.svelte
Problem
The admin tiles page promises reordering by position, but
bingo_tile.positionis unique and theupdateaction writes the submitted position directly. Moving a tile to any existing position causes PostgreSQL's unique-constraint error instead of changing the order; swapping two positions is impossible through the UI.Reproduction
/admin/tileswith two tiles at positions 0 and 1.positionconstraint, currently surfaced as a server error.Suggested fix
Implement a reorder operation that adjusts the intervening positions in a transaction (or use a temporary unused position for swaps), and return a validation error rather than an unhandled database error for conflicts.
Affected code
src/lib/server/db/schema.tssrc/routes/admin/tiles/+page.server.tssrc/routes/admin/tiles/+page.svelte