Reject legacy collation and persistence drift before adoption

This commit is contained in:
Artyom
2026-11-05 21:41:01 +03:00
parent 71c643c6d1
commit 66c614426c
2 changed files with 6 additions and 2 deletions
+4 -2
View File
@@ -17,12 +17,14 @@ SNAPSHOT = text("""
AND c.relname NOT IN ('schema_migrations', 'alembic_version')
)
SELECT 'table' AS kind, c.relname AS name,
concat_ws('|', c.relkind, c.relrowsecurity, c.relforcerowsecurity) AS definition
concat_ws('|', c.relkind, c.relpersistence,
c.relrowsecurity, c.relforcerowsecurity) AS definition
FROM relations c
UNION ALL
SELECT 'column', c.relname || '.' || a.attname,
concat_ws('|', a.attnum, format_type(a.atttypid, a.atttypmod), a.attnotnull,
a.attidentity, a.attgenerated, pg_get_expr(d.adbin, d.adrelid))
a.attidentity, a.attgenerated, a.attcollation::regcollation,
pg_get_expr(d.adbin, d.adrelid))
FROM relations c JOIN pg_attribute a ON a.attrelid = c.oid
LEFT JOIN pg_attrdef d ON d.adrelid = c.oid AND d.adnum = a.attnum
WHERE a.attnum > 0 AND NOT a.attisdropped
+2
View File
@@ -216,6 +216,8 @@ async def test_legacy_upgrade_preserves_every_row(empty_database: str, versions:
"ALTER TABLE messages DROP CONSTRAINT messages_chat_id_sender_id_fkey",
"ALTER TABLE users DROP CONSTRAINT users_username_format",
"ALTER TABLE users ALTER COLUMN display_name TYPE varchar",
'ALTER TABLE users ALTER COLUMN username TYPE text COLLATE "C"',
"ALTER TABLE sessions SET UNLOGGED",
"ALTER TABLE sessions ALTER COLUMN expires_at DROP NOT NULL",
"UPDATE schema_migrations SET checksum = 'tampered' WHERE version = '0001_init'",
"DELETE FROM schema_migrations WHERE version = '0001_init'",