post_migrate
signal handler instead.elidable=True
.
pulpcore-manager squashmigrations
will skip them because there is no data to expect anyway.see Django docs
Squashing is meant to be a two step process in django:
CreateModel
and some extra steps for foreign keys and indices.Step one should be safe for Pulp at any time in core and in plugins.
Step two is problematic.
You cannot repeat step one without step two:
CommandError: You cannot squash squashed migrations! Please transition it to a normal migration first: https://docs.djangoproject.com/en/3.2/topics/migrations/#squashing-migrations
Should we start by squashing all migrations for a release? Probably not.
default
values.0001_...
to one more than the last existing migration, django will continue to count from there for future migrations.
Plugin migrations depend on pulpcore migrations.
But migrations may only be deleted once there are no more dependencies.
In general a plugin must be installable after all pulpcore migrations have run.
Note: With deleting migrations we loose the possibility to upgrade from everywhere.
Squashing the migration in plugins no other plugins depend on should be much simpler.
Plan:
pulpcore 3.25
0001_initial
...
0020
0001_squashed_0020 # "squashed migration"
0021_release_3.25 # plugin depend on this once they declare pulpcore>=3.25,<3.30
pulpcore 3.30
0001_squashed_0020 # rewritten to be a "normal migration" (ie loses 'replace' stmts)
0021_release_3.25 # plugins can still depend on this (will be removed in 3.35)
0022
...
0030
0001_squashed_0030 # "squashed migration"
0031_release_3.30 # plugin depend on this once they declare pulpcore>=3.30,<3.35
pulpcore 3.35
0001_squashed_0030 # rewritten to be a "normal migration"
0031_release_3.30 # plugins can still depend on this (will be removed in 3.40)
0032
...
0040
0001_squashed_0040 # "squashed migration"
0041_release_3.35 # plugin depend on this once they declare pulpcore>=3.35,<3.40
There is an experiment to manipulate migrations as needed for this process:
https://github.com/mdellweg/pulpcore/tree/migration_tools
Django 4.1 ships its own optimizemigration command.