use of com.djrapitops.plan.storage.database.transactions.init.CreateTablesTransaction in project Plan by plan-player-analytics.
the class SQLDB method setupDatabase.
/**
* Ensures connection functions correctly and all tables exist.
* <p>
* Updates to latest schema.
*/
private void setupDatabase() {
executeTransaction(new CreateTablesTransaction());
logger.info("Database: Making sure schema is up to date..");
for (Patch patch : patches()) {
executeTransaction(patch);
}
executeTransaction(new OperationCriticalTransaction() {
@Override
protected void performOperations() {
if (getState() == State.PATCHING)
setState(State.OPEN);
}
});
registerIndexCreationTask();
logger.info("Database: Ready for operation.");
}
use of com.djrapitops.plan.storage.database.transactions.init.CreateTablesTransaction in project Plan by plan-player-analytics.
the class DBPatchSQLiteRegressionTest method setUpDBWithOldSchema.
@BeforeEach
void setUpDBWithOldSchema(@TempDir Path tempDir) throws Exception {
component = new PluginMockComponent(tempDir);
underTest = this.component.getPlanSystem().getDatabaseSystem().getSqLiteFactory().usingFileCalled("test");
underTest.setTransactionExecutorServiceProvider(MoreExecutors::newDirectExecutorService);
underTest.init();
// Initialize database with the old table schema
dropAllTables(underTest);
underTest.executeTransaction(new Transaction() {
@Override
protected void performOperations() {
execute(serverTable);
execute(usersTable);
execute(userInfoTable);
execute(geoInfoTable);
execute(nicknameTable);
execute(sessionsTable);
execute(killsTable);
execute(pingTable);
execute(commandUseTable);
execute(tpsTable);
execute(worldsTable);
execute(worldTimesTable);
execute(securityTable);
execute(transferTable);
}
});
underTest.executeTransaction(new CreateTablesTransaction());
insertData(underTest);
}
use of com.djrapitops.plan.storage.database.transactions.init.CreateTablesTransaction in project Plan by plan-player-analytics.
the class MySQLTest method setUp.
@BeforeEach
void setUp() {
TestErrorLogger.throwErrors(true);
db().executeTransaction(new Patch() {
@Override
public boolean hasBeenApplied() {
return false;
}
@Override
public void applyPatch() {
dropTable("plan_world_times");
dropTable("plan_kills");
dropTable("plan_sessions");
dropTable("plan_worlds");
dropTable("plan_users");
}
});
db().executeTransaction(new CreateTablesTransaction());
db().executeTransaction(new RemoveEverythingTransaction());
db().executeTransaction(new StoreServerInformationTransaction(new Server(serverUUID(), TestConstants.SERVER_NAME, "")));
assertEquals(serverUUID(), ((SQLDB) db()).getServerUUIDSupplier().get());
}
use of com.djrapitops.plan.storage.database.transactions.init.CreateTablesTransaction in project Plan by plan-player-analytics.
the class DBPatchMySQLRegressionTest method setUpDBWithOldSchema.
@BeforeEach
void setUpDBWithOldSchema() throws Exception {
PlanSystem system = component.getPlanSystem();
Optional<Database> db = new DBPreparer(system, TEST_PORT_NUMBER).prepareMySQL();
assumeTrue(db.isPresent());
underTest = (MySQLDB) db.get();
dropAllTables();
// Initialize database with the old table schema
underTest.executeTransaction(new Transaction() {
@Override
protected void performOperations() {
execute(serverTable);
execute(usersTable);
execute(userInfoTable);
execute(geoInfoTable);
execute(nicknameTable);
execute(sessionsTable);
execute(killsTable);
execute(pingTable);
execute(commandUseTable);
execute(tpsTable);
execute(worldsTable);
execute(worldTimesTable);
execute(securityTable);
execute(transferTable);
}
});
underTest.executeTransaction(new CreateTablesTransaction());
insertData(underTest);
}
use of com.djrapitops.plan.storage.database.transactions.init.CreateTablesTransaction in project Plan by plan-player-analytics.
the class SQLiteTest method setUp.
@BeforeEach
void setUp() {
TestErrorLogger.throwErrors(true);
db().executeTransaction(new Patch() {
@Override
public boolean hasBeenApplied() {
return false;
}
@Override
public void applyPatch() {
dropTable("plan_world_times");
dropTable("plan_kills");
dropTable("plan_sessions");
dropTable("plan_worlds");
dropTable("plan_users");
}
});
db().executeTransaction(new CreateTablesTransaction());
db().executeTransaction(new RemoveEverythingTransaction());
db().executeTransaction(new StoreServerInformationTransaction(new Server(serverUUID(), "ServerName", "")));
assertEquals(serverUUID(), ((SQLDB) db()).getServerUUIDSupplier().get());
}
Aggregations