Add a new migration to the blocks table

This commit is contained in:
zontreck 2024-04-24 03:40:23 -07:00
parent 0e4d9a832a
commit 43a1a44a8f
2 changed files with 12 additions and 1 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.
mod_license=GPLv3
# The mod version. See https://semver.org/
mod_version=1201.13.042424.0307
mod_version=1201.13.042424.0339
# 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.
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html

View file

@ -123,6 +123,17 @@ public class DatabaseMigrations
migrations.add(blocksTable.withMigrationAction(makeBlocksTable));
Migration blocksUpdate = builder()
.withTableID("blocks")
.withVersion(2);
PreparedStatement removePKey = DatabaseWrapper.get().prepareStatement("ALTER TABLE `blocks` DROP PRIMARY KEY;");
blocksUpdate.withMigrationAction(removePKey);
PreparedStatement addIDColumn = DatabaseWrapper.get().prepareStatement("ALTER TABLE `blocks` ADD `ID` INT NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (`ID`);");
blocksUpdate.withMigrationAction(addIDColumn);
migrations.add(blocksUpdate);
RegisterMigrationsEvent rme = new RegisterMigrationsEvent();
MinecraftForge.EVENT_BUS.post(rme);