Migrations were not being properly updated
This commit is contained in:
parent
e7f289d709
commit
4fefc79f5f
2 changed files with 5 additions and 3 deletions
|
@ -75,6 +75,8 @@ public class DatabaseMigrations
|
|||
PreparedStatement pstat = DatabaseWrapper.get().prepareStatement("REPLACE INTO `migrations` (tableID, version) VALUES (?,?);");
|
||||
pstat.setString(0, tableID);
|
||||
pstat.setInt(1, version);
|
||||
|
||||
pstat.execute();
|
||||
} catch (SQLException ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
|
@ -142,7 +144,7 @@ public class DatabaseMigrations
|
|||
if(lastTableChecked.tableID != m.tableID) lastTableChecked = getCurrentTable(m.tableID);
|
||||
}
|
||||
|
||||
if(m.version > lastTableChecked.version) {
|
||||
if(lastTableChecked == null || m.version > lastTableChecked.version) {
|
||||
|
||||
LibZontreck.LOGGER.info("Executing migration " + m.tableID + ":" + m.version);
|
||||
m.execute();
|
||||
|
@ -170,7 +172,7 @@ public class DatabaseMigrations
|
|||
return builder().withTableID(tableID).withVersion(result.getInt("version"));
|
||||
}
|
||||
|
||||
}catch (SQLException ex)
|
||||
}catch (Exception ex)
|
||||
{
|
||||
if(tableID == "migrations")
|
||||
{
|
||||
|
|
Reference in a new issue