Move all Flyway SQL migrations to 'dspace-api.jar' to discourage running them manually.

This commit is contained in:
Tim Donohue
2014-11-06 15:52:10 -06:00
parent 5fb04adec9
commit 9bfa417f18
42 changed files with 32 additions and 31 deletions

View File

@@ -267,18 +267,22 @@ public class DatabaseUtils
DatabaseMetaData meta = connection.getMetaData(); DatabaseMetaData meta = connection.getMetaData();
// NOTE: we use "findDbKeyword()" here as it won't cause // NOTE: we use "findDbKeyword()" here as it won't cause
// DatabaseManager.initialize() to be called (which in turn auto-calls Flyway) // DatabaseManager.initialize() to be called (which in turn auto-calls Flyway)
String scriptFolder = DatabaseManager.findDbKeyword(meta); String dbType = DatabaseManager.findDbKeyword(meta);
connection.close(); connection.close();
// Determine location(s) where Flyway will load all DB migrations // Determine location(s) where Flyway will load all DB migrations
ArrayList<String> scriptLocations = new ArrayList<String>(); ArrayList<String> scriptLocations = new ArrayList<String>();
// First, add location of SQL migrations (based on DB Type) // First, add location for custom SQL migrations, if any (based on DB Type)
// e.g. [dspace.dir]/etc/[dbtype]/ // e.g. [dspace.dir]/etc/[dbtype]/
scriptLocations.add("filesystem:" + ConfigurationManager.getProperty("dspace.dir") + scriptLocations.add("filesystem:" + ConfigurationManager.getProperty("dspace.dir") +
"/etc/migrations/" + scriptFolder); "/etc/" + dbType);
// Next, add the Java package where Flyway will load Java migrations from // Also add the Java package where Flyway will load SQL migrations from (based on DB Type)
scriptLocations.add("classpath:org.dspace.storage.rdbms.sqlmigration." + dbType);
// Also add the Java package where Flyway will load Java migrations from
// NOTE: this also loads migrations from any sub-package
scriptLocations.add("classpath:org.dspace.storage.rdbms.migration"); scriptLocations.add("classpath:org.dspace.storage.rdbms.migration");
// Special scenario: If XMLWorkflows are enabled, we need to run its migration(s) // Special scenario: If XMLWorkflows are enabled, we need to run its migration(s)

View File

@@ -9,9 +9,8 @@ By default, the DSpace Unit Testing environment configures H2 to run in
These database migrations are automatically called by [Flyway](http://flywaydb.org/) These database migrations are automatically called by [Flyway](http://flywaydb.org/)
when the `DatabaseManager` initializes itself (see `initializeDatabase()` method). when the `DatabaseManager` initializes itself (see `initializeDatabase()` method).
The H2 migrations in this directory are *based on* the Oracle Migrations The H2 migrations in this directory are *based on* the Oracle Migrations, but
(`[src]/dspace/etc/migrations/oracle/*.sql`), but with some modifications in with some modifications in order to be valid in H2.
order to be valid in H2.
## Oracle vs H2 script differences ## Oracle vs H2 script differences

View File

@@ -1,25 +1,24 @@
# DSpace Database Now Upgrades Automatically # DSpace Database Now Upgrades Automatically
AS OF DSPACE 5.0, the DSpace database now upgrades itself AUTOMATICALLY. AS OF DSPACE 5, the DSpace database now upgrades itself AUTOMATICALLY.
Therefore, all `database_schema*.sql` files have been removed. Starting Therefore, all `database_schema*.sql` files have been removed. Starting
with DSpace 4.x -> 5.0 upgrade, you will no longer need to manually run any with DSpace 4.x -> 5.0 upgrade, you will no longer need to manually run any
SQL scripts to upgrade your database. SQL scripts to upgrade your database.
However, if you have not yet upgraded to DSpace 4.x, YOU MUST MANUALLY DO SO. Please see the [5.0 Upgrade Instructions](https://wiki.duraspace.org/display/DSDOC5x/Upgrading+to+5.x)
Those manual `database_schema*.sql` scripts can still be found in the for more information on upgrading to DSpace 5.
DSpace 4.x source code at:
https://github.com/DSpace/DSpace/tree/dspace-4_x/dspace/etc/oracle/
## More info on automatic database upgrades (for developers) ## More info on automatic database upgrades
As of DSpace 5.0, we now use [Flyway DB](http://flywaydb.org/) along with As of DSpace 5.0, we now use [Flyway DB](http://flywaydb.org/) along with the
the scripts under `[dspace]/etc/migrations/oracle` to automatically keep your SQL scripts embedded in the `dspace-api.jar` to automatically keep your DSpace
DSpace database up-to-date. database up-to-date. These scripts are now located in the source code at:
`[dspace-src]/dspace-api/src/main/java/resources/org/dspace/storage/rdbms/sqlmigration/oracle`
As Flyway automates the upgrade process, you should NEVER run these scripts As Flyway automates the upgrade process, you should NEVER run these SQL scripts
manually. For more information, please see the `README` in the scripts directory. manually. For more information, please see the `README.md` in the scripts directory.
## Using the update-sequences.sql script ## Using the update-sequences.sql script
@@ -31,4 +30,4 @@ feature).
This `update-sequences.sql` script can be run manually. It will not harm your This `update-sequences.sql` script can be run manually. It will not harm your
database (or its contents) in any way. It just ensures all database counts (i.e. database (or its contents) in any way. It just ensures all database counts (i.e.
sequences) are properly set to the next available value. sequences) are properly set to the next available value.

View File

@@ -1,25 +1,24 @@
# DSpace Database Now Upgrades Automatically # DSpace Database Now Upgrades Automatically
AS OF DSPACE 5.0, the DSpace database now upgrades itself AUTOMATICALLY. AS OF DSPACE 5, the DSpace database now upgrades itself AUTOMATICALLY.
Therefore, all `database_schema*.sql` files have been removed. Starting Therefore, all `database_schema*.sql` files have been removed. Starting
with DSpace 4.x -> 5.0 upgrade, you will no longer need to manually run any with DSpace 4.x -> 5.0 upgrade, you will no longer need to manually run any
SQL scripts to upgrade your database. SQL scripts to upgrade your database.
However, if you have not yet upgraded to DSpace 4.x, YOU MUST MANUALLY DO SO. Please see the [5.0 Upgrade Instructions](https://wiki.duraspace.org/display/DSDOC5x/Upgrading+to+5.x)
Those manual `database_schema*.sql` scripts can still be found in the for more information on upgrading to DSpace 5.
DSpace 4.x source code at:
https://github.com/DSpace/DSpace/tree/dspace-4_x/dspace/etc/postgres/
## More info on automatic database upgrades ## More info on automatic database upgrades
As of DSpace 5.0, we now use [Flyway DB](http://flywaydb.org/) along with As of DSpace 5.0, we now use [Flyway DB](http://flywaydb.org/) along with the
the scripts under `[dspace]/etc/migrations/oracle` to automatically keep your SQL scripts embedded in the `dspace-api.jar` to automatically keep your DSpace
DSpace database up-to-date. database up-to-date. These scripts are now located in the source code at:
`[dspace-src]/dspace-api/src/main/java/resources/org/dspace/storage/rdbms/sqlmigration/postgres`
As Flyway automates the upgrade process, you should NEVER run these scripts As Flyway automates the upgrade process, you should NEVER run these SQL scripts
manually. For more information, please see the `README` in the scripts directory. manually. For more information, please see the `README.md` in the scripts directory.
## Using the update-sequences.sql script ## Using the update-sequences.sql script