Disclosure: I build Schemity , a desktop ERD tool - this post is from our blog and uses it for the examples.
TL;DR: A CI job can tell which migration statements lose data, can fail on existing rows, or rewrite and lock a table without connecting to anything, as long as it rebuilds the schema from the older migrations in the repo first. The same ALTER COLUMN email TYPE varchar(120) rewrites the table when the column was text and changes nothing on disk when it was varchar(100) , so the statement alone cannot say which. Row counts and table sizes still need a live connection.
A CI job can check a database migration without a database: rebuild the schema from the older migrations in the repo, then read each new statement against it. That is enough to say which statements drop data, which can fail on rows already in the table, which rewrite or lock it, and which add a design problem such as a foreign key with no index.…