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>
|
<version>1.18.24</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</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>
|
</dependencies>
|
||||||
</project>
|
</project>
|
@ -3,6 +3,8 @@ package com.eu.habbo;
|
|||||||
import ch.qos.logback.classic.Level;
|
import ch.qos.logback.classic.Level;
|
||||||
import ch.qos.logback.classic.spi.ILoggingEvent;
|
import ch.qos.logback.classic.spi.ILoggingEvent;
|
||||||
import ch.qos.logback.core.ConsoleAppender;
|
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.*;
|
||||||
import com.eu.habbo.core.consolecommands.ConsoleCommand;
|
import com.eu.habbo.core.consolecommands.ConsoleCommand;
|
||||||
import com.eu.habbo.database.Database;
|
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.plugin.events.emulator.EmulatorStoppedEvent;
|
||||||
import com.eu.habbo.threading.ThreadPooling;
|
import com.eu.habbo.threading.ThreadPooling;
|
||||||
import com.eu.habbo.util.imager.badges.BadgeImager;
|
import com.eu.habbo.util.imager.badges.BadgeImager;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -58,33 +62,43 @@ public final class Emulator {
|
|||||||
""";
|
""";
|
||||||
|
|
||||||
|
|
||||||
|
@Getter
|
||||||
private static int timeStarted = 0;
|
private static int timeStarted = 0;
|
||||||
|
@Getter
|
||||||
private static Runtime runtime;
|
private static Runtime runtime;
|
||||||
|
@Getter
|
||||||
private static ConfigurationManager config;
|
private static ConfigurationManager config;
|
||||||
|
@Getter
|
||||||
private static CryptoConfig crypto;
|
private static CryptoConfig crypto;
|
||||||
|
@Getter
|
||||||
private static TextsManager texts;
|
private static TextsManager texts;
|
||||||
|
@Getter
|
||||||
private static GameServer gameServer;
|
private static GameServer gameServer;
|
||||||
|
@Getter
|
||||||
private static RCONServer rconServer;
|
private static RCONServer rconServer;
|
||||||
|
@Setter
|
||||||
|
@Getter
|
||||||
private static CameraClient cameraClient;
|
private static CameraClient cameraClient;
|
||||||
|
@Getter
|
||||||
private static Database database;
|
private static Database database;
|
||||||
|
@Getter
|
||||||
private static DatabaseLogger databaseLogger;
|
private static DatabaseLogger databaseLogger;
|
||||||
|
@Getter
|
||||||
private static ThreadPooling threading;
|
private static ThreadPooling threading;
|
||||||
|
@Getter
|
||||||
private static GameEnvironment gameEnvironment;
|
private static GameEnvironment gameEnvironment;
|
||||||
|
@Getter
|
||||||
private static PluginManager pluginManager;
|
private static PluginManager pluginManager;
|
||||||
|
@Getter
|
||||||
private static BadgeImager badgeImager;
|
private static BadgeImager badgeImager;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
Thread hook = new Thread(new Runnable() {
|
Thread hook = new Thread(Emulator::dispose);
|
||||||
public synchronized void run() {
|
|
||||||
Emulator.dispose();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
hook.setPriority(10);
|
hook.setPriority(10);
|
||||||
Runtime.getRuntime().addShutdownHook(hook);
|
Runtime.getRuntime().addShutdownHook(hook);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void promptEnterKey(){
|
public static void promptEnterKey() {
|
||||||
log.info("\n");
|
log.info("\n");
|
||||||
log.info("This is a developer preview build. Your plugins for Arcturus Morningstar 3.x will NOT work on this build.");
|
log.info("This is a developer preview build. Your plugins for Arcturus Morningstar 3.x will NOT work on this build.");
|
||||||
log.info("Press \"ENTER\" if you agree to the terms stated above...");
|
log.info("Press \"ENTER\" if you agree to the terms stated above...");
|
||||||
@ -105,7 +119,7 @@ public final class Emulator {
|
|||||||
appender.start();
|
appender.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
Locale.setDefault(new Locale("en"));
|
Locale.setDefault( Locale.ENGLISH);
|
||||||
setBuild();
|
setBuild();
|
||||||
Emulator.stopped = false;
|
Emulator.stopped = false;
|
||||||
ConsoleCommand.load();
|
ConsoleCommand.load();
|
||||||
@ -113,7 +127,7 @@ public final class Emulator {
|
|||||||
System.out.println(logo);
|
System.out.println(logo);
|
||||||
|
|
||||||
// Checks if this is a BETA build before allowing them to continue.
|
// Checks if this is a BETA build before allowing them to continue.
|
||||||
if (PREVIEW.toLowerCase().contains("preview") ) {
|
if (PREVIEW.toLowerCase().contains("preview")) {
|
||||||
System.out.println();
|
System.out.println();
|
||||||
promptEnterKey();
|
promptEnterKey();
|
||||||
}
|
}
|
||||||
@ -215,7 +229,7 @@ public final class Emulator {
|
|||||||
try {
|
try {
|
||||||
String filepath = new File(Emulator.class.getProtectionDomain().getCodeSource().getLocation().getPath()).getAbsolutePath();
|
String filepath = new File(Emulator.class.getProtectionDomain().getCodeSource().getLocation().getPath()).getAbsolutePath();
|
||||||
MessageDigest md = MessageDigest.getInstance("MD5");// MD5
|
MessageDigest md = MessageDigest.getInstance("MD5");// MD5
|
||||||
try(FileInputStream fis = new FileInputStream(filepath)) {
|
try (FileInputStream fis = new FileInputStream(filepath)) {
|
||||||
byte[] dataBytes = new byte[1024];
|
byte[] dataBytes = new byte[1024];
|
||||||
int nread;
|
int nread;
|
||||||
while ((nread = fis.read(dataBytes)) != -1)
|
while ((nread = fis.read(dataBytes)) != -1)
|
||||||
@ -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() {
|
public static Random getRandom() {
|
||||||
return ThreadLocalRandom.current();
|
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() {
|
public static int getOnlineTime() {
|
||||||
return getIntUnixTimestamp() - timeStarted;
|
return getIntUnixTimestamp() - timeStarted;
|
||||||
}
|
}
|
||||||
@ -379,7 +333,7 @@ public final class Emulator {
|
|||||||
int totalSeconds = 0;
|
int totalSeconds = 0;
|
||||||
|
|
||||||
Matcher m = Pattern.compile("(([0-9]*) (second|minute|hour|day|week|month|year))").matcher(timeString);
|
Matcher m = Pattern.compile("(([0-9]*) (second|minute|hour|day|week|month|year))").matcher(timeString);
|
||||||
Map<String,Integer> map = new HashMap<>();
|
Map<String, Integer> map = new HashMap<>();
|
||||||
map.put("second", 1);
|
map.put("second", 1);
|
||||||
map.put("minute", 60);
|
map.put("minute", 60);
|
||||||
map.put("hour", 3600);
|
map.put("hour", 3600);
|
||||||
@ -393,8 +347,8 @@ public final class Emulator {
|
|||||||
int amount = Integer.parseInt(m.group(2));
|
int amount = Integer.parseInt(m.group(2));
|
||||||
String what = m.group(3);
|
String what = m.group(3);
|
||||||
totalSeconds += amount * map.get(what);
|
totalSeconds += amount * map.get(what);
|
||||||
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
catch (Exception ignored) { }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return totalSeconds;
|
return totalSeconds;
|
||||||
@ -420,8 +374,8 @@ public final class Emulator {
|
|||||||
int amount = Integer.parseInt(m.group(2));
|
int amount = Integer.parseInt(m.group(2));
|
||||||
String what = m.group(3);
|
String what = m.group(3);
|
||||||
c.add(map.get(what), amount);
|
c.add(map.get(what), amount);
|
||||||
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
catch (Exception ignored) { }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return c.getTime();
|
return c.getTime();
|
||||||
@ -430,7 +384,7 @@ public final class Emulator {
|
|||||||
private static String dateToUnixTimestamp(Date date) {
|
private static String dateToUnixTimestamp(Date date) {
|
||||||
String res = "";
|
String res = "";
|
||||||
Date aux = stringToDate("1970-01-01 00:00:00");
|
Date aux = stringToDate("1970-01-01 00:00:00");
|
||||||
if(aux == null) return null;
|
if (aux == null) return null;
|
||||||
|
|
||||||
Timestamp aux1 = dateToTimeStamp(aux);
|
Timestamp aux1 = dateToTimeStamp(aux);
|
||||||
Timestamp aux2 = dateToTimeStamp(date);
|
Timestamp aux2 = dateToTimeStamp(date);
|
||||||
|
@ -6,6 +6,8 @@ import com.zaxxer.hikari.HikariDataSource;
|
|||||||
import gnu.trove.map.hash.THashMap;
|
import gnu.trove.map.hash.THashMap;
|
||||||
import gnu.trove.set.hash.THashSet;
|
import gnu.trove.set.hash.THashSet;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.flywaydb.core.Flyway;
|
||||||
|
import org.flywaydb.core.api.output.MigrateResult;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
@ -42,6 +44,20 @@ public class Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
log.info("Database -> Connected! ({} MS)", System.currentTimeMillis() - millis);
|
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() {
|
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"/>
|
<level value="error"/>
|
||||||
</logger>
|
</logger>
|
||||||
|
|
||||||
|
<logger name="org.flywaydb.core.internal.sqlscript">
|
||||||
|
<level value="warn"/>
|
||||||
|
</logger>
|
||||||
|
|
||||||
<root level="info">
|
<root level="info">
|
||||||
<appender-ref ref="Console" />
|
<appender-ref ref="Console" />
|
||||||
<appender-ref ref="FileDebug" />
|
<appender-ref ref="FileDebug" />
|
||||||
|
Loading…
Reference in New Issue
Block a user