November 22, 2026

The Truth in the Catalog: Lessons from a Mission-Critical Database Migration

In the modern landscape of web development, the promise of "managed backends" and "no-code" builders often comes with a hidden cost: the loss of direct control. For one developer operating a specialized travel directory, this trade-off recently reached a breaking point. The project, which encompasses a 750-page directory, hundreds of listings, and a meticulously maintained log of affiliate booking clicks, had reached a level of complexity where the constraints of its original environment were no longer sustainable.

The front end of the directory had long been hosted on Vercel, a standard choice for high-performance web applications. However, the heart of the operation—the database—resided within Lovable Cloud. While Lovable provides a managed backend powered by Supabase, it effectively acts as a "walled garden." Users are provided with an app builder and a query tool, but the underlying infrastructure remains largely inaccessible. There was no administrative dashboard, no direct connection string for external tools, and no ability to perform a standard pg_dump to export data. Furthermore, the limitations of the free tier meant that excessive use of the provided query tool would result in a twenty-minute lockout, a significant hurdle for any intensive data management task.

This week, the developer successfully completed a high-stakes migration, moving the entire database to a self-owned Supabase project. The process, executed with the assistance of Claude Code on a local home server, serves as a masterclass in the pitfalls of "schema drift" and the philosophical difference between a database’s recorded history and its actual state.

The migration files weren’t the database

The initial strategy for the migration seemed straightforward: replay the project’s migration history. In theory, a Supabase project’s migration folder contains a chronological record of every SQL command ever executed to shape the database. The repository in question contained 89 such files. However, theory and reality diverged almost immediately.

The automated replay process failed at file 29 due to a missing row that a subsequent command expected to find. It failed again at file 30 because of a naming conflict; a table titled favorites was being created for a second time by a different file, this time with a conflicting set of columns.

Upon closer inspection, the developer discovered a chaotic history. Of the 89 files, eighteen had been authored by hand rather than generated by the Lovable platform. Some of these manual scripts had been executed on the live database via a SQL editor and never properly integrated into the migration flow. Others had apparently never been run at all. It became clear that the migrations folder was not a factual record of the database’s evolution; it was a fragmented narrative written by multiple authors over time, none of whom had verified the story against the actual production environment.

Faced with a "story" that didn’t match the "reality," the developer pivoted to a more forensic approach. Rather than relying on the migration logs, they turned to the Postgres catalog itself. Postgres maintains an internal description of every object it houses—from tables and columns to complex triggers, security policies, and permissions. By querying the live catalog directly, the developer generated a 438-statement script that described the database exactly as it existed in its current state. This script, when executed, rebuilt the entire structure in a single, clean transaction.

To verify the accuracy of this new structure, a "fingerprinting" system was developed. By running a comprehensive query against both the old and new databases and hashing the results across eleven categories—including 439 columns, 108 constraints, 109 indexes, and 101 row-level security policies—the developer could mathematically prove the structures were identical. When all eleven hashes matched, the structural phase of the migration was deemed a success.

Rows: the checksum caught the transport

With the architecture in place, the focus shifted to the content: the listings, pages, and approximately 800 images that constitute the directory’s value. The verification method remained rigorous; for every table, the developer hashed the text of every row on both the source and the destination.