From 82e05f610ee499f0ff6a1c8440cd7b290fe4a013 Mon Sep 17 00:00:00 2001 From: NeumimTo Date: Wed, 10 Jul 2019 14:23:26 -0700 Subject: [PATCH] fux migrations --- .../main/java/cz/neumimto/rpg/sponge/NtRpgPlugin.java | 2 +- .../neumimto/rpg/sponge/assets/SpongeAssetService.java | 4 ++-- .../rpg/sponge/persistance/PersistenceHandler.java | 8 +++----- ...-fix-null-levels.sql => 022419-fix-null-levels.sql} | 2 +- .../nt-rpg/sql/mysql/062519-attrpoints-spent.sql | 5 +++++ .../nt-rpg/sql/mysql/071019-add-missing-columns.sql | 10 ++++++++++ .../nt-rpg/sql/mysql/250619-attrpoints-spent.sql | 5 ----- .../nt-rpg/sql/postgresql/062519-attrpoints-spent.sql | 5 +++++ .../sql/postgresql/071019-add-missing-columns.sql | 10 ++++++++++ .../nt-rpg/sql/postgresql/250619-attrpoints-spent.sql | 5 ----- 10 files changed, 37 insertions(+), 19 deletions(-) rename Plugin/src/main/resources/assets/nt-rpg/sql/mysql/{240219-fix-null-levels.sql => 022419-fix-null-levels.sql} (56%) create mode 100644 Plugin/src/main/resources/assets/nt-rpg/sql/mysql/062519-attrpoints-spent.sql create mode 100644 Plugin/src/main/resources/assets/nt-rpg/sql/mysql/071019-add-missing-columns.sql delete mode 100644 Plugin/src/main/resources/assets/nt-rpg/sql/mysql/250619-attrpoints-spent.sql create mode 100644 Plugin/src/main/resources/assets/nt-rpg/sql/postgresql/062519-attrpoints-spent.sql create mode 100644 Plugin/src/main/resources/assets/nt-rpg/sql/postgresql/071019-add-missing-columns.sql delete mode 100644 Plugin/src/main/resources/assets/nt-rpg/sql/postgresql/250619-attrpoints-spent.sql diff --git a/Plugin/src/main/java/cz/neumimto/rpg/sponge/NtRpgPlugin.java b/Plugin/src/main/java/cz/neumimto/rpg/sponge/NtRpgPlugin.java index 6bf955694..257ab2241 100644 --- a/Plugin/src/main/java/cz/neumimto/rpg/sponge/NtRpgPlugin.java +++ b/Plugin/src/main/java/cz/neumimto/rpg/sponge/NtRpgPlugin.java @@ -157,7 +157,7 @@ public void preinit(GamePreInitializationEvent e) { PluginCore.MANAGED_JPA_TYPES.add(JPABaseCharacterAttribute.class); PluginCore.MANAGED_JPA_TYPES.add(JPACharacterSkill.class); PluginCore.MANAGED_JPA_TYPES.add(JPACharacterClass.class); - Sponge.getEventManager().registerListeners(this, new PersistenceHandler()); + Sponge.getEventManager().registerListeners(this, injector.getInstance(PersistenceHandler.class)); new NKeys(); DataRegistration.builder() .manipulatorId("item_attribute_ref") diff --git a/Plugin/src/main/java/cz/neumimto/rpg/sponge/assets/SpongeAssetService.java b/Plugin/src/main/java/cz/neumimto/rpg/sponge/assets/SpongeAssetService.java index f4b66a9c0..1cb1a3706 100644 --- a/Plugin/src/main/java/cz/neumimto/rpg/sponge/assets/SpongeAssetService.java +++ b/Plugin/src/main/java/cz/neumimto/rpg/sponge/assets/SpongeAssetService.java @@ -17,7 +17,7 @@ public class SpongeAssetService implements AssetService { @Override public String getAssetAsString(String path) { try { - return Sponge.getAssetManager().getAsset(NtRpgPlugin.GlobalScope.plugin, "Skills-Definitions.conf").get().readString(); + return Sponge.getAssetManager().getAsset(NtRpgPlugin.GlobalScope.plugin, path).get().readString(); } catch (IOException e) { Log.error("Could not copy file Skills-Definition.conf into the directory " + ResourceLoader.addonDir, e); throw new IllegalArgumentException(e); @@ -26,7 +26,7 @@ public String getAssetAsString(String path) { @Override public void copyToFile(String s, Path toPath) { - Asset asset = Sponge.getAssetManager().getAsset(NtRpgPlugin.GlobalScope.plugin, "Skills-Definitions.conf").get(); + Asset asset = Sponge.getAssetManager().getAsset(NtRpgPlugin.GlobalScope.plugin, s).get(); try { asset.copyToFile(toPath); } catch (IOException e) { diff --git a/Plugin/src/main/java/cz/neumimto/rpg/sponge/persistance/PersistenceHandler.java b/Plugin/src/main/java/cz/neumimto/rpg/sponge/persistance/PersistenceHandler.java index fb8f3c437..faa027a40 100644 --- a/Plugin/src/main/java/cz/neumimto/rpg/sponge/persistance/PersistenceHandler.java +++ b/Plugin/src/main/java/cz/neumimto/rpg/sponge/persistance/PersistenceHandler.java @@ -37,14 +37,12 @@ public void onFindDbSchemaMigrationsEvent(FindDbSchemaMigrationsEvent event) thr List migrations = Arrays.asList( "sql/%s/040918-init-db.sql", "sql/%s/060119-update-2.0.0.sql", - "sql/%s/240219-fix-null-levels.sql", - "sql/%s/250619-attrpoints-spent.sql" + "sql/%s/022419-fix-null-levels.sql", + "sql/%s/062519-attrpoints-spent.sql", + "sql/%s/071019-add-missing-columns.sql" ); String s = dms.getDatabaseProductName().toLowerCase(); - if (s.equalsIgnoreCase("mariadb")) { - s = "mysql"; - } for (String migration : migrations) { migration = migration.replaceAll("%s", s); diff --git a/Plugin/src/main/resources/assets/nt-rpg/sql/mysql/240219-fix-null-levels.sql b/Plugin/src/main/resources/assets/nt-rpg/sql/mysql/022419-fix-null-levels.sql similarity index 56% rename from Plugin/src/main/resources/assets/nt-rpg/sql/mysql/240219-fix-null-levels.sql rename to Plugin/src/main/resources/assets/nt-rpg/sql/mysql/022419-fix-null-levels.sql index b3e3e3b48..230e4e878 100644 --- a/Plugin/src/main/resources/assets/nt-rpg/sql/mysql/240219-fix-null-levels.sql +++ b/Plugin/src/main/resources/assets/nt-rpg/sql/mysql/022419-fix-null-levels.sql @@ -2,4 +2,4 @@ --@author:NeumimTo --@date:24.02.2019 16:00 --@note:Level was null -update table rpg_character_class set level = 0 where level is null; \ No newline at end of file +update rpg_character_class set level = 0 where level is null; \ No newline at end of file diff --git a/Plugin/src/main/resources/assets/nt-rpg/sql/mysql/062519-attrpoints-spent.sql b/Plugin/src/main/resources/assets/nt-rpg/sql/mysql/062519-attrpoints-spent.sql new file mode 100644 index 000000000..493745017 --- /dev/null +++ b/Plugin/src/main/resources/assets/nt-rpg/sql/mysql/062519-attrpoints-spent.sql @@ -0,0 +1,5 @@ +--@id:add-attr-pointsspent +--@author:NeumimTo +--@date:25.06.2019 18:20 +--@note:Add column for attribute points spent sum +alter table rpg_character_base add column attribute_points_spent int default 0; \ No newline at end of file diff --git a/Plugin/src/main/resources/assets/nt-rpg/sql/mysql/071019-add-missing-columns.sql b/Plugin/src/main/resources/assets/nt-rpg/sql/mysql/071019-add-missing-columns.sql new file mode 100644 index 000000000..007143b65 --- /dev/null +++ b/Plugin/src/main/resources/assets/nt-rpg/sql/mysql/071019-add-missing-columns.sql @@ -0,0 +1,10 @@ +--@id:add-missing-columns +--@author:NeumimTo +--@date:10.07.2019 23:00 +--@note:Add some missing column +alter table rpg_character_attribute add column created timestamp not null default now(); +alter table rpg_character_attribute add column updated timestamp not null default now(); +alter table rpg_character_class add column updated timestamp not null default now(); +alter table rpg_character_class add column created timestamp not null default now(); +alter table rpg_character_skill add column created timestamp not null default now(); +alter table rpg_character_skill add column updated timestamp not null default now(); \ No newline at end of file diff --git a/Plugin/src/main/resources/assets/nt-rpg/sql/mysql/250619-attrpoints-spent.sql b/Plugin/src/main/resources/assets/nt-rpg/sql/mysql/250619-attrpoints-spent.sql deleted file mode 100644 index 4a4209875..000000000 --- a/Plugin/src/main/resources/assets/nt-rpg/sql/mysql/250619-attrpoints-spent.sql +++ /dev/null @@ -1,5 +0,0 @@ ---@id:fix-null-level ---@author:NeumimTo ---@date:25.06.2019 18:20 ---@note:Add column for attribute points spent sum -update table rpg_character_base add column attribute_points_spent int default 0; \ No newline at end of file diff --git a/Plugin/src/main/resources/assets/nt-rpg/sql/postgresql/062519-attrpoints-spent.sql b/Plugin/src/main/resources/assets/nt-rpg/sql/postgresql/062519-attrpoints-spent.sql new file mode 100644 index 000000000..493745017 --- /dev/null +++ b/Plugin/src/main/resources/assets/nt-rpg/sql/postgresql/062519-attrpoints-spent.sql @@ -0,0 +1,5 @@ +--@id:add-attr-pointsspent +--@author:NeumimTo +--@date:25.06.2019 18:20 +--@note:Add column for attribute points spent sum +alter table rpg_character_base add column attribute_points_spent int default 0; \ No newline at end of file diff --git a/Plugin/src/main/resources/assets/nt-rpg/sql/postgresql/071019-add-missing-columns.sql b/Plugin/src/main/resources/assets/nt-rpg/sql/postgresql/071019-add-missing-columns.sql new file mode 100644 index 000000000..007143b65 --- /dev/null +++ b/Plugin/src/main/resources/assets/nt-rpg/sql/postgresql/071019-add-missing-columns.sql @@ -0,0 +1,10 @@ +--@id:add-missing-columns +--@author:NeumimTo +--@date:10.07.2019 23:00 +--@note:Add some missing column +alter table rpg_character_attribute add column created timestamp not null default now(); +alter table rpg_character_attribute add column updated timestamp not null default now(); +alter table rpg_character_class add column updated timestamp not null default now(); +alter table rpg_character_class add column created timestamp not null default now(); +alter table rpg_character_skill add column created timestamp not null default now(); +alter table rpg_character_skill add column updated timestamp not null default now(); \ No newline at end of file diff --git a/Plugin/src/main/resources/assets/nt-rpg/sql/postgresql/250619-attrpoints-spent.sql b/Plugin/src/main/resources/assets/nt-rpg/sql/postgresql/250619-attrpoints-spent.sql deleted file mode 100644 index 4a4209875..000000000 --- a/Plugin/src/main/resources/assets/nt-rpg/sql/postgresql/250619-attrpoints-spent.sql +++ /dev/null @@ -1,5 +0,0 @@ ---@id:fix-null-level ---@author:NeumimTo ---@date:25.06.2019 18:20 ---@note:Add column for attribute points spent sum -update table rpg_character_base add column attribute_points_spent int default 0; \ No newline at end of file