VNG-Realisatie / vng-api-common

Gedeelde code voor RESTful APIs
5 stars 12 forks source link

Resolve migration merge conflicts #201

Closed sergei-maertens closed 2 years ago

sergei-maertens commented 2 years ago

Upgrading from the 1.0.x series to 1.7.x is pretty much broken because of migration differences. Both branches contain migrations that do the same physical changes in the database (drop request_id, add logrecord_id columns). The migration files from 1.0.x were not included in the 1.7.x series, or vice versa.

This PR adds the migration files from 1.0.x into the latest release series, and a merge migration file to reconcile the migration tree. This causes problems for downstream projects upgrading from 1.0.x to latest, but also for projects that have never been on 1.0.x, as the migrations contain conflicting operations. We cannot simply update the code of one of the two migration branches, since there are projects that have performed the request_id/logrecord_id migrations, but also projects that haven't and we cannot know upfront which has what.

To solve this, custom AddField and RemoveField migration operations are defined and they replace the default operations in the migration files. Their implementation uses the schema inspector for the database used to figure out if the relevant columns still/already exist and adapt their actual database changes based on that introspection.

NOTE

I suggest merging and releasing this leads to vng-api-common 2.0 so that downstream projects can take special care testing out these changes.

sergei-maertens commented 2 years ago

Discussed and we will release this as 1.7.8

annashamray commented 2 years ago

@sergei-maertens seems to work :)