Go back and revise the database migrations. Breaking change

This commit is contained in:
zontreck 2024-04-30 15:31:53 -07:00
parent 0d735ec2e8
commit aa9f0c5235
2 changed files with 4 additions and 9 deletions

View file

@ -53,7 +53,7 @@ mod_name=Zontreck's Library Mod
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default. # The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
mod_license=GPLv3 mod_license=GPLv3
# The mod version. See https://semver.org/ # The mod version. See https://semver.org/
mod_version=1201.13.043024.1524 mod_version=1201.13.043024.1530
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository. # The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
# This should match the base package used for the mod sources. # This should match the base package used for the mod sources.
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html # See https://maven.apache.org/guides/mini/guide-naming-conventions.html

View file

@ -66,7 +66,8 @@ public class DatabaseMigrations
try { try {
DatabaseWrapper.get().executePreparedStatement(pstmt); DatabaseWrapper.get().executePreparedStatement(pstmt);
} catch (SQLException e) { } catch (SQLException e) {
LibZontreck.LOGGER.warn("There was a problem executing a migration. The migration is " + pstmt+"\n\nThis does not necessarily mean a failure. If everything seems to work fine, this migration might not have been necessary."); LibZontreck.LOGGER.warn("There was a problem executing a migration. The migration is " + pstmt+"\n\nThis does not necessarily mean a failure. If everything seems to work fine, this migration might not have been necessary.\n\n");
e.printStackTrace();
} }
} }
@ -115,10 +116,7 @@ public class DatabaseMigrations
" `posZ` int(11) NOT NULL," + " `posZ` int(11) NOT NULL," +
" `snapshotID` int(11) NOT NULL DEFAULT 0 COMMENT 'Enables multiple blocks existing at the same position'," + " `snapshotID` int(11) NOT NULL DEFAULT 0 COMMENT 'Enables multiple blocks existing at the same position'," +
" `block` blob NOT NULL COMMENT 'NBT Data representing a SavedBlock'," + " `block` blob NOT NULL COMMENT 'NBT Data representing a SavedBlock'," +
" PRIMARY KEY (`time`)," + " PRIMARY KEY (`time`)" +
" UNIQUE KEY `posX` (`posX`)," +
" UNIQUE KEY `posY` (`posY`)," +
" UNIQUE KEY `posZ` (`posZ`)" +
") ;"); ") ;");
migrations.add(blocksTable.withMigrationAction(makeBlocksTable)); migrations.add(blocksTable.withMigrationAction(makeBlocksTable));
@ -136,9 +134,6 @@ public class DatabaseMigrations
migrations.add(builder() migrations.add(builder()
.withTableID("blocks") .withTableID("blocks")
.withVersion(3) .withVersion(3)
.withMigrationAction(DatabaseWrapper.get().prepareStatement(" ALTER TABLE `blocks` DROP INDEX `posX`; "))
.withMigrationAction(DatabaseWrapper.get().prepareStatement(" ALTER TABLE `blocks` DROP INDEX `posY`; "))
.withMigrationAction(DatabaseWrapper.get().prepareStatement(" ALTER TABLE `blocks` DROP INDEX `posZ`; "))
.withMigrationAction(DatabaseWrapper.get().prepareStatement("ALTER TABLE `savedBlocks`.`blocks` ADD UNIQUE (`posX`, `posY`, `posZ`); "))); .withMigrationAction(DatabaseWrapper.get().prepareStatement("ALTER TABLE `savedBlocks`.`blocks` ADD UNIQUE (`posX`, `posY`, `posZ`); ")));