Repository navigation
fix: Restore two-way table comparison in the database integrity check - #5800
Merged
FXschwartz merged 2 commits intoOct 1, 2026
Merged
Conversation
|
All contributors have signed the CLA ✍️ ✅ |
Contributor
Author
|
I have read the CLA Document and I hereby sign the CLA |
FXschwartz
requested changes
Oct 1, 2026
FXschwartz
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for picking this up! I went through the change and the reverse loops look great to me!
Just one small recommendation
FXschwartz
approved these changes
Oct 1, 2026
FXschwartz
left a comment
Collaborator
There was a problem hiding this comment.
LGTM! Great job @BiAksoy and thanks again for the quick fix.
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Before #2778,
TableDefinition.likereturned a bool and compared the number of columns, indexes and foreign keys on both sides before matching them by name, so an object present on only one side made it fail. #2778 replaced it with the detailedList<ComparisonWarning>version and dropped those counts. Since thenlikeonly walks the entries ofthis, and becauseverifyDatabaseIntegritycallsliveTable.like(table), a column, index or foreign key declared in the models but missing from the database is never reported and the server starts normally.This PR restores the two-way comparison inside
TableComparisons.like: after the existing loops, it reports the columns, indexes and foreign keys that only exist inother, using the existingisAddedstate and the same name matching as the forward loops (exact for columns, case-insensitive for indexes and foreign keys). The call sites and the labels are unchanged, as agreed in #5797; the inverted expected/found wording is handled separately.Because the live table is still the receiver, an object missing from the database is reported as added until that wording is fixed. With the test server schema after dropping
address.street,blocking_blocked_unique_idxandblocking_fk_1, and addingcat_extra_idx:Before:
After:
DatabaseBulkData.exportTableDatauses the same comparison, so the Insights export now also rejects a table that is missing a declared column, index or foreign key. Before, a missing column made it return the target definition next to rows selected from the live columns.Tests cover the added direction in the column, index and foreign key comparison tests (including index names that only differ in casing), declared columns, indexes and foreign keys missing from the database on both SQLite and PostgreSQL, matching declared indexes and foreign keys that must not warn, and the bulk data export with a missing and a matching table. The integrity and export tests only assert that the object is named, not the missing/added wording, so they hold when the labels are fixed. The full test server schemas boot without integrity warnings on PostgreSQL (179 tables, 63 foreign keys, 260 indexes including GIN, GiST, SP-GiST, BRIN, HNSW and IVFFlat) and SQLite (166 tables, 70 foreign keys, 47 indexes).
Fixes #5797.
Pre-launch Checklist
///), and made sure that the documentation follows the same style as other Serverpod documentation. I checked spelling and grammar.Breaking changes
A database that is missing a column, index or foreign key its models declare now fails the integrity check, as it did before 2.1.4. In development the server exits at startup, and since #5719 a maintenance migration run exits with code 1. The Insights bulk data export also rejects such tables.