Skip to content

Fix PostgresModelDataMigrator leaving the swapped-in table without privileges, stats and autovacuum - #294

Merged
Photonios merged 2 commits into
masterfrom
fix-model-data-migrator-vacuum-and-privileges
Oct 5, 2026
Merged

Photonios merged 2 commits into
masterfrom
fix-model-data-migrator-vacuum-and-privileges

Conversation

@Photonios

Copy link
Copy Markdown
Contributor

PostgresModelDataMigrator ran VACUUM ANALYZE and the autovacuum reset outside a transaction, where SET LOCAL search_path does nothing, so both hit the original table. The swapped-in table was left with autovacuum_enabled=false and no statistics. postgres_prepend_local_search_path now raises outside a transaction, like postgres_set_local already does.

The swapped-in table also lost all its privileges, because the default privileges of a schema don't apply to a table created in another schema. They are now copied right before the swap. Column privileges, and sequence privileges on Django 4.0 and older, are not copied.

@Photonios
Photonios marked this pull request as ready for review October 5, 2026 18:57
@Photonios
Photonios merged commit 8becfa3 into master Oct 5, 2026
8 checks passed
@Photonios
Photonios deleted the fix-model-data-migrator-vacuum-and-privileges branch October 5, 2026 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant