mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-27 05:05:18 +01:00
Fix renaming of database tables.
https://github.com/BentoBoxWorld/BentoBox/issues/1536
This commit is contained in:
parent
4609881542
commit
9f1d610dfd
@ -83,7 +83,8 @@ public class SQLDatabaseHandler<T> extends AbstractJSONDatabaseHandler<T> {
|
|||||||
protected void createSchema() {
|
protected void createSchema() {
|
||||||
if (sqlConfig.renameRequired()) {
|
if (sqlConfig.renameRequired()) {
|
||||||
// Transition from the old table name
|
// Transition from the old table name
|
||||||
try (PreparedStatement pstmt = connection.prepareStatement(sqlConfig.getRenameTableSQL())) {
|
String sql = sqlConfig.getRenameTableSQL().replace("[oldTableName]", sqlConfig.getOldTableName()).replace("[tableName]", sqlConfig.getTableName());
|
||||||
|
try (PreparedStatement pstmt = connection.prepareStatement(sql)) {
|
||||||
pstmt.execute();
|
pstmt.execute();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
plugin.logError("Could not rename " + sqlConfig.getOldTableName() + " for data object " + dataObject.getCanonicalName() + " " + e.getMessage());
|
plugin.logError("Could not rename " + sqlConfig.getOldTableName() + " for data object " + dataObject.getCanonicalName() + " " + e.getMessage());
|
||||||
|
@ -64,7 +64,8 @@ public class SQLiteDatabaseHandler<T> extends SQLDatabaseHandler<T> {
|
|||||||
try (ResultSet resultSet = pstmt.executeQuery()) {
|
try (ResultSet resultSet = pstmt.executeQuery()) {
|
||||||
if (resultSet.next() && resultSet.getBoolean(1)) {
|
if (resultSet.next() && resultSet.getBoolean(1)) {
|
||||||
// Transition from the old table name
|
// Transition from the old table name
|
||||||
try (PreparedStatement pstmt2 = getConnection().prepareStatement(getSqlConfig().getRenameTableSQL())) {
|
String sql = getSqlConfig().getRenameTableSQL().replace("[oldTableName]", getSqlConfig().getOldTableName().replace("[tableName]", getSqlConfig().getTableName()));
|
||||||
|
try (PreparedStatement pstmt2 = getConnection().prepareStatement(sql)) {
|
||||||
pstmt2.execute();
|
pstmt2.execute();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
plugin.logError("Could not rename " + getSqlConfig().getOldTableName() + " for data object " + dataObject.getCanonicalName() + " " + e.getMessage());
|
plugin.logError("Could not rename " + getSqlConfig().getOldTableName() + " for data object " + dataObject.getCanonicalName() + " " + e.getMessage());
|
||||||
|
Loading…
Reference in New Issue
Block a user