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

Improve repository migration script #296

Merged
merged 25 commits into from
Feb 4, 2022
Merged

Conversation

njohner
Copy link
Contributor

@njohner njohner commented Jan 27, 2022

To finally get a few benefits, I had to modify the migration script quite a bit. Before we were generating a mapping of old and new positions in the order of the rows in the excel file and at the same time analysing the corresponding operation. This made the whole script very sensitive to operation ordering in the excel file, and defining the correct order was really not always easy (as the operations themselves actually happen in the order create, move, merge). Moreover we were sometimes using positions (i.e. reference numbers) to identify the parents (for example for creation operations). All the creation operations happening first, can lead to temporarily having 2 repository folders with the same reference number (e.g. are creating a new repofolder having the same number as an already existing one which will be moved later in the migration), which in turn would lead to issues identifying the correct parent in other creation operations. To solve these issues (and also better identify some move operations), we now:

  • assign a guid to all existing repository folders
  • construct two mappings:
    • old (initial) positions to its guid
    • new (final) positions to their guid (we assign a guid here to positions that will be created later)
  • Once this is done we go a second time over all the rows in the excel and identify to what operation it will correspond

With this it is easier to correctly identify different operation types and the identification is less dependent on the order in the excel file.

Also note that I've updated the corresponding tests in opengever.core, to make sure the migration script was still working as before and added a new test for the newly supported edge cases (see 4teamwork/opengever.core#6792, last 5 commits)

For https://4teamwork.atlassian.net/browse/CA-3245 and https://4teamwork.atlassian.net/browse/CA-3243

Niklaus Johner added 17 commits January 25, 2022 12:20
We will need these to unequivocally identify the correct parent
to create new repository folders in.
This approach has several advantages:
- it does not depend on operation order
- it will allow to correctly handle some cases of position
  creation where the bundle import would fail because it finds
  several positions with the same reference number. The mapping
  will allow to use the GUIDs in the bundle instead of the reference
  number.
For example position 11, if the parent (position 1) is moved to
a different position and a new repository folder is created with
reference number 1, we would need to move position 11 in order
for it to remain 11.
@njohner njohner changed the title Nj/ca 3243/improve repo migrator Improve repository migration script Jan 28, 2022
@njohner njohner marked this pull request as ready for review January 28, 2022 09:30
@njohner njohner requested a review from a team January 28, 2022 09:30
Copy link
Member

@elioschmutz elioschmutz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@njohner njohner force-pushed the nj/CA-3243/improve_repo_migrator branch from 4841c86 to 58c49da Compare January 31, 2022 11:01
This notably allows to correctly reindex objects that are in the
trash.
@njohner njohner merged commit 024b20a into master Feb 4, 2022
@njohner njohner deleted the nj/CA-3243/improve_repo_migrator branch February 4, 2022 09:18
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.

None yet

2 participants