Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Squash / clean up (old) migrations #4973

Merged
merged 10 commits into from
Dec 30, 2024

Conversation

sergei-maertens
Copy link
Member

@sergei-maertens sergei-maertens commented Dec 27, 2024

Part of 3.0 release prep, #4920

Changes

  • Removed the RunPython operations that have run in 2.8
  • Fixed the upgrade path definitions, there was some duplication
  • Squashed migrations in various apps, cleaning up some migration cruft along the way

Tested on:

  • dev environment which was on latest master
  • fresh instance to simulate a new 3.0 instance without prior migrations
  • dump of one of the 2.8.x test environments to simulate upgrading from an existing instance

Checklist

Check off the items that are completed or not relevant.

  • Impact on features

    • Checked copying a form
    • Checked import/export of a form
    • Config checks in the configuration overview admin page
    • Problem detection in the admin email digest is handled
  • Release management

    • I have labelled the PR as "needs-backport" accordingly
  • I have updated the translations assets (you do NOT need to provide translations)

    • Ran ./bin/makemessages_js.sh
    • Ran ./bin/compilemessages_js.sh
  • Dockerfile/scripts

    • Updated the Dockerfile with the necessary scripts from the ./bin folder
  • Commit hygiene

    • Commit messages refer to the relevant Github issue
    • Commit messages explain the "why" of change, not the how

Squashed all migrations into a single operation. Requires 2.8.0 to have
been run (which is enforced by the upgrade checks).

Once 3.0 is released, the original migrations can be removed.
Replaced some RunPython operations that are guaranteed to have been
run on Open Forms 2.8.x with empty operations so that we can
properly optimize migrations during squashing.
Manually commented out some of the RunPython to hopefully better
optimize the squashed migration, and added those operations back in
to the squashed migration (mostly the resetting of the default template
translations which is a workaround).

The update_summary_tags in the original migration now imports the
definition from the squashed migration rather than not executing it
at all, as some dev-environments might miss this step if they pull
master not frequently enough.

This migration can be further optimized by hand, see the next commit.
Due to the forward-ports we ended up with multiple merge migrations
each overlapping a bit, and 0063 brought them all together.

Squashmigrations can only handle a single branch of migrations and
left out the forward-ported migrations 0059 and 0062. These can
safely be included manually as well, as they basically only update
the model state in migrations.
Similar to the config app, migrations were squashed and some merge
migrations were involved, but this time Django picked it up correctly.

The price logic rules conversion was moved and in the original migration
a dynamic import is now used instead to avoid duplicating the
implementation.
Copy link

codecov bot commented Dec 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.65%. Comparing base (dbd9a35) to head (7d6be9c).
Report is 15 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4973   +/-   ##
=======================================
  Coverage   96.65%   96.65%           
=======================================
  Files         762      762           
  Lines       25935    25935           
  Branches     3391     3391           
=======================================
  Hits        25067    25067           
  Misses        604      604           
  Partials      264      264           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

The Objects API group config model was moved from the registrations app
to the general purpose contrib app for the Objects API, as it is used
by both prefill and registration plugins. This involved some dark
migrations magic with SeparateDatabaseAndState to move the model
without breaking the existing table or messing with table names.

Now that we're guaranteed existing instances have upgrade to 2.8, we
know that the tables are properly in the right place and the necessary
migrations have been executed, allowing us to turn them into normal
migrations so that fresh installs can take the direct path rather than
the detour, and it allows us to clean up some migration code.

The rest of the migrations in the contrib app are not yet squashed, as
they are primarly operations around RunPython that need to be executed
on 3.0 instances.
Squashed all migrations since 2.3.0 into a single file, optimizing
away some in-between states for refactors that happened along
the way.

RunPython operations have been emptied since they're guaranteed
to have run on OF 2.8.x, per the upgrade requirements.
These have never been squashed before. Only the migrations before 3.0
are squashed, as the migrations in 3.0 contain mostly RunPython
operations that still need to be executed.
@sergei-maertens sergei-maertens force-pushed the release/4920-3.0-squash-migrations branch from 009eec8 to a2d8e48 Compare December 27, 2024 16:17
We require users to be on OF 2.8 before they can upgrade to 3.0
@sergei-maertens sergei-maertens marked this pull request as ready for review December 27, 2024 17:10
@sergei-maertens sergei-maertens merged commit eeae60c into master Dec 30, 2024
35 checks passed
@sergei-maertens sergei-maertens deleted the release/4920-3.0-squash-migrations branch December 30, 2024 08:43
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