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

Add "./dspace database skip" command to optionally skip older migrations #8611

Merged
merged 1 commit into from Jan 11, 2023

Conversation

tdonohue
Copy link
Member

@tdonohue tdonohue commented Dec 13, 2022

References

Several users have encountered issues with older, ignored 5.7.* migrations (specifically 5.7.2017.04.11 and 5.7.2017.05.05) when running the ./dspace database migrate ignored command to upgrade from 6.x to 7.x.

Description

Adds the ./dspace database skip [version] command, which allows you to skip applying a single ("Pending" or "Ignored") migration. Behind the scenes, this command tells Flyway that the skipped migration has already been run. Therefore, once a migration is skipped, it will not be run again in the future.

This PR looks larger than it really is, as I also refactored DatabaseUtils.main() to use a switch instead of a series of if/else if statements -- this makes the code much more readable. But, git seems to think I modified most of the main() method, when I've just realigned code to fit within the switch / case statements.

Instructions for Reviewers

  1. The easiest way to test this new ./dspace database skip [version] command is to find a database which has not run either the 5.7.2017.04.11 or 5.7.2017.05.05 migrations.
  2. Use ./dspace database info to verify one (or both) of the 5.7 migrations appear in the "Ignored" state.
  3. Attempt to run ./dspace database migrate ignored on the database to upgrade to 7.x. You will receive errors for both the 5.7.2017.04.11 or 5.7.2017.05.05 migrations. Both of these migrations are no longer valid in 7.x, and are considered obsolete.
  4. Run the ./dspace database skip [version] command to skip each 5.7 migration:
./dspace database skip "5.7.2017.04.11"
./dspace database skip "5.7.2017.05.05"
  1. Using ./dspace database info again, verify that both of these migrations are now set to "Out Of Order" state (which means they are considered successfully run, but run out of numerical order)
  2. Try the migration again: ./dspace database migrate ignored. This time, it will succeed.

I've tested this entire scenario using the example database above. I've verified it allows users to get past these failing, ignored migrations.

@tdonohue tdonohue added bug high priority interface: command-line DSpace CLI (command-line interface) backend: FlywayDB Related to database migrations or Flyway labels Dec 13, 2022
@tdonohue tdonohue added this to the 7.5 milestone Dec 13, 2022
@tdonohue tdonohue self-assigned this Dec 13, 2022
@tdonohue tdonohue added the 1 APPROVAL pull request only requires a single approval to merge. label Dec 15, 2022
Copy link
Contributor

@corrad82-4s corrad82-4s left a comment

Choose a reason for hiding this comment

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

Hi @tdonohue , I have been able to test this PR and all run as expected and described. No remarks from my side

@tdonohue tdonohue merged commit c4efe41 into DSpace:main Jan 11, 2023
@tdonohue tdonohue deleted the add_database_skip branch January 11, 2023 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1 APPROVAL pull request only requires a single approval to merge. backend: FlywayDB Related to database migrations or Flyway bug high priority interface: command-line DSpace CLI (command-line interface)
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants