From e2556da41358e42ece8b650ae8341a13ecac6a28 Mon Sep 17 00:00:00 2001 From: Jesus Zazueta Date: Thu, 19 Jan 2023 00:20:19 -0500 Subject: [PATCH] - Lowercase liquibase changeset names. - Minor version bump. --- build.gradle.kts | 2 +- .../io/vacco/metolithe/codegen/liquibase/MtLb.java | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index c0ad835..247dc0a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -4,7 +4,7 @@ subprojects { apply(plugin = "io.vacco.oss.gitflow") group = "io.vacco.metolithe" - version = "2.8.0" + version = "2.8.1" configure { addClasspathHell() } configure { resourceExclusions.add("module-info.class") } diff --git a/mt-codegen/src/main/java/io/vacco/metolithe/codegen/liquibase/MtLb.java b/mt-codegen/src/main/java/io/vacco/metolithe/codegen/liquibase/MtLb.java index f7b798b..90fb663 100644 --- a/mt-codegen/src/main/java/io/vacco/metolithe/codegen/liquibase/MtLb.java +++ b/mt-codegen/src/main/java/io/vacco/metolithe/codegen/liquibase/MtLb.java @@ -60,7 +60,7 @@ private AddColumn mapNonPkAttribute(MtDescriptor d, MtFieldDescriptor fd) { private ChangeSet mapIndex(MtDescriptor d, MtFieldDescriptor fm) { var idx = new CreateIndex(); - idx.indexName = d.getFormat().of(format("idx-%s-%s", d.getName(), fm.getFieldName())); + idx.indexName = d.getFormat().of(format("idx_%s_%s", d.getName(), fm.getFieldName())); idx.tableName = d.getName(); idx.columns.add(new Column().withName(fm.getFieldName())); return new ChangeSet().withId(idx.indexName).add(idx); @@ -70,7 +70,8 @@ private ChangeSet mapCompositeIndex(String indexName, MtDescriptor d, List fd.get(MtCompIndex.class).get().idx())) .map(MtFieldDescriptor::getFieldName).toArray(); - var indexId = format("idx-%s-%s", indexName, Integer.toHexString(hash32(toStringConcat(fields).get(), DEFAULT_SEED))); + var hash = Integer.toHexString(hash32(toStringConcat(fields).get(), DEFAULT_SEED)); + var indexId = format("idx_%s_%s", indexName, hash); var idx = new CreateIndex() .withIndexName(d.getFormat().of(indexId)) .withTableName(d.getName()); @@ -83,7 +84,7 @@ private ChangeSet mapCompositeIndex(String indexName, MtDescriptor d, List d) { var uc = new AddUniqueConstraint(); uc.tableName = d.getName(); - uc.constraintName = d.getFormat().of(format("unq-%s", d.getName())); + uc.constraintName = d.getFormat().of(format("unq_%s", d.getName())); uc.columnNames = d.get(MtUnique.class) .sorted(comparingInt(fd -> fd.get(MtUnique.class).get().idx())) .map(MtFieldDescriptor::getFieldName).collect(joining(",")); @@ -106,7 +107,8 @@ private AddForeignKeyConstraint mapForeignKey(MtDescriptor d, MtFieldDescript var fromField = fd.getFieldName(); var to = fkTarget.getName(); var toField = targetPk.getFieldName(); - var fkId = format("fk-%s", Integer.toHexString(hash32(toStringConcat(from, fromField, to, toField).get(), DEFAULT_SEED))); + var hash = Integer.toHexString(hash32(toStringConcat(from, fromField, to, toField).get(), DEFAULT_SEED)); + var fkId = format("fk_%s", hash); var fkc = new AddForeignKeyConstraint(); fkc.baseColumnNames = fromField; @@ -127,13 +129,13 @@ private List mapForeignKeys(List>> clas } private ChangeSet mapTableColumn(MtDescriptor d, MtFieldDescriptor fd) { - var cs = new ChangeSet().withId(String.format("tbl-col-%s-%s", d.getName(), fd.getFieldName())); + var cs = new ChangeSet().withId(String.format("tbl_col_%s_%s", d.getName(), fd.getFieldName())); cs.add(mapNonPkAttribute(d, fd)); return cs; } private ChangeSet mapTable(MtDescriptor d) { - var cs = new ChangeSet().withId(String.format("tbl-%s", d.getName())); + var cs = new ChangeSet().withId(String.format("tbl_%s", d.getName())); var ct = new CreateTable().withTableName(d.getName()); cs.changes.add(ct); d.get(MtPk.class).findFirst()