diff --git a/src/main/java/ca/tweetzy/auctionhouse/AuctionHouse.java b/src/main/java/ca/tweetzy/auctionhouse/AuctionHouse.java index 98ce949..58da95a 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/AuctionHouse.java +++ b/src/main/java/ca/tweetzy/auctionhouse/AuctionHouse.java @@ -185,7 +185,8 @@ public class AuctionHouse extends TweetyPlugin { new _23_ItemToNBTSerializationMigration(), new _24_RemainingItemToNBTSerializationMigration(), new _25_BidHistoryMigration(), - new _26_MultiSerAndCurrencyMigration() + new _26_MultiSerAndCurrencyMigration(), + new _27_FixMigration25to26Migration() ); dataMigrationManager.runMigrations(); diff --git a/src/main/java/ca/tweetzy/auctionhouse/database/DataManager.java b/src/main/java/ca/tweetzy/auctionhouse/database/DataManager.java index 6eea9f6..612ebf5 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/database/DataManager.java +++ b/src/main/java/ca/tweetzy/auctionhouse/database/DataManager.java @@ -314,9 +314,11 @@ public class DataManager extends DataManagerAbstract { if (resultSet.getInt("serialize_version") == 0) { try (PreparedStatement updateStatement = connection.prepareStatement("UPDATE " + this.getTablePrefix() + "auctions SET serialize_version = 1, itemstack = ? WHERE id = ?")) { - updateStatement.setString(1, QuickItem.toString(item.getItem())); - updateStatement.setString(2, resultSet.getString("id")); - updateStatement.executeUpdate(); + try { + updateStatement.setString(1, QuickItem.toString(item.getItem())); + updateStatement.setString(2, resultSet.getString("id")); + updateStatement.executeUpdate(); + } catch (NbtApiException ignored) {} } } @@ -934,7 +936,14 @@ public class DataManager extends DataManagerAbstract { if (possibleItem.contains("Head Database")) possibleItem = possibleItem.replace("Head Database", "HeadDatabase"); - ItemStack item = resultSet.getInt("serialize_version") == 1 ? QuickItem.getItem(resultSet.getString("itemstack")) : AuctionAPI.decodeItemTransaction(possibleItem); + + ItemStack item = null; + + if (resultSet.getInt("serialize_version") == 1) + item = QuickItem.getItem(resultSet.getString("itemstack")); + +// AuctionAPI.decodeItemTransaction(possibleItem); + if (item == null) return null; return new Transaction( UUID.fromString(resultSet.getString("id")), diff --git a/src/main/java/ca/tweetzy/auctionhouse/database/migrations/_27_FixMigration25to26Migration.java b/src/main/java/ca/tweetzy/auctionhouse/database/migrations/_27_FixMigration25to26Migration.java new file mode 100644 index 0000000..af89bd9 --- /dev/null +++ b/src/main/java/ca/tweetzy/auctionhouse/database/migrations/_27_FixMigration25to26Migration.java @@ -0,0 +1,35 @@ +package ca.tweetzy.auctionhouse.database.migrations; + +import ca.tweetzy.flight.database.DataMigration; + +import java.sql.Connection; +import java.sql.SQLException; +import java.sql.Statement; + +public final class _27_FixMigration25to26Migration extends DataMigration { + + public _27_FixMigration25to26Migration() { + super(27); + } + + @Override + public void migrate(Connection connection, String tablePrefix) throws SQLException { + try (Statement statement = connection.createStatement()) { + statement.execute("ALTER TABLE " + tablePrefix + "auctions DROP COLUMN currency"); + statement.execute("ALTER TABLE " + tablePrefix + "auctions ADD currency VARCHAR(70) DEFAULT 'Vault/Vault'"); + + statement.execute("DROP TABLE " + tablePrefix + "bids;"); + statement.execute("CREATE TABLE " + tablePrefix + "bids (" + + "id VARCHAR(36) NOT NULL PRIMARY KEY, " + + "listing_id VARCHAR(36) NOT NULL, " + + "bidder_uuid VARCHAR(36) NOT NULL, " + + "bidder_name VARCHAR(16) NOT NULL, " + + "currency VARCHAR(70) NOT NULL DEFAULT 'Vault/Vault'," + + "currency_item TEXT NULL," + + "amount DOUBLE NOT NULL, " + + "world VARCHAR(126) NOT NULL, " + + "server VARCHAR(80) NOT NULL, " + + "created_at BigInt NOT NULL )"); + } + } +}