Skip to content

Tile position editor cannot reorder into an occupied position #14

Description

@YoyoJesus

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions