Skip to content

fix(migrations): log loud warnings on down() for irreversible data migrations - #1387

Open
cythecode wants to merge 1 commit into
rinafcode:mainfrom
cythecode:fix/irreversible-migrations-down-warning-issue-1207
Open

fix(migrations): log loud warnings on down() for irreversible data migrations#1387
cythecode wants to merge 1 commit into
rinafcode:mainfrom
cythecode:fix/irreversible-migrations-down-warning-issue-1207

Conversation

@cythecode

Copy link
Copy Markdown

Overview

Adds explicit loud warnings (console.warn) to down() in irreversible data migrations and extension initializers so that migration:revert outputs an honest status instead of silently doing nothing, and documents all non-reversible migrations in the migrations README.

Related Issue

Closes #1207

Changes

Migrations

  • [MODIFY] src/migrations/1600000000000-enable-uuid-ossp.ts
    • Added loud warning in down() stating that the uuid-ossp extension is retained as other objects depend on it.
  • [MODIFY] src/migrations/1783000000000-clear-plaintext-auth-tokens.ts
    • Added loud warning in down() noting that cleared plaintext tokens cannot be recovered.
  • [MODIFY] src/migrations/1783000000001-reencrypt-oauth-provider-tokens.ts
    • Added loud warning in down() noting that AES-GCM encrypted OAuth provider tokens cannot be reverted to plaintext.
  • [MODIFY] src/migrations/1783000000006-clear-legacy-bcrypt-refresh-tokens.ts
    • Added loud warning in down() stating that legacy bcrypt hashes cannot be restored.
  • [MODIFY] src/migrations/1790000000000-add-paused-subscription-status.ts
    • Added loud warning in down() noting that PostgreSQL does not support dropping enum values.
  • [MODIFY] src/migrations/1791000000001-fix-forum-anonymous-author.ts
    • Added loud warning in down() noting that purged anonymous forum votes and flagged statuses cannot be reconstructed.
  • [MODIFY] src/migrations/README.md
    • Added "Non-reversible and data migrations" section documenting reasons for no-op/partial rollbacks and the loud warning rule.
  • [MODIFY] docs/migrations.md
    • Updated best practices table to mention loud warnings for irreversible migrations.
  • [ADD] src/migrations/irreversible-migrations.spec.ts
    • Added unit test suite asserting down() emits the expected loud warnings across all irreversible migrations.

Verification Results

$ jest src/migrations/irreversible-migrations.spec.ts
PASS src/migrations/irreversible-migrations.spec.ts
  Irreversible migrations down() loud warnings (Issue #1207)
    ✓ 1600000000000-enable-uuid-ossp logs a loud warning in down() (4 ms)
    ✓ 1783000000000-clear-plaintext-auth-tokens logs a loud warning in down() (1 ms)
    ✓ 1783000000001-reencrypt-oauth-provider-tokens logs a loud warning in down()
    ✓ 1783000000006-clear-legacy-bcrypt-refresh-tokens logs a loud warning in down()
    ✓ 1790000000000-add-paused-subscription-status logs a loud warning in down() (1 ms)
    ✓ 1790000000001-fix-invoice-number-sequence logs a loud warning in down() (1 ms)
    ✓ 1791000000001-fix-forum-anonymous-author logs a loud warning in down()

Test Suites: 1 passed, 1 total
Tests:       7 passed, 7 total

$ node scripts/validate-migrations.js
PASS: All 38 migration files use only the passed queryRunner

$ tsc --project tsconfig.build.json --noEmit
Passed with 0 errors.
Acceptance Criteria Status
Irreversible migrations emit loud warnings in down() ✅ All no-op / data migrations log descriptive warning messages
Documented list in migrations README ✅ Comprehensive table added to src/migrations/README.md
Automated unit tests verify warning behavior ✅ 7 unit tests covering all irreversible migrations pass
Shared transaction rule preserved validate-migrations.js passes with 0 violations

…grations

- Log explicit warnings in down() for non-reversible data migrations and retained extensions
- Document list of non-reversible/partial-rollback migrations in src/migrations/README.md
- Add unit tests verifying down() loud warning behavior across all irreversible migrations

Closes rinafcode#1207
Copilot AI lite review requested due to automatic review settings August 30, 2026 02:07
@drips-wave

drips-wave Bot commented Aug 30, 2026

Copy link
Copy Markdown

@cythecode 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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@RUKAYAT-CODER

Copy link
Copy Markdown
Contributor

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

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.

Irreversible data migrations have no-op down() — migration:revert silently does nothing

3 participants