mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-27 09:00:28 +08:00
Since queries are now allowed, delegated Patch#shouldBeExecuted
This commit is contained in:
parent
3ab30f8b9f
commit
87d77240fa
@ -44,13 +44,16 @@ public abstract class Patch extends OperationCriticalTransaction {
|
||||
|
||||
protected abstract void applyPatch();
|
||||
|
||||
@Override
|
||||
protected boolean shouldBeExecuted() {
|
||||
return !hasBeenApplied();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void performOperations() {
|
||||
// if (!hasBeenApplied()) { TODO Uncomment after moving patches to the execution service
|
||||
if (dbType == DBType.MYSQL) disableForeignKeyChecks();
|
||||
applyPatch();
|
||||
if (dbType == DBType.MYSQL) enableForeignKeyChecks();
|
||||
// }
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
|
@ -23,13 +23,9 @@ import com.djrapitops.plan.db.access.queries.containers.ContainerFetchQueries;
|
||||
import com.djrapitops.plan.db.access.transactions.CreateTablesTransaction;
|
||||
import com.djrapitops.plan.db.access.transactions.RemoveEverythingTransaction;
|
||||
import com.djrapitops.plan.db.access.transactions.Transaction;
|
||||
import com.djrapitops.plan.db.tasks.PatchTask;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.db.patches.Patch;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.DatabaseSettings;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.console.TestPluginLogger;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
@ -116,15 +112,9 @@ public class DBPatchH2RegressionTest extends DBPatchRegressionTest {
|
||||
|
||||
@Test
|
||||
public void h2PatchTaskWorksWithoutErrors() {
|
||||
PatchTask patchTask = new PatchTask(underTest.patches(), new Locale(), new TestPluginLogger(), new ErrorHandler() {
|
||||
@Override
|
||||
public void log(L l, Class aClass, Throwable throwable) {
|
||||
throw new AssertionError(throwable);
|
||||
}
|
||||
});
|
||||
|
||||
// Patching might fail due to exception.
|
||||
patchTask.run();
|
||||
for (Patch patch : underTest.patches()) {
|
||||
underTest.executeTransaction(patch);
|
||||
}
|
||||
|
||||
assertPatchesHaveBeenApplied(underTest);
|
||||
|
||||
|
@ -24,15 +24,11 @@ import com.djrapitops.plan.db.access.queries.containers.ContainerFetchQueries;
|
||||
import com.djrapitops.plan.db.access.transactions.CreateTablesTransaction;
|
||||
import com.djrapitops.plan.db.access.transactions.RemoveEverythingTransaction;
|
||||
import com.djrapitops.plan.db.access.transactions.Transaction;
|
||||
import com.djrapitops.plan.db.tasks.PatchTask;
|
||||
import com.djrapitops.plan.db.patches.Patch;
|
||||
import com.djrapitops.plan.system.PlanSystem;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.paths.DatabaseSettings;
|
||||
import com.djrapitops.plan.system.settings.paths.WebserverSettings;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.console.TestPluginLogger;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
import org.junit.*;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import rules.PluginComponentMocker;
|
||||
@ -144,15 +140,9 @@ public class DBPatchMySQLRegressionTest extends DBPatchRegressionTest {
|
||||
|
||||
@Test
|
||||
public void mysqlPatchTaskWorksWithoutErrors() {
|
||||
PatchTask patchTask = new PatchTask(underTest.patches(), new Locale(), new TestPluginLogger(), new ErrorHandler() {
|
||||
@Override
|
||||
public void log(L l, Class aClass, Throwable throwable) {
|
||||
throw new AssertionError(throwable);
|
||||
}
|
||||
});
|
||||
|
||||
// Patching might fail due to exception.
|
||||
patchTask.run();
|
||||
for (Patch patch : underTest.patches()) {
|
||||
underTest.executeTransaction(patch);
|
||||
}
|
||||
|
||||
assertPatchesHaveBeenApplied(underTest);
|
||||
|
||||
|
@ -23,11 +23,7 @@ import com.djrapitops.plan.db.access.queries.containers.ContainerFetchQueries;
|
||||
import com.djrapitops.plan.db.access.transactions.CreateTablesTransaction;
|
||||
import com.djrapitops.plan.db.access.transactions.RemoveEverythingTransaction;
|
||||
import com.djrapitops.plan.db.access.transactions.Transaction;
|
||||
import com.djrapitops.plan.db.tasks.PatchTask;
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.console.TestPluginLogger;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
import com.djrapitops.plan.db.patches.Patch;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
@ -109,15 +105,9 @@ public class DBPatchSQLiteRegressionTest extends DBPatchRegressionTest {
|
||||
|
||||
@Test
|
||||
public void sqlitePatchTaskWorksWithoutErrors() {
|
||||
PatchTask patchTask = new PatchTask(underTest.patches(), new Locale(), new TestPluginLogger(), new ErrorHandler() {
|
||||
@Override
|
||||
public void log(L l, Class aClass, Throwable throwable) {
|
||||
throw new AssertionError(throwable);
|
||||
}
|
||||
});
|
||||
|
||||
// Patching might fail due to exception.
|
||||
patchTask.run();
|
||||
for (Patch patch : underTest.patches()) {
|
||||
underTest.executeTransaction(patch);
|
||||
}
|
||||
|
||||
assertPatchesHaveBeenApplied(underTest);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user