mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-27 19:47:49 +01:00
Extension table create table statements
This commit is contained in:
parent
031eba7cea
commit
405d4f643b
@ -45,5 +45,12 @@ public class CreateTablesTransaction extends OperationCriticalTransaction {
|
||||
execute(WorldTimesTable.createTableSQL(dbType));
|
||||
execute(SecurityTable.createTableSQL(dbType));
|
||||
execute(SettingsTable.createTableSQL(dbType));
|
||||
|
||||
// DataExtension tables
|
||||
execute(ExtensionIconTable.createTableSQL(dbType));
|
||||
execute(ExtensionPluginTable.createTableSQL(dbType));
|
||||
execute(ExtensionTabTable.createTableSQL(dbType));
|
||||
execute(ExtensionProviderTable.createTableSQL(dbType));
|
||||
execute(ExtensionPlayerValueTable.createTableSQL(dbType));
|
||||
}
|
||||
}
|
@ -16,6 +16,11 @@
|
||||
*/
|
||||
package com.djrapitops.plan.db.sql.tables;
|
||||
|
||||
import com.djrapitops.plan.db.DBType;
|
||||
import com.djrapitops.plan.db.sql.parsing.CreateTableParser;
|
||||
import com.djrapitops.plan.db.sql.parsing.Sql;
|
||||
import com.djrapitops.plan.extension.icon.Color;
|
||||
import com.djrapitops.plan.extension.icon.Family;
|
||||
import com.djrapitops.plan.extension.icon.Icon;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
@ -52,4 +57,13 @@ public class ExtensionIconTable {
|
||||
statement.setString(parameterIndex + 1, icon.getFamily().name());
|
||||
statement.setString(parameterIndex + 2, icon.getColor().name());
|
||||
}
|
||||
|
||||
public static String createTableSQL(DBType dbType) {
|
||||
return CreateTableParser.create(TABLE_NAME, dbType)
|
||||
.column(ID, INT).primaryKey()
|
||||
.column(ICON_NAME, Sql.varchar(50)).notNull().defaultValue("'question'")
|
||||
.column(FAMILY, Sql.varchar(15)).notNull().defaultValue(Family.SOLID.name())
|
||||
.column(COLOR, Sql.varchar(25)).notNull().defaultValue(Color.NONE.name())
|
||||
.build();
|
||||
}
|
||||
}
|
@ -16,12 +16,16 @@
|
||||
*/
|
||||
package com.djrapitops.plan.db.sql.tables;
|
||||
|
||||
import com.djrapitops.plan.db.DBType;
|
||||
import com.djrapitops.plan.db.sql.parsing.CreateTableParser;
|
||||
import com.djrapitops.plan.db.sql.parsing.Sql;
|
||||
|
||||
/**
|
||||
* Table information about 'plan_extension_user_values'.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class ExtensionPlayerValues {
|
||||
public class ExtensionPlayerValueTable {
|
||||
|
||||
public static final String TABLE_NAME = "plan_extension_user_values";
|
||||
|
||||
@ -36,4 +40,19 @@ public class ExtensionPlayerValues {
|
||||
public static final String STRING_VALUE = "string_value";
|
||||
public static final String GROUP_VALUE = "group_value";
|
||||
|
||||
public static String createTableSQL(DBType dbType) {
|
||||
return CreateTableParser.create(TABLE_NAME, dbType)
|
||||
.column(ID, Sql.INT).primaryKey()
|
||||
.column(BOOLEAN_VALUE, Sql.BOOL)
|
||||
.column(DOUBLE_VALUE, Sql.DOUBLE)
|
||||
.column(PERCENTAGE_VALUE, Sql.DOUBLE)
|
||||
.column(LONG_VALUE, Sql.LONG)
|
||||
.column(STRING_VALUE, Sql.varchar(50))
|
||||
.column(GROUP_VALUE, Sql.varchar(50))
|
||||
.column(USER_UUID, Sql.varchar(36)).notNull()
|
||||
.column(PROVIDER_ID, Sql.INT).notNull()
|
||||
.foreignKey(PROVIDER_ID, ExtensionProviderTable.TABLE_NAME, ExtensionProviderTable.ID)
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
@ -16,6 +16,10 @@
|
||||
*/
|
||||
package com.djrapitops.plan.db.sql.tables;
|
||||
|
||||
import com.djrapitops.plan.db.DBType;
|
||||
import com.djrapitops.plan.db.sql.parsing.CreateTableParser;
|
||||
import com.djrapitops.plan.db.sql.parsing.Sql;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.UUID;
|
||||
@ -46,4 +50,15 @@ public class ExtensionPluginTable {
|
||||
statement.setString(parameterIndex, pluginName);
|
||||
statement.setString(parameterIndex + 1, serverUUID.toString());
|
||||
}
|
||||
|
||||
public static String createTableSQL(DBType dbType) {
|
||||
return CreateTableParser.create(TABLE_NAME, dbType)
|
||||
.column(ID, INT).primaryKey()
|
||||
.column(PLUGIN_NAME, Sql.varchar(50)).notNull()
|
||||
.column(LAST_UPDATED, LONG).notNull()
|
||||
.column(SERVER_UUID, Sql.varchar(36)).notNull()
|
||||
.column(ICON_ID, INT).notNull()
|
||||
.foreignKey(ICON_ID, ExtensionIconTable.TABLE_NAME, ExtensionIconTable.ID)
|
||||
.build();
|
||||
}
|
||||
}
|
@ -16,6 +16,10 @@
|
||||
*/
|
||||
package com.djrapitops.plan.db.sql.tables;
|
||||
|
||||
import com.djrapitops.plan.db.DBType;
|
||||
import com.djrapitops.plan.db.sql.parsing.CreateTableParser;
|
||||
import com.djrapitops.plan.db.sql.parsing.Sql;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.UUID;
|
||||
@ -55,4 +59,24 @@ public class ExtensionProviderTable {
|
||||
ExtensionPluginTable.set2PluginValuesToStatement(statement, parameterIndex + 1, pluginName, serverUUID);
|
||||
}
|
||||
|
||||
public static String createTableSQL(DBType dbType) {
|
||||
return CreateTableParser.create(TABLE_NAME, dbType)
|
||||
.column(ID, INT).primaryKey()
|
||||
.column(PROVIDER_NAME, Sql.varchar(50)).notNull()
|
||||
.column(TEXT, Sql.varchar(50)).notNull()
|
||||
.column(DESCRIPTION, Sql.varchar(150))
|
||||
.column(PRIORITY, INT).notNull().defaultValue("0")
|
||||
.column(GROUPABLE, BOOL).notNull().defaultValue(false)
|
||||
.column(CONDITION, Sql.varchar(50))
|
||||
.column(PROVIDED_CONDITION, Sql.varchar(50))
|
||||
.column(FORMAT_TYPE, Sql.varchar(25))
|
||||
.column(IS_PLAYER_NAME, BOOL).notNull().defaultValue(false)
|
||||
.column(PLUGIN_ID, INT).notNull()
|
||||
.column(ICON_ID, INT).notNull()
|
||||
.column(TAB_ID, INT).notNull()
|
||||
.foreignKey(PLUGIN_ID, ExtensionPluginTable.TABLE_NAME, ExtensionPluginTable.ID)
|
||||
.foreignKey(ICON_ID, ExtensionIconTable.TABLE_NAME, ExtensionIconTable.ID)
|
||||
.foreignKey(TAB_ID, ExtensionTabTable.TABLE_NAME, ExtensionTabTable.ID)
|
||||
.build();
|
||||
}
|
||||
}
|
@ -16,6 +16,11 @@
|
||||
*/
|
||||
package com.djrapitops.plan.db.sql.tables;
|
||||
|
||||
import com.djrapitops.plan.db.DBType;
|
||||
import com.djrapitops.plan.db.sql.parsing.CreateTableParser;
|
||||
import com.djrapitops.plan.db.sql.parsing.Sql;
|
||||
import com.djrapitops.plan.extension.ElementOrder;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.UUID;
|
||||
@ -47,4 +52,17 @@ public class ExtensionTabTable {
|
||||
statement.setString(parameterIndex, tabName);
|
||||
ExtensionPluginTable.set2PluginValuesToStatement(statement, parameterIndex + 1, pluginName, serverUUID);
|
||||
}
|
||||
|
||||
public static String createTableSQL(DBType dbType) {
|
||||
return CreateTableParser.create(TABLE_NAME, dbType)
|
||||
.column(ID, INT).primaryKey()
|
||||
.column(TAB_NAME, Sql.varchar(50)).notNull()
|
||||
.column(ELEMENT_ORDER, Sql.varchar(100)).notNull().defaultValue("'" + ElementOrder.serialize(ElementOrder.values()) + "'")
|
||||
.column(TAB_PRIORITY, INT).notNull()
|
||||
.column(PLUGIN_ID, INT).notNull()
|
||||
.column(ICON_ID, INT).notNull()
|
||||
.foreignKey(PLUGIN_ID, ExtensionPluginTable.TABLE_NAME, ExtensionPluginTable.ID)
|
||||
.foreignKey(ICON_ID, ExtensionIconTable.TABLE_NAME, ExtensionIconTable.ID)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ package com.djrapitops.plan.extension.implementation.storage.transactions.result
|
||||
import com.djrapitops.plan.db.access.ExecStatement;
|
||||
import com.djrapitops.plan.db.access.Executable;
|
||||
import com.djrapitops.plan.db.access.transactions.Transaction;
|
||||
import com.djrapitops.plan.db.sql.tables.ExtensionPlayerValues;
|
||||
import com.djrapitops.plan.db.sql.tables.ExtensionPlayerValueTable;
|
||||
import com.djrapitops.plan.db.sql.tables.ExtensionPluginTable;
|
||||
import com.djrapitops.plan.db.sql.tables.ExtensionProviderTable;
|
||||
|
||||
@ -57,8 +57,8 @@ public class RemoveInvalidResultsTransaction extends Transaction {
|
||||
}
|
||||
|
||||
private Executable deleteInvalidMethodResults(String invalidMethod) {
|
||||
String sql = "DELETE FROM " + ExtensionPlayerValues.TABLE_NAME +
|
||||
WHERE + ExtensionPlayerValues.PROVIDER_ID + "=" + ExtensionProviderTable.STATEMENT_SELECT_PROVIDER_ID;
|
||||
String sql = "DELETE FROM " + ExtensionPlayerValueTable.TABLE_NAME +
|
||||
WHERE + ExtensionPlayerValueTable.PROVIDER_ID + "=" + ExtensionProviderTable.STATEMENT_SELECT_PROVIDER_ID;
|
||||
return new ExecStatement(sql) {
|
||||
@Override
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
|
@ -27,7 +27,7 @@ import java.util.UUID;
|
||||
|
||||
import static com.djrapitops.plan.db.sql.parsing.Sql.AND;
|
||||
import static com.djrapitops.plan.db.sql.parsing.Sql.WHERE;
|
||||
import static com.djrapitops.plan.db.sql.tables.ExtensionPlayerValues.*;
|
||||
import static com.djrapitops.plan.db.sql.tables.ExtensionPlayerValueTable.*;
|
||||
|
||||
/**
|
||||
* Transaction to store method result of a {@link com.djrapitops.plan.extension.implementation.providers.BooleanDataProvider}.
|
||||
|
@ -27,7 +27,7 @@ import java.util.UUID;
|
||||
|
||||
import static com.djrapitops.plan.db.sql.parsing.Sql.AND;
|
||||
import static com.djrapitops.plan.db.sql.parsing.Sql.WHERE;
|
||||
import static com.djrapitops.plan.db.sql.tables.ExtensionPlayerValues.*;
|
||||
import static com.djrapitops.plan.db.sql.tables.ExtensionPlayerValueTable.*;
|
||||
|
||||
/**
|
||||
* Transaction to store method result of a {@link com.djrapitops.plan.extension.implementation.providers.DoubleDataProvider}.
|
||||
|
@ -27,7 +27,7 @@ import java.util.UUID;
|
||||
|
||||
import static com.djrapitops.plan.db.sql.parsing.Sql.AND;
|
||||
import static com.djrapitops.plan.db.sql.parsing.Sql.WHERE;
|
||||
import static com.djrapitops.plan.db.sql.tables.ExtensionPlayerValues.*;
|
||||
import static com.djrapitops.plan.db.sql.tables.ExtensionPlayerValueTable.*;
|
||||
|
||||
/**
|
||||
* Transaction to store method result of a {@link com.djrapitops.plan.extension.implementation.providers.NumberDataProvider}.
|
||||
|
@ -27,7 +27,7 @@ import java.util.UUID;
|
||||
|
||||
import static com.djrapitops.plan.db.sql.parsing.Sql.AND;
|
||||
import static com.djrapitops.plan.db.sql.parsing.Sql.WHERE;
|
||||
import static com.djrapitops.plan.db.sql.tables.ExtensionPlayerValues.*;
|
||||
import static com.djrapitops.plan.db.sql.tables.ExtensionPlayerValueTable.*;
|
||||
|
||||
/**
|
||||
* Transaction to store method result of a {@link com.djrapitops.plan.extension.implementation.providers.PercentageDataProvider}.
|
||||
|
@ -27,7 +27,7 @@ import java.util.UUID;
|
||||
|
||||
import static com.djrapitops.plan.db.sql.parsing.Sql.AND;
|
||||
import static com.djrapitops.plan.db.sql.parsing.Sql.WHERE;
|
||||
import static com.djrapitops.plan.db.sql.tables.ExtensionPlayerValues.*;
|
||||
import static com.djrapitops.plan.db.sql.tables.ExtensionPlayerValueTable.*;
|
||||
|
||||
/**
|
||||
* Transaction to store method result of a {@link com.djrapitops.plan.extension.implementation.providers.StringDataProvider}.
|
||||
|
Loading…
Reference in New Issue
Block a user