Search in sources :

Example 31 with PlanConfig

use of com.djrapitops.plan.settings.config.PlanConfig in project Plan by plan-player-analytics.

the class DBPreparer method prepareMySQL.

public Optional<Database> prepareMySQL() {
    PlanConfig config = dependencies.config();
    Optional<String> formattedDB = setUpMySQLSettings(config);
    if (formattedDB.isPresent()) {
        String formattedDatabase = formattedDB.get();
        SQLDB mysql = prepareDBByName(DBType.MYSQL.getName());
        mysql.executeTransaction(new Transaction() {

            @Override
            protected void performOperations() {
                execute("DROP DATABASE " + formattedDatabase);
                execute("CREATE DATABASE " + formattedDatabase);
                execute("USE " + formattedDatabase);
            }
        });
        return Optional.of(mysql);
    }
    return Optional.empty();
}
Also used : Transaction(com.djrapitops.plan.storage.database.transactions.Transaction) SQLDB(com.djrapitops.plan.storage.database.SQLDB) PlanConfig(com.djrapitops.plan.settings.config.PlanConfig)

Aggregations

PlanConfig (com.djrapitops.plan.settings.config.PlanConfig)31 Test (org.junit.jupiter.api.Test)17 BeforeAll (org.junit.jupiter.api.BeforeAll)8 Path (java.nio.file.Path)5 TestPluginLogger (utilities.TestPluginLogger)5 PluginMockComponent (utilities.mocks.PluginMockComponent)5 DBSystem (com.djrapitops.plan.storage.database.DBSystem)4 MoreExecutors (com.google.common.util.concurrent.MoreExecutors)4 User (com.djrapitops.plan.delivery.domain.auth.User)3 SessionCache (com.djrapitops.plan.gathering.cache.SessionCache)3 ActiveSession (com.djrapitops.plan.gathering.domain.ActiveSession)3 SQLiteDB (com.djrapitops.plan.storage.database.SQLiteDB)3 RegisterWebUserTransaction (com.djrapitops.plan.storage.database.transactions.commands.RegisterWebUserTransaction)3 File (java.io.File)3 TimeAmountFormatter (com.djrapitops.plan.delivery.formatting.time.TimeAmountFormatter)2 Setting (com.djrapitops.plan.settings.config.paths.key.Setting)2 SQLDB (com.djrapitops.plan.storage.database.SQLDB)2 StoreConfigTransaction (com.djrapitops.plan.storage.database.transactions.StoreConfigTransaction)2 ErrorLogger (com.djrapitops.plan.utilities.logging.ErrorLogger)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2