mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-27 00:40:52 +01:00
add flyway migrations - older flyway as new one is being a dick
This commit is contained in:
parent
45e3b6ed99
commit
efc2707aff
13
pom.xml
13
pom.xml
@ -172,5 +172,18 @@
|
||||
<version>1.18.24</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.flywaydb</groupId>
|
||||
<artifactId>flyway-core</artifactId>
|
||||
<version>7.7.3</version>
|
||||
</dependency>
|
||||
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.flywaydb</groupId>-->
|
||||
<!-- <artifactId>flyway-mysql</artifactId>-->
|
||||
<!-- <version>9.11.0</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
</dependencies>
|
||||
</project>
|
@ -3,6 +3,8 @@ package com.eu.habbo;
|
||||
import ch.qos.logback.classic.Level;
|
||||
import ch.qos.logback.classic.spi.ILoggingEvent;
|
||||
import ch.qos.logback.core.ConsoleAppender;
|
||||
import ch.qos.logback.core.filter.Filter;
|
||||
import ch.qos.logback.core.spi.FilterReply;
|
||||
import com.eu.habbo.core.*;
|
||||
import com.eu.habbo.core.consolecommands.ConsoleCommand;
|
||||
import com.eu.habbo.database.Database;
|
||||
@ -17,6 +19,8 @@ import com.eu.habbo.plugin.events.emulator.EmulatorStartShutdownEvent;
|
||||
import com.eu.habbo.plugin.events.emulator.EmulatorStoppedEvent;
|
||||
import com.eu.habbo.threading.ThreadPooling;
|
||||
import com.eu.habbo.util.imager.badges.BadgeImager;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -58,28 +62,38 @@ public final class Emulator {
|
||||
""";
|
||||
|
||||
|
||||
|
||||
@Getter
|
||||
private static int timeStarted = 0;
|
||||
@Getter
|
||||
private static Runtime runtime;
|
||||
@Getter
|
||||
private static ConfigurationManager config;
|
||||
@Getter
|
||||
private static CryptoConfig crypto;
|
||||
@Getter
|
||||
private static TextsManager texts;
|
||||
@Getter
|
||||
private static GameServer gameServer;
|
||||
@Getter
|
||||
private static RCONServer rconServer;
|
||||
@Setter
|
||||
@Getter
|
||||
private static CameraClient cameraClient;
|
||||
@Getter
|
||||
private static Database database;
|
||||
@Getter
|
||||
private static DatabaseLogger databaseLogger;
|
||||
@Getter
|
||||
private static ThreadPooling threading;
|
||||
@Getter
|
||||
private static GameEnvironment gameEnvironment;
|
||||
@Getter
|
||||
private static PluginManager pluginManager;
|
||||
@Getter
|
||||
private static BadgeImager badgeImager;
|
||||
|
||||
static {
|
||||
Thread hook = new Thread(new Runnable() {
|
||||
public synchronized void run() {
|
||||
Emulator.dispose();
|
||||
}
|
||||
});
|
||||
Thread hook = new Thread(Emulator::dispose);
|
||||
hook.setPriority(10);
|
||||
Runtime.getRuntime().addShutdownHook(hook);
|
||||
}
|
||||
@ -105,7 +119,7 @@ public final class Emulator {
|
||||
appender.start();
|
||||
}
|
||||
|
||||
Locale.setDefault(new Locale("en"));
|
||||
Locale.setDefault( Locale.ENGLISH);
|
||||
setBuild();
|
||||
Emulator.stopped = false;
|
||||
ConsoleCommand.load();
|
||||
@ -302,71 +316,11 @@ public final class Emulator {
|
||||
}
|
||||
}
|
||||
|
||||
public static ConfigurationManager getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
public static CryptoConfig getCrypto() {
|
||||
return crypto;
|
||||
}
|
||||
|
||||
public static TextsManager getTexts() {
|
||||
return texts;
|
||||
}
|
||||
|
||||
public static Database getDatabase() {
|
||||
return database;
|
||||
}
|
||||
|
||||
public static DatabaseLogger getDatabaseLogger() {
|
||||
return databaseLogger;
|
||||
}
|
||||
|
||||
public static Runtime getRuntime() {
|
||||
return runtime;
|
||||
}
|
||||
|
||||
public static GameServer getGameServer() {
|
||||
return gameServer;
|
||||
}
|
||||
|
||||
public static RCONServer getRconServer() {
|
||||
return rconServer;
|
||||
}
|
||||
|
||||
|
||||
public static ThreadPooling getThreading() {
|
||||
return threading;
|
||||
}
|
||||
|
||||
public static GameEnvironment getGameEnvironment() {
|
||||
return gameEnvironment;
|
||||
}
|
||||
|
||||
public static PluginManager getPluginManager() {
|
||||
return pluginManager;
|
||||
}
|
||||
|
||||
public static Random getRandom() {
|
||||
return ThreadLocalRandom.current();
|
||||
}
|
||||
|
||||
public static BadgeImager getBadgeImager() {
|
||||
return badgeImager;
|
||||
}
|
||||
|
||||
public static synchronized CameraClient getCameraClient() {
|
||||
return cameraClient;
|
||||
}
|
||||
|
||||
public static synchronized void setCameraClient(CameraClient client) {
|
||||
cameraClient = client;
|
||||
}
|
||||
|
||||
public static int getTimeStarted() {
|
||||
return timeStarted;
|
||||
}
|
||||
|
||||
public static int getOnlineTime() {
|
||||
return getIntUnixTimestamp() - timeStarted;
|
||||
}
|
||||
@ -393,8 +347,8 @@ public final class Emulator {
|
||||
int amount = Integer.parseInt(m.group(2));
|
||||
String what = m.group(3);
|
||||
totalSeconds += amount * map.get(what);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
catch (Exception ignored) { }
|
||||
}
|
||||
|
||||
return totalSeconds;
|
||||
@ -420,8 +374,8 @@ public final class Emulator {
|
||||
int amount = Integer.parseInt(m.group(2));
|
||||
String what = m.group(3);
|
||||
c.add(map.get(what), amount);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
catch (Exception ignored) { }
|
||||
}
|
||||
|
||||
return c.getTime();
|
||||
|
@ -6,6 +6,8 @@ import com.zaxxer.hikari.HikariDataSource;
|
||||
import gnu.trove.map.hash.THashMap;
|
||||
import gnu.trove.set.hash.THashSet;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.flywaydb.core.Flyway;
|
||||
import org.flywaydb.core.api.output.MigrateResult;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
@ -42,6 +44,20 @@ public class Database {
|
||||
}
|
||||
|
||||
log.info("Database -> Connected! ({} MS)", System.currentTimeMillis() - millis);
|
||||
|
||||
Flyway flyway = Flyway.configure().placeholderReplacement(false).dataSource(dataSource).load();
|
||||
MigrateResult migrateResult = flyway.migrate();
|
||||
|
||||
if (migrateResult.migrationsExecuted > 0) {
|
||||
if (migrateResult.initialSchemaVersion != null)
|
||||
log.info("Database -> {} Original Schema Version", migrateResult.initialSchemaVersion);
|
||||
else
|
||||
log.info("Database -> Initial migration completed");
|
||||
|
||||
log.info("Database -> Successfully migrated! ({} migrations executed)", migrateResult.migrationsExecuted);
|
||||
}
|
||||
|
||||
log.info("Database -> Ready!");
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
|
31678
src/main/resources/db/migration/V1__Create_initial_schema.sql
Normal file
31678
src/main/resources/db/migration/V1__Create_initial_schema.sql
Normal file
File diff suppressed because one or more lines are too long
@ -62,6 +62,10 @@
|
||||
<level value="error"/>
|
||||
</logger>
|
||||
|
||||
<logger name="org.flywaydb.core.internal.sqlscript">
|
||||
<level value="warn"/>
|
||||
</logger>
|
||||
|
||||
<root level="info">
|
||||
<appender-ref ref="Console" />
|
||||
<appender-ref ref="FileDebug" />
|
||||
|
Loading…
Reference in New Issue
Block a user