-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
DS-2167: Add Flyway automatic database upgrades to DSpace #686
Conversation
You can keep chugging away on this to finish up (assuming you've got the cycles). This seems like it could potentially help the upgrade process. Hopefully the remaining work can be accomplished in time for further testing/review, feature freeze. Also, there are ~100 PR's to review, so we'll have our hands full. |
I agree with Peter, +1 extension granted, this looks really cool, it's exactly the sort of thing that I like to see in every DSpace release. If there's anything we can do to help, just ask. |
ea7e3fb
to
2a7caee
Compare
FYI - Just rebased on latest master. Also added a commit to fix Unit Tests. The bad news is that H2 needs its own custom migrations directory ( Unfortunately, the H2 "ALTER TABLE" syntax is annoyingly different from both PostgreSQL and Oracle...and obviously "ALTER TABLE" is used heavily in DB upgrade scripts. This means that in order to support Unit Testing of our upgrade process, we will need to write custom migrations for PostgreSQL, Oracle AND H2. |
I wonder if we could actually script the PostgreSQL and Oracle upgrade script creation, and derive them both from the H2 upgrade script (don't know how exactly)? Mostly just wondering if this could be made a "good thing" instead of "yet another thing". |
I've pushed up some more enhancements which now automatically update the metadata/format registries during database upgrades, and also automatically re-indexes your content (as long as Solr is running) post-upgrade. I've modified the original description. This is now functionally "complete" for the 4.x -> 5.0 upgrade process. I'm now working on backporting older migration scripts to Flyway to hopefully support migrating 1.x version all the way to 5.0. I suspect it shouldn't take too long to get those older migrations working (fingers crossed). |
I just tried to test on Postgres. I manually upgraded a small 3.x DB to 4.x. Then I ran this PR and it errored out: 2014-10-22 11:35:00,916 ERROR org.dspace.storage.rdbms.DatabaseManager @ SQL getDataSource Error - I checked the code and it checks for the presence of the "Webapp" table. I verified that I have that in my DB. Could the problem be in case-sensitive table names? |
@helix84 - It looks like the I'm digging around for ideas for how to do this match in a case insensitive manner. All I've come up with is to load all your DB Tables into an ArrayList (or similar), lowercase them all, and then try to match against a lowercase name. |
I'm sure we're all aware, but I thought I'd just mention that Oracle "upcases" all table, row and column names. |
@helix84 - try it again. I just figured out how to tell if a database lowercases or uppercases all "identifiers" (i.e. table names, etc.). Just need to use Just pushed up a commit to check the DB defaults, and then properly lowercase or uppercase the table name search string, as necessary. I think it should work now. |
UPDATE: I've just pushed up a commit which attempts to determine which version of DSpace you are using. It needs a lot of testing, but my basic tests look to work thus far. But, unfortunately, DSpace 1.7 is difficult as it only involved a single sequence deletion. So, we may want to just update it's SQL script to check if the sequence exists before deleting it. READY FOR TESTING ON ANY / ALL UPGRADES. Let's see if this works! |
I tested it and detection of DSpace 4 db format now works. Upgrade to DSpace 5 db format also works. Congrats! There were couple of errors, I sent them your way in an email. Regarding 1.7, you can check for existence of a sequence in Postgres using the following SQL. |
I did a couple more tests on two different databases (3->5, 1.8->5, 1.6->5) and apart from some errors, it looks good (the DBs have been upgraded to 5 and schema_version seems to contain correct information). I sent the logs to Tim. One thing we need to document is that the first run of a new version of DSpace (Flyway DB upgrade) may take long, depending on DB size, so the user should check the log to see whether it completed, failed or is still running. A db of 30k items took ~16 minutes. |
This should help with detecting a sequence in Oracle: I'll be available to test again on Monday (perhaps Sunday night). |
I've reviewed the logs from @helix84. From what I can tell each of the migrations (4->5, 3->5, 1.8->5, 1.6->5) were all SUCCESSFUL (which is awesome). The errors he reported were in the post-migration processing steps, and both were minor errors:
This still needs some testing on Oracle. But, it sounds like the basics are working (with a few minor errors in post-processing that I'll work to clean up) |
I've just pushed up fixes to the two minor errors that @helix84 encountered. For now I had to turn off the auto-reindexing, as the DB Migration process runs before anything else spins up...so Solr isn't yet started, etc. |
Hi Tim, great job, the errors are now gone after I tested the 3 -> 5 upgrade. However, DSpace didn't start up after the upgrade because Solr isn't running. A manual index rebuild (-b) failed for the same reason. ERROR org.dspace.discovery.SolrServiceImpl @ Server refused connection at: http://localhost:8080/solr/search Then, after a Tomcat restart, DSpace started and shows the comm & coll structure, but the items aren't accessible due to the failed reindex (which can be fixed using -f). |
Just pushed an update to add in better commandline tools for DB actions.:
|
I'm +1, this recognized a 1.8 DB, and upgraded it to the latest. The only surprise I had was that a page load to XMLUI stalled until a discovery reindex occurred. That's probably fine though. Maybe if possible, run the reindex in the background? |
68873ce
to
7f03724
Compare
FYI for all...I've just rebased this PR on latest master (as it sounds like some folks were seeing minor errors since it wasn't fully merged to master). So, if you have this PR branch already checked out, you will need to delete that old branch and re-checkout for further testing. |
43ec26a
to
9ec3766
Compare
FYI, just rebased on "master" again as there were missing Spring configs in my branch. Again, you'll need to checkout a fresh copy of this branch. |
Hi Tim, I've managed to set up the Oracle DB VirtualBox instance, and cloned one of our Oracle clients databases onto my local setup. Here's the errors I got after tomcat restarted. dspace.log https://gist.github.com/peterdietz/0e4bed9a79c50451f736 Essentially:
|
Here's the contents of schema_version table:
Also, it's strange that schema_version and tempone are lowercase, and all the other tables are uppercase. You could use DatabaseManager.canonicalize(...) to make it match case. |
…o check for short description.
…yet exist and Solr isn't running when DB migration runs.
Scaffolding for auto-reindexing in Solr
…g test connections. Refactor DatabaseManager to move commandline tools to DatabaseUtils
…needs to be done once. Also use ConfigurationManager, since Kernel is sometimes null.
compatible databases
…ted once registry tables exist
migrations, instead create them after DB is initialized
…te a post-upgrade script for sequence updates
… ALWAYS lowercase.
… inline (after migrating from dctyperegistry to metadataschemaregistry)
3c23359
to
ed9725e
Compare
FYI, just performed a fresh "rebase" in order to prepare for merger of this code into "master" |
DS-2167: Add Flyway automatic database upgrades to DSpace
https://jira.duraspace.org/browse/DS-2167
Update: This PR is now ready to test for the 4.x -> 5.0 upgrade process. It's "functionally complete". I'm still working on backporting other migrations scripts in order to auto-migrate from old versions of the DSpace DB.
This PR does the following (unchecked boxes have not been fully implemented yet):
I've done some basic testing of upgrades from 4.0 -> 5.0 database. It seems to work well.
However, fair warning for developers: Testing this WILL REQUIRE you to start with a 4.0 compatible database. Flyway is not "smart" enough to know if you already manually ran the 'database_schema-4-5.sql" script yet...so it will attempt to run those database schema changes a second time.