mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-01 22:15:08 +00:00
MySQL fixes, relocations, minor touchups
This commit is contained in:
1 parent
988a5da77c
commit
f8e8be9979
6 files changed
+30
-13
No files matched your search
@@ -42,6 +42,7 @@ import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Stream;
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.CarbonChatProvider;
|
||||
import net.draycia.carbon.api.channels.ChannelRegistry;
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.api.events.CarbonChatEvent;
|
||||
@@ -163,7 +164,7 @@ public class CarbonChannelRegistry implements ChannelRegistry, DefaultedRegistry
|
||||
|
||||
if (startVersion != endVersion) { // we might not have made any changes
|
||||
// TODO: use logger
|
||||
System.out.println("Updated config schema from " + startVersion + " to " + endVersion);
|
||||
CarbonChatProvider.carbonChat().logger().info("Updated config schema from " + startVersion + " to " + endVersion);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,13 +28,18 @@ import org.spongepowered.configurate.objectmapping.meta.Comment;
|
||||
@ConfigSerializable
|
||||
public class DatabaseSettings {
|
||||
|
||||
@Comment("JDBC URL")
|
||||
@Comment("""
|
||||
JDBC URL. Suggested defaults for each DB:
|
||||
MySQL: jdbc:mysql://host:3306/DB
|
||||
MariaDB: jdbc:mariadb://host:3306/DB
|
||||
PostgreSQL: jdbc:postgresql://host:5432/database
|
||||
""")
|
||||
private String url = "jdbc:mysql://localhost:3306/carbon";
|
||||
|
||||
@Comment("")
|
||||
@Comment("The connection username.")
|
||||
private String username = "username";
|
||||
|
||||
@Comment("")
|
||||
@Comment("The connection password.")
|
||||
private String password = "password";
|
||||
|
||||
public String url() {
|
||||
|
||||
@@ -29,7 +29,6 @@ import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import javax.sql.DataSource;
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.CarbonChatProvider;
|
||||
import net.draycia.carbon.api.users.ComponentPlayerResult;
|
||||
import net.draycia.carbon.api.users.UserManager;
|
||||
@@ -73,7 +72,7 @@ public final class MySQLUserManager implements UserManager<CarbonPlayerCommon>,
|
||||
try {
|
||||
//Class.forName("org.postgresql.Driver");
|
||||
Class.forName("org.mariadb.jdbc.Driver");
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
Class.forName("com.mysql.cj.jdbc.Driver"); // Manually loading this might not be necessary
|
||||
} catch (final Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
@@ -86,14 +85,16 @@ public final class MySQLUserManager implements UserManager<CarbonPlayerCommon>,
|
||||
|
||||
final DataSource dataSource = new HikariDataSource(hikariConfig);
|
||||
|
||||
Flyway.configure(CarbonChat.class.getClassLoader())
|
||||
final Flyway flyway = Flyway.configure(Thread.currentThread().getContextClassLoader())
|
||||
.baselineVersion("0")
|
||||
.baselineOnMigrate(true)
|
||||
.locations("queries/migrations/mysql")
|
||||
.dataSource(dataSource)
|
||||
.validateOnMigrate(true)
|
||||
.load()
|
||||
.migrate();
|
||||
.load();
|
||||
|
||||
flyway.repair();
|
||||
flyway.migrate();
|
||||
|
||||
final Jdbi jdbi = Jdbi.create(dataSource)
|
||||
.registerArrayType(UUID.class, "uuid")
|
||||
|
||||
Reference in new issue
Block a user