Skip to content

Add automated database migration dry-run step to CI pipeline#1070

Open
EmeditWeb wants to merge 1 commit into
rinafcode:mainfrom
EmeditWeb:automated-db-migration
Open

Add automated database migration dry-run step to CI pipeline#1070
EmeditWeb wants to merge 1 commit into
rinafcode:mainfrom
EmeditWeb:automated-db-migration

Conversation

@EmeditWeb

Copy link
Copy Markdown

Close #840

Summary

Adds automated TypeORM migration validation to the CI pipeline to catch broken or missing migrations before deployment.

Changes

New file

  • src/config/datasource.ts — TypeORM DataSource configuration for CLI use, with synchronize: false and correct migration paths

CI workflow (.github/workflows/ci.yml)

  • Added PostgreSQL 16 service container with health check
  • Added database environment variables (DATABASE_HOST, DATABASE_PORT, etc.)
  • Added Run migrations step (pnpm run migration:run)
  • Added Check for schema drift step (pnpm run migration:generate:check)
  • Added Revert migrations step (pnpm run migration:revert)

Package scripts (package.json)

  • migration:run — run TypeORM migrations via CLI
  • migration:revert — revert last migration via CLI
  • migration:generate — generate a new migration via CLI
  • migration:generate:check — detect schema drift (fails if model changes exist without a migration)

Documentation

  • CONTRIBUTING.md — Added CI pipeline migration jobs, reproduction steps, and full Migration Testing section
  • README.md — Added Migrations row to CI tables and migration commands to local checks
  • docs/migrations.md — Updated TypeORM CLI command to v0.3.x syntax

Acceptance criteria

  • CI fails if any migration file produces an error
  • CI fails if model changes exist without a corresponding migration
  • Revert step confirms migrations are reversible

…afcode#840)

- Add PostgreSQL service container to CI workflow
- Add migration:run step to apply TypeORM migrations and fail on errors
- Add migration:revert step to confirm migrations are reversible
- Add migration:generate:check step to detect schema drift
- Add src/config/datasource.ts for TypeORM CLI usage
- Add migration scripts to package.json (migration:run, migration:revert, migration:generate, migration:generate:check)
- Update CONTRIBUTING.md with migration testing instructions
- Update README.md CI tables with migration stage
- Update docs/migrations.md to use TypeORM 0.3.x CLI syntax
@drips-wave

drips-wave Bot commented Jul 25, 2026

Copy link
Copy Markdown

@EmeditWeb Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@RUKAYAT-CODER

Copy link
Copy Markdown
Contributor

Well done on the job done so far!
Kindly fix your workflow to pass.

@EmeditWeb

Copy link
Copy Markdown
Author

alright, I'd fix it

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.

Add automated database migration dry-run step to CI pipeline

2 participants