diff --git a/alembic/legacy.py b/alembic/legacy.py index a0f2f3d3..d5cbf421 100644 --- a/alembic/legacy.py +++ b/alembic/legacy.py @@ -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 diff --git a/student-tests/api/test_migrations.py b/student-tests/api/test_migrations.py index d0dd2608..6dc97cc7 100644 --- a/student-tests/api/test_migrations.py +++ b/student-tests/api/test_migrations.py @@ -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'",