feat(db): name the tables and columns the database lacks on every start

After the migrations, both engines compare the declared entities with the
live schema in one catalog statement and log a warning naming each table or
column that is missing, what fails because of it, and that it should be
reported. It never refuses a start, not even when the check itself fails,
and says nothing on a database the migrations built; a Postgres lane suite
holds that on a real server.
This commit is contained in:
Maurice
2026-11-18 15:22:36 +01:00
parent ca7cdcebcc
commit 771dab7c35
6 changed files with 273 additions and 2 deletions
+16
View File
@@ -35,3 +35,19 @@ export function tableExistsSql(platform: Platform): string {
*/
export const CURRENT_SCHEMA_TABLES_SQL =
'select table_name from information_schema.tables where table_schema = current_schema() order by table_name';
/**
* Every column of every table, one `table_name` and `name` per row: the
* whole schema in one statement, for the boot's check that each column the
* entities map exists (`db/schema-gaps.ts`). Postgres reads the current
* schema only, as above.
*/
export function tableColumnsSql(platform: Platform): string {
if (isSqlite(platform)) {
return "select m.name as table_name, p.name as name from sqlite_master m join pragma_table_info(m.name) p where m.type = 'table'";
}
if (isPostgres(platform)) {
return 'select table_name, column_name as name from information_schema.columns where table_schema = current_schema()';
}
return unsupported(platform);
}