Skip to content

Skip database integrity checks for tables that have managedMigration: false #5730

Closed

Description

@marcelomendoncasoares

Describe the bug

Tables declared with managedMigration: false are correctly excluded from Serverpod's migration generation, but are still included in the runtime database integrity check.

This makes the behavior of managedMigration: false inconsistent: Serverpod does not manage the table's schema lifecycle, but still requires the live schema to conform to what Serverpod can represent in its model.

For example, adding a manually managed expression index to an unmanaged table causes the integrity check to report the index as missing from the model and prevents the server from starting in development mode.

To reproduce

  1. Define a table with migrations disabled:
class: Example
table: example
managedMigration: false
fields:
  name: String
  1. Create the table manually in PostgreSQL.

  2. Add a database object that is not represented in the Serverpod model, for example an expression index:

CREATE INDEX example_lower_name_idx
ON example (LOWER(name));
  1. Start the Serverpod server in development mode.

  2. The database integrity check reports a schema mismatch for example_lower_name_idx even though the table has explicitly opted out of Serverpod-managed migrations.

Expected behavior

Tables with managedMigration: false should be excluded from database migration integrity validation, consistently with how they are excluded from migration generation.

Users opting out of managed migrations for a table are taking responsibility for manually defining and maintaining that table's database schema.

Optionally, Serverpod could still validate the subset of the schema that the ORM depends on, such as the presence and compatible types/nullability of columns declared in the model. However, additional columns, indexes, foreign keys, or other database objects on a managedMigration: false table should not cause integrity validation to fail, since those are explicitly outside Serverpod's migration ownership.

Library version

Serverpod 4.0.0

Platform information

N/A

Additional context

Migration generation already filters unmanaged tables. For example, generateDatabaseMigration() filters both source and target definitions using table.isManaged.

However, MigrationManager.verifyDatabaseIntegrity() currently gets all target table definitions and verifies each one:

var targetTables = session.db.analyzer.getTargetTableDefinitions();

for (var table in targetTables) {
  ...
}

TableDefinition already contains the managed flag, so the integrity check could apply the same semantics, e.g.:

for (var table in targetTables.where((table) => table.managed != false)) {
  ...
}

This is also related to #4743, but is a separate issue. A scoped-ignore mechanism is useful when a table is still managed by Serverpod but contains a few custom database objects. For a table explicitly marked managedMigration: false, no per-element ignores should be necessary.

The current behavior was also independently reported in #4743: an unmanaged table containing a manually created partial index still fails database integrity validation.

How experienced are you with this library?

Expert - Experienced and comfortable with using this library in complex projects

Are you interested in working on a PR for this?

  • I want to work on this

Activity

  1. added
    bug
    area: migrations
    on Sep 18, 2026
  2. moved this from Inbox 📫 to In Progress 🔥 in Serverpod Frameworkson Sep 22, 2026
  3. moved this from In Progress 🔥 to Done 🚀 in Serverpod Frameworkson Sep 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area: migrationsbug

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions