mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-03-09 21:29:12 +01:00
Fixed row_number patches when an old version added data to the database after
This commit is contained in:
parent
8c0f2b1106
commit
058b3f8d0e
@ -50,7 +50,7 @@ public class ExtensionPlayerTableValueTable {
|
||||
return CreateTableBuilder.create(TABLE_NAME, dbType)
|
||||
.column(ID, INT).primaryKey()
|
||||
.column(USER_UUID, Sql.varchar(36)).notNull()
|
||||
.column(ROW_NUMBER, INT).notNull()
|
||||
.column(ROW_NUMBER, INT).notNull().defaultValue("0")
|
||||
.column(VALUE_1, Sql.varchar(250))
|
||||
.column(VALUE_2, Sql.varchar(250))
|
||||
.column(VALUE_3, Sql.varchar(250))
|
||||
|
@ -51,7 +51,7 @@ public class ExtensionServerTableValueTable {
|
||||
return CreateTableBuilder.create(TABLE_NAME, dbType)
|
||||
.column(ID, INT).primaryKey()
|
||||
.column(SERVER_UUID, Sql.varchar(36)).notNull()
|
||||
.column(ROW_NUMBER, INT).notNull()
|
||||
.column(ROW_NUMBER, INT).notNull().defaultValue("0")
|
||||
.column(VALUE_1, Sql.varchar(250))
|
||||
.column(VALUE_2, Sql.varchar(250))
|
||||
.column(VALUE_3, Sql.varchar(250))
|
||||
|
@ -79,7 +79,7 @@ public class ExtensionTableProviderTable {
|
||||
.column(ID, INT).primaryKey()
|
||||
.column(PROVIDER_NAME, Sql.varchar(50)).notNull()
|
||||
.column(COLOR, Sql.varchar(25)).notNull().defaultValue("'" + Color.NONE.name() + "'")
|
||||
.column(VALUES_FOR, INT)
|
||||
.column(VALUES_FOR, INT).defaultValue("0")
|
||||
.column(CONDITION, Sql.varchar(54)) // 50 + 4 for "not_"
|
||||
.column(COL_1, Sql.varchar(50))
|
||||
.column(COL_2, Sql.varchar(50))
|
||||
|
@ -31,7 +31,9 @@ import java.util.Map;
|
||||
|
||||
import static com.djrapitops.plan.storage.database.sql.building.Sql.*;
|
||||
import static com.djrapitops.plan.storage.database.sql.tables.ExtensionPlayerTableValueTable.ID;
|
||||
import static com.djrapitops.plan.storage.database.sql.tables.ExtensionPlayerTableValueTable.*;
|
||||
import static com.djrapitops.plan.storage.database.sql.tables.ExtensionPlayerTableValueTable.TABLE_ID;
|
||||
import static com.djrapitops.plan.storage.database.sql.tables.ExtensionServerTableValueTable.ROW_NUMBER;
|
||||
import static com.djrapitops.plan.storage.database.sql.tables.ExtensionServerTableValueTable.TABLE_NAME;
|
||||
|
||||
public class PlayerTableValuesRowNumberPatch extends Patch {
|
||||
|
||||
@ -65,8 +67,14 @@ public class PlayerTableValuesRowNumberPatch extends Patch {
|
||||
|
||||
@Override
|
||||
protected void applyPatch() {
|
||||
addColumn(TABLE_NAME, ROW_NUMBER + ' ' + Sql.INT + " NOT NULL DEFAULT 0");
|
||||
if (!hasColumn(TABLE_NAME, ROW_NUMBER)) {
|
||||
addColumn(TABLE_NAME, ROW_NUMBER + ' ' + Sql.INT + " NOT NULL DEFAULT 0");
|
||||
}
|
||||
|
||||
updateRowIds();
|
||||
}
|
||||
|
||||
private void updateRowIds() {
|
||||
String updateRowId = "UPDATE " + TABLE_NAME + " SET " +
|
||||
ROW_NUMBER + "=?" +
|
||||
WHERE + ID + "=?";
|
||||
|
@ -65,8 +65,14 @@ public class ServerTableValuesRowNumberPatch extends Patch {
|
||||
|
||||
@Override
|
||||
protected void applyPatch() {
|
||||
addColumn(TABLE_NAME, ROW_NUMBER + ' ' + Sql.INT + " NOT NULL DEFAULT 0");
|
||||
if (!hasColumn(TABLE_NAME, ROW_NUMBER)) {
|
||||
addColumn(TABLE_NAME, ROW_NUMBER + ' ' + Sql.INT + " NOT NULL DEFAULT 0");
|
||||
}
|
||||
|
||||
updateRowIds();
|
||||
}
|
||||
|
||||
private void updateRowIds() {
|
||||
String updateRowId = "UPDATE " + TABLE_NAME + " SET " +
|
||||
ROW_NUMBER + "=?" +
|
||||
WHERE + ID + "=?";
|
||||
|
Loading…
Reference in New Issue
Block a user