fix(migrations): reconcile entity/migration drift so the schema drift check passes strictly - #1212
Merged
RUKAYAT-CODER merged 1 commit intoAug 17, 2026
Conversation
…schema check Align entity definitions with the schema produced by the migrations so that migration:generate reports zero drift: - Add columns to entities that migrations create but entities omit (users localization fields, user_preferences currency, course currency/search_vector, audit_logs version, course_bulk_operations undo/notes/reason/version). - Name entity indexes to match the explicit index names the migrations use, and match column types (timestamptz) and FK delete rules. - Register the course.search_vector generated column metadata. - Add a reconciliation migration that aligns the remaining drift (indexes, FK constraint names, enum values, bulk-operation columns). - Remove the known-drift snapshot and make drift-check.sh fail on any drift, so model changes without a migration are caught in CI.
Contributor
|
Thank you for contributing to the project |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Reconciles the pre-existing drift between the entity definitions and the schema produced by the migrations so
migration:generate --checkreports zero drift, then removes thescripts/known-drift.txtsnapshot tolerance and makes the drift check strict again.What changed
userslocalization fields (country,country_code,timezone,city,preferred_currency),user_preferences.currency,course.currency+ canonicalsearch_vectorcolumn,audit_logs.version,course_bulk_operations(undone_by_id,reason,notes,version).IDX_users_createdAt,IDX_course_category,IDX_audit_logs_*, grading/gamification/forum indexes) so no indexes are silently dropped.timestamptzfor audit/grading timestamps) and FK delete rules (messages,schema_change) to the migrations.tier_enumtype name on the gamification entities viaenumName.1796000000000-reconcile-schema-drift) that creates the entity-declared indexes missing from the database, renames FK constraints to their entity-generated names, extends theaudit_logs.actionenum values, and backfills the missingcourse_bulk_operationscolumns.scripts/known-drift.txtand updatedscripts/drift-check.shto fail on any entity/migration drift.Verification
pnpm run migration:runon a fresh Postgres ✔pnpm run migration:generate:check→ "No schema drift" ✔pnpm run migration:revert✔pnpm run lint:ci,pnpm run typecheck,pnpm run build✔Closes #1194