Skip to content

Implement TypeORM migrations for production deployments #55

Description

@nanaf6203-bit

Area: Database
Priority: P1 — High

Description

Currently using synchronize: true (acceptable in development but dangerous in production). Schema changes must be controlled via migrations to prevent data loss, enable zero-downtime deploys, and ensure reproducibility across environments.

Acceptance Criteria

  • Generate initial migration capturing current schema (users, tips, notifications, refresh_tokens, social_links)
  • Set synchronize: false when NODE_ENV=production in src/config/typeorm.config.ts
  • Add npm scripts in package.json: migration:generate, migration:run, migration:revert, migration:show
  • Configure DataSource standalone for CLI: src/config/data-source.ts
  • Add docs/MIGRATIONS.md with naming conventions and best practices
  • Add CI job migration-check that fails on pending schema drift
  • Verify: run migrations on fresh DB → schema matches expected; revert → schema rolls back cleanly

Technical Notes

  • File naming: <timestamp>-<Name>.ts (TypeORM default)
  • Reversible: every migration has both up and down
  • No data migrations without explicit runbook
  • Reference: https://typeorm.io/migrations

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions