hacksu / hacksu/bingo

Tile position editor cannot reorder into an occupied position

Open
#14 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Description

## 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

1. Open `/admin/tiles` with two tiles at positions 0 and 1.
2. Change the position of tile 0 to 1 and save.
3. 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`

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the update action in src/routes/admin/tiles/+page.server.ts and the position constraint in src/lib/server/db/schema.ts, then inspect the form flow in src/routes/admin/tiles/+page.svelte. Reproduce the move from position 0 to 1 with two tiles. Done means occupied positions can be reordered or swapped safely, and conflicts return a validation error instead of an unhandled database error.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql, typescript
Domain
backend, database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.