Changed so forced upgrade includes dropping tables

This commit is contained in:
Ziver Koc 2021-07-12 00:35:57 +02:00
parent dbed0b91db
commit f4f52e997b

View file

@ -66,7 +66,7 @@ public class DBUpgradeHandler {
} }
/** /**
* Will create a rename mapping where an existing table will be renamed. * Will create a rename mapping where an existing table will be renamed to the given new name.
* *
* @param oldTableName current name of the table * @param oldTableName current name of the table
* @param newTableName new name that old table will be renamed to. * @param newTableName new name that old table will be renamed to.
@ -83,9 +83,11 @@ public class DBUpgradeHandler {
} }
/** /**
* With the default behaviour unnecessary columns will not be removed. * With the default behaviour no longer existing columns and tables will
* But if forced upgrade is set to true then the upgrade handler will * not be removed.
* create a new table and migrate the data from the old one to the new table. * If forced upgrade is set to true then the upgrade handler will
* create a new table and migrate over the data from the old to the
* new table and finally remove the old table.
* *
* @param enable true to enable forced upgrade * @param enable true to enable forced upgrade
*/ */
@ -101,9 +103,11 @@ public class DBUpgradeHandler {
upgradeRenameTables(); upgradeRenameTables();
upgradeCreateTables(); upgradeCreateTables();
upgradeDropTables();
upgradeAlterTables(); upgradeAlterTables();
if (forceUpgradeEnabled)
upgradeDropTables();
logger.fine("Committing upgrade transaction..."); logger.fine("Committing upgrade transaction...");
target.getConnection().commit(); target.getConnection().commit();
} catch(SQLException e) { } catch(SQLException e) {
@ -261,7 +265,7 @@ public class DBUpgradeHandler {
new TableStructureResultHandler()); new TableStructureResultHandler());
} }
private static class DBColumn{ private static class DBColumn {
String name; String name;
String type; String type;
boolean notNull; boolean notNull;