mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-08-26 22:49:51 +02:00
Fixed MySQL with multiple plan databases returns wrong table count #724
This commit is contained in:
parent
ac3e9a969c
commit
2c5a97d0b1
|
@ -4,6 +4,7 @@ import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
|||
import com.djrapitops.plan.system.database.databases.sql.processing.QueryAllStatement;
|
||||
import com.djrapitops.plan.system.database.databases.sql.processing.QueryStatement;
|
||||
import com.djrapitops.plan.system.database.databases.sql.statements.TableSqlParser;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
|
@ -29,13 +30,16 @@ public abstract class Patch {
|
|||
|
||||
public boolean hasTable(String tableName) {
|
||||
String sql = usingMySQL ?
|
||||
"SELECT * FROM information_schema.TABLES WHERE table_name=? LIMIT 1" :
|
||||
"SELECT * FROM information_schema.TABLES WHERE table_name=? AND TABLE_SCHEMA=? LIMIT 1" :
|
||||
"SELECT tbl_name FROM sqlite_master WHERE tbl_name=?";
|
||||
|
||||
return query(new QueryStatement<Boolean>(sql) {
|
||||
@Override
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
statement.setString(1, tableName);
|
||||
if (usingMySQL) {
|
||||
statement.setString(2, Settings.DB_DATABASE.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -10,7 +10,7 @@ public class VersionTableRemovalPatch extends Patch {
|
|||
|
||||
@Override
|
||||
public boolean hasBeenApplied() {
|
||||
return hasTable("plan_version");
|
||||
return !hasTable("plan_version");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue
Block a user