mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-11-06 10:49:44 +01: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.QueryAllStatement;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.processing.QueryStatement;
|
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.database.databases.sql.statements.TableSqlParser;
|
||||||
|
import com.djrapitops.plan.system.settings.Settings;
|
||||||
|
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
@ -29,13 +30,16 @@ public abstract class Patch {
|
|||||||
|
|
||||||
public boolean hasTable(String tableName) {
|
public boolean hasTable(String tableName) {
|
||||||
String sql = usingMySQL ?
|
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=?";
|
"SELECT tbl_name FROM sqlite_master WHERE tbl_name=?";
|
||||||
|
|
||||||
return query(new QueryStatement<Boolean>(sql) {
|
return query(new QueryStatement<Boolean>(sql) {
|
||||||
@Override
|
@Override
|
||||||
public void prepare(PreparedStatement statement) throws SQLException {
|
public void prepare(PreparedStatement statement) throws SQLException {
|
||||||
statement.setString(1, tableName);
|
statement.setString(1, tableName);
|
||||||
|
if (usingMySQL) {
|
||||||
|
statement.setString(2, Settings.DB_DATABASE.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -10,7 +10,7 @@ public class VersionTableRemovalPatch extends Patch {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasBeenApplied() {
|
public boolean hasBeenApplied() {
|
||||||
return hasTable("plan_version");
|
return !hasTable("plan_version");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user