Skip to content

setup: wire golang-migrate runner into server startup#11

Merged
Lewiskunta merged 1 commit into
mainfrom
setup/migrations
May 29, 2026
Merged

setup: wire golang-migrate runner into server startup#11
Lewiskunta merged 1 commit into
mainfrom
setup/migrations

Conversation

@Lewiskunta

Copy link
Copy Markdown
Contributor

Implements: database migration runner.

Changes:

  • Installed golang-migrate/v4, pgx/v5
  • Replaced SELECT 1 placeholder with real migration 000001
    enabling the pgcrypto extension for UUID generation
  • Created internal/db/migrate.go with RunMigrations()
  • RunMigrations() is idempotent - safe to call on every startup
  • Handles dirty state detection and logs migration version
  • Wired RunMigrations() into cmd/server/main.go startup sequence
  • Server exits with a non-zero code if migrations fail
  • Unit test for invalid database URL handling

Verified against live Docker Compose postgres:

  • Migration 000001 applies on first run
  • No re-application on subsequent runs (ErrNoChange)
  • schema_migrations table created by golang-migrate
  • pgcrypto extension enabled in database

@Lewiskunta Lewiskunta merged commit 2e56259 into main May 29, 2026
4 checks passed
@Lewiskunta Lewiskunta deleted the setup/migrations branch May 29, 2026 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant