diff --git a/src/main/java/net/neoforged/camelot/Database.java b/src/main/java/net/neoforged/camelot/Database.java index 736ec3c..e03a050 100644 --- a/src/main/java/net/neoforged/camelot/Database.java +++ b/src/main/java/net/neoforged/camelot/Database.java @@ -114,10 +114,11 @@ static void init() throws IOException { .callbacks(schemaMigrationCallback(14, connection -> { LOGGER.info("Migrating logging channels from main.db to configuration.db"); try (var stmt = connection.createStatement()) { + // So uh, while the type in the table is meant to be an int, it was actually a string. The new DB also stores a string var rs = stmt.executeQuery("select type, channel from logging_channels"); config.useExtension(LoggingChannelsDAO.class, extension -> { while (rs.next()) { - extension.insert(rs.getLong(2), LoggingChannelsDAO.Type.values()[rs.getInt(1)]); + extension.insert(rs.getLong(2), LoggingChannelsDAO.Type.valueOf(rs.getString(1))); } }); } diff --git a/src/main/java/net/neoforged/camelot/db/transactionals/LoggingChannelsDAO.java b/src/main/java/net/neoforged/camelot/db/transactionals/LoggingChannelsDAO.java index 1209e9c..ab83324 100644 --- a/src/main/java/net/neoforged/camelot/db/transactionals/LoggingChannelsDAO.java +++ b/src/main/java/net/neoforged/camelot/db/transactionals/LoggingChannelsDAO.java @@ -1,7 +1,7 @@ package net.neoforged.camelot.db.transactionals; import net.dv8tion.jda.api.entities.emoji.Emoji; -import org.jdbi.v3.core.enums.EnumByOrdinal; +import org.jdbi.v3.core.enums.EnumByName; import org.jdbi.v3.sqlobject.statement.SqlQuery; import org.jdbi.v3.sqlobject.statement.SqlUpdate; import org.jdbi.v3.sqlobject.transaction.Transactional; @@ -11,7 +11,6 @@ /** * A transactional used to interact with {@link Type logging channels}. */ -@EnumByOrdinal public interface LoggingChannelsDAO extends Transactional { @SqlUpdate("insert into logging_channels(channel, type) values (?, ?)") @@ -29,6 +28,7 @@ public interface LoggingChannelsDAO extends Transactional { @SqlQuery("select type from logging_channels where channel = ?") List getTypesForChannel(long channelId); + @EnumByName enum Type { MODERATION("Moderation", "Moderation events, such as bans and warnings", "🔨"), JOINS("Joins", "Join and leave events", "🚪"), diff --git a/src/main/resources/db/config/V1__logging_threadpings.sql b/src/main/resources/db/config/V1__logging_threadpings.sql index 322a73a..09e3b45 100644 --- a/src/main/resources/db/config/V1__logging_threadpings.sql +++ b/src/main/resources/db/config/V1__logging_threadpings.sql @@ -1,6 +1,6 @@ create table logging_channels ( - type tinyint not null, + type text not null, channel unsigned big int not null, constraint logging_channels_keys primary key (type, channel) );