For reasons better explained in another post, it would be useful to have idempotent migrations. It would:
- Allow to resume a migration that was interrupted without starting from scratch
- Make it easier to implement mirroring for issues and other aspects of a software project
- Potentially help with federation
To illustrate how it would go, I created a patch that does part of the job and passes tests, for issues and labels only:
- It adds an OriginalIndex field to the Issue table, to keep track of the Number field from the migration structure. Whenever a migration from the same origin resumes, each issue can be matched.
- The InsertIssues method is replaced with the UpsertIssues method which adds an issue if it does not already exist or updates it if it does.
- The Label and Issue creation tests are run twice to verify they are indeed idempotent
There are, of course, a lot more details to implement before this patch is ready to be reviewed or merged. I would however be very interested to hear from maintainers and owners if they have an opinion on this.