Skip to content

refactor: Fix duplicate migration filenames #203

@Xhristin3

Description

@Xhristin3

Problem Statement

Two migration pairs share the date counter 2026061001:

  • database/migrations/2026061001_add_password_hash.{up,down}.sql
  • database/migrations/2026061001_add_user_password_hash.{up,down}.sql

The naming convention (YYYYMMDDNN_short_description.{up,down}.sql) requires <NN> to be unique for migrations on the same day. Having two 01 migrations creates a filename collision and ambiguous ordering.

Evidence

database/migrations/
  2026061001_add_password_hash.up.sql       ← both use 01
  2026061001_add_password_hash.down.sql
  2026061001_add_user_password_hash.up.sql  ← both use 01
  2026061001_add_user_password_hash.down.sql

Impact

Tooling that scans migrations by filename prefix could pick up the wrong migration or apply them in the wrong order. The schema.sql file has password_hash NOT NULL DEFAULT '' in the CREATE TABLE statement but the migration adds it as a column — these represent different approaches. Which migration should be applied first is ambiguous.

Proposed Solution

  1. Compare both migration pairs against database/schema.sql
  2. Determine which migration is correct
  3. Rename the second pair to 2026061002_*
  4. Update the README.md listing to reflect the rename
  5. Verify that applying both in order produces the same schema as schema.sql

Acceptance Criteria

  • No two migration pairs share the same date counter
  • Applying migrations in numeric order produces the schema.sql structure
  • Migration README listing is updated

File Map

  • database/migrations/2026061001_add_password_hash.up.sql — rename candidate
  • database/migrations/2026061001_add_password_hash.down.sql — rename candidate
  • database/migrations/2026061001_add_user_password_hash.up.sql — rename candidate
  • database/migrations/2026061001_add_user_password_hash.down.sql — rename candidate
  • database/migrations/README.md — update listing

Labels: refactoring, bug, quick win
Priority: Medium | Difficulty: Beginner | Estimated Effort: 1h


Labels: refactoring,bug,quick win
Priority: Medium | Difficulty: Beginner | Estimated Effort: 1h
Backlog ID: REPO-020

Metadata

Metadata

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions