October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk3 min

Our Migration Test Passed Because the Last Job Left Its Database Behind

A successful migration job may have skipped the transition you meant to test because it inherited a database changed by an earlier run. Diagnose reuse, inspect schema and history, and verify migrations from a clean baseline.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A green migration test only proves that the migration path it actually ran succeeded against the database state the job received. If a previous job left behind a database that was already migrated—or whose schema or migration history had changed—the next job may skip the transition you intended to test. Check whether CI reuses the database, inspect both its schema and migration history, then rerun the test against a newly created database in a known starting state.

Why can a leftover database make a migration test pass?

A migration test is meaningful only relative to its starting state. If the test expects an older schema but receives a database already at the newer migration state, the migration may have nothing to do. The command can exit successfully without proving that the change works from the intended baseline.

As an Amazon Associate I earn from qualifying purchases.

That can happen when CI shares a database between jobs, restores a database volume from a cache, or preserves a test database after a run. The exact cause depends on the project’s framework and CI configuration; the title alone does not identify either.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Database lifecycle behavior is not universal. Django’s test runner normally destroys test databases after a run, but --keepdb opts into reuse, and a forced interruption can leave a test database behind. Check the project’s actual command and cleanup path rather than assuming a successful or failed job removed its database. Django documents its test database lifecycle.

How do you confirm whether the job reused stale state?

  1. Trace how CI obtains the database. Determine whether each job provisions a new database, connects to a shared one, or restores a cached or persisted volume. Review setup and teardown scripts, framework flags, and cancellation or timeout handling.
  2. Capture the starting state before migrations run. Record the schema and the migration-history records, then compare both with the baseline the test is supposed to use. An exit code alone does not reveal which starting state the job received.
  3. Check migration bookkeeping and schema separately. For EF Core, pending migrations are determined by comparing migrations in the application assembly with records in the target database. That comparison does not prove that the database’s actual schema matches those records or that it began at the intended baseline. Inspect both. EF Core explains applied and pending migration management.
  4. Repeat against a clean, disposable database. Create or reset a throwaway database to the expected starting state, apply migrations, and verify the resulting schema and any important data transformations. Supabase’s documented workflow, for example, resets the local database before applying migrations. Supabase’s migration guide shows that workflow.

What should a trustworthy migration check verify?

A reliable check validates the transition, not merely that a migration command returned successfully. It should establish the starting point, exercise the intended migration path, and verify the result.

  • Starting state: Confirm the database is new or reset to the expected baseline, not merely present and reachable.
  • Migration execution: Confirm the migrations that should run actually ran. A command that sees no pending work is not evidence that the intended transition was tested.
  • Resulting state: Assert expected schema changes and data transformations. Migration-history metadata and the physical schema are related but distinct things to validate.
  • Repeatability: Make cleanup explicit for success, failure, timeout, and cancellation so a later job cannot silently inherit state.

These checks catch different failure modes: bookkeeping can say a migration was applied when the schema is wrong, or schema changes can exist without matching migration records. GitLab documents a migration-check job that compares schema after rollback and checks generated versus committed migration history. See GitLab’s migration-check job.

How should CI handle cleanup and concurrent tests?

Prefer an isolated database for each job when practical. If a shared database is necessary, make ownership, reset behavior, and serialization explicit; otherwise, one job can alter the state another job expects.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Cleanup must also account for tests that manage transactions. EF Core describes rollback-based isolation for many database tests, but tests that manage transactions need appropriate cleanup, and tests against the same shared database should not run in parallel when that can cause interference. EF Core’s database-testing guidance covers these isolation considerations.

Rank #3
Dell PowerEdge R730xd Server 24B SFF 2U, 2X Intel Xeon E5-2690 v4 2.6Ghz (28-cores Total), 128GB DDR4 RAM, 4X 1.2TB 10K SAS 2.5” 12Gb/s HDD, H730P 2GB RAID, NIC 10Gb + I350 1Gb (Renewed)
  • Dell PowerEdge R730xd 24B SFF 2U Server
  • 2x Intel Xeon E5-2690 v4 2.6Ghz 14-Core (28-cores Total)
  • 128GB DDR4 RAM – 4x 1.2TB 10K SAS 2.5” 12Gb/s
  • Dell H730P mini 2GB 12Gb/s RAID
  • 2x 750W PSU - 2x 10Gb SFP+ 2x 1Gb (RJ45) NIC
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

What if the migration already ran on a shared database?

Do not delete migration source code as a shortcut if that migration has already been applied to shared databases. Keep the applied migration available and make a corrective migration, or coordinate a rollback that accounts for every database using it. Before applying changes to production, inspect the generated SQL script and confirm it is appropriate for the database’s current migration state: EF Core notes that scripts apply only from the appropriate migration state. EF Core’s guidance on applying migrations explains script use, while its migration-management guidance addresses managing migration history.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.