File tree Expand file tree Collapse file tree 1 file changed +11
-9
lines changed
core/src/main/java/com/github/games647/fastlogin/core/storage Expand file tree Collapse file tree 1 file changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -73,14 +73,21 @@ protected void createTables() throws SQLException {
7373 }
7474 }
7575
76- protected int getTableVersion (String table ) {
76+ protected int getTableVersion (MigratableStorage table ) {
7777 try (Connection con = storage .getDataSource ().getConnection ();
7878 PreparedStatement loadStmt = con .prepareStatement (LOAD_TABLE_VERSION )) {
79- loadStmt .setString (1 , table );
79+ loadStmt .setString (1 , table . getTableName () );
8080
8181 try (ResultSet resultSet = loadStmt .executeQuery ()) {
8282 if (resultSet .next ()) {
83- return resultSet .getInt (1 );
83+ int version = resultSet .getInt (1 );
84+
85+ // special case: table premium was created before the migration manager
86+ if (version == 0 && "premium" .equals (table .getTableName ()) && table .tableExists ()) {
87+ version = 1 ;
88+ }
89+
90+ return version ;
8491 }
8592 }
8693 } catch (SQLException sqlEx ) {
@@ -91,12 +98,7 @@ protected int getTableVersion(String table) {
9198 }
9299
93100 protected void migrateTable (MigratableStorage table ) {
94- int initialVersion = getTableVersion (table .getTableName ());
95-
96- // special case: table premium was created before the migration manager
97- if (initialVersion == 0 && "premium" .equals (table .getTableName ()) && table .tableExists ()) {
98- initialVersion = 1 ;
99- }
101+ int initialVersion = getTableVersion (table );
100102
101103 for (int i = initialVersion ; i < table .getLatestTableVersion (); i ++) {
102104 core .getPlugin ().getLog ().info ("Starting database migration of table {} to version {}" ,
You can’t perform that action at this time.
0 commit comments