Summary
The SDK README documents npm run migration:run as a required setup step, but the state of the actual migration files in the repository is unconfirmed. Several changes across the issue backlog add new columns, new enum values, and new tables that each require a migration. Without confirmed, complete migrations, a fresh environment setup will either fail silently with missing columns or require manual schema intervention. This issue audits existing migrations and generates all missing ones.
How to audit the current migration state
Run npm run migration:run in a clean environment and observe whether it succeeds without errors. Then run the application and attempt POST /accounts - if TypeORM throws column-not-found errors, migrations are incomplete. TypeORM can also generate a migration diff with
npm run migration:generate -- -n AuditCheck
against a fresh database - the generated file will show what the ORM thinks is missing.
Enum migration note
PostgreSQL enum changes are particularly fragile. Adding INITIALIZING to the AccountStatus enum requires:
sqlALTER TYPE account_status_enum ADD VALUE 'initializing' BEFORE 'pending_payment';
TypeORM's auto-generated migrations do not always handle enum additions correctly: verify the generated SQL manually before running it in any shared environment.
Environment considerations
Migrations should be safe to run multiple times (idempotent where possible). Each migration should have both an up and a down method: the down method is critical for rolling back during testing without manual database intervention.
Where to look
- src/database/: existing migration files and the TypeORM data source config
- src/modules/accounts/entities/account.entity.ts: source of truth for the accounts schema
- src/modules/claims/entities/claim.entity.ts: source of truth for the claims schema
- TypeORM migration documentation: specifically migration:generate and migration:run
Acceptance Criteria
Summary
The SDK README documents npm run migration:run as a required setup step, but the state of the actual migration files in the repository is unconfirmed. Several changes across the issue backlog add new columns, new enum values, and new tables that each require a migration. Without confirmed, complete migrations, a fresh environment setup will either fail silently with missing columns or require manual schema intervention. This issue audits existing migrations and generates all missing ones.
How to audit the current migration state
Run npm run migration:run in a clean environment and observe whether it succeeds without errors. Then run the application and attempt POST /accounts - if TypeORM throws column-not-found errors, migrations are incomplete. TypeORM can also generate a migration diff with
against a fresh database - the generated file will show what the ORM thinks is missing.
Enum migration note
PostgreSQL enum changes are particularly fragile. Adding INITIALIZING to the AccountStatus enum requires:
sqlALTER TYPE account_status_enum ADD VALUE 'initializing' BEFORE 'pending_payment';
TypeORM's auto-generated migrations do not always handle enum additions correctly: verify the generated SQL manually before running it in any shared environment.
Environment considerations
Migrations should be safe to run multiple times (idempotent where possible). Each migration should have both an up and a down method: the down method is critical for rolling back during testing without manual database intervention.
Where to look
Acceptance Criteria