aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPetr Ilin <hevav@hevav.dev>2022-12-26 04:01:49 +0300
committerPetr Ilin <hevav@hevav.dev>2022-12-26 04:01:49 +0300
commit9cbeb1ea1120e08985c0859301d6ed65468397ca (patch)
tree4a7ab881e07ea1c0e131026538f22095fc798977 /src
parent875261843920e98fe578c25cff6338398265ffbb (diff)
downloadLimboAuth-9cbeb1ea1120e08985c0859301d6ed65468397ca.tar.gz
LimboAuth-9cbeb1ea1120e08985c0859301d6ed65468397ca.tar.bz2
LimboAuth-9cbeb1ea1120e08985c0859301d6ed65468397ca.zip
Fix migrateDb for postgres and sqlite
Diffstat (limited to 'src')
-rw-r--r--src/main/java/net/elytrium/limboauth/LimboAuth.java23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/main/java/net/elytrium/limboauth/LimboAuth.java b/src/main/java/net/elytrium/limboauth/LimboAuth.java
index d2c442f..c98497f 100644
--- a/src/main/java/net/elytrium/limboauth/LimboAuth.java
+++ b/src/main/java/net/elytrium/limboauth/LimboAuth.java
@@ -422,16 +422,21 @@ public class LimboAuth {
String findSql;
String database = Settings.IMP.DATABASE.DATABASE;
String tableName = tableInfo.getTableName();
- switch (Settings.IMP.DATABASE.STORAGE_TYPE) {
- case "h2": {
+ DatabaseLibrary databaseLibrary = DatabaseLibrary.valueOf(Settings.IMP.DATABASE.STORAGE_TYPE.toUpperCase(Locale.ROOT));
+ switch (databaseLibrary) {
+ case SQLITE: {
+ findSql = "SELECT name FROM PRAGMA_TABLE_INFO('" + tableName + "')";
+ break;
+ }
+ case H2: {
findSql = "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '" + tableName + "';";
break;
}
- case "postgresql": {
+ case POSTGRESQL: {
findSql = "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_CATALOG = '" + database + "' AND TABLE_NAME = '" + tableName + "';";
break;
}
- case "mysql": {
+ case MYSQL: {
findSql = "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '" + database + "' AND TABLE_NAME = '" + tableName + "';";
break;
}
@@ -447,7 +452,15 @@ public class LimboAuth {
tables.forEach(table -> {
try {
- StringBuilder builder = new StringBuilder("ALTER TABLE " + tableName + " ADD ");
+ StringBuilder builder = new StringBuilder("ALTER TABLE ");
+ if (databaseLibrary == DatabaseLibrary.POSTGRESQL) {
+ builder.append('"');
+ }
+ builder.append(tableName);
+ if (databaseLibrary == DatabaseLibrary.POSTGRESQL) {
+ builder.append('"');
+ }
+ builder.append(" ADD ");
String columnDefinition = table.getColumnDefinition();
DatabaseType databaseType = dao.getConnectionSource().getDatabaseType();
if (columnDefinition == null) {