From 9fbe901e87b5690ef07df935d65e1fc650c0a6b7 Mon Sep 17 00:00:00 2001 From: seed-master Date: Sun, 17 Sep 2023 00:41:19 +0200 Subject: [PATCH] entity changelog fixes --- .../org/seed/core/entity/EntityChangeLogBuilder.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/seed/core/entity/EntityChangeLogBuilder.java b/src/main/java/org/seed/core/entity/EntityChangeLogBuilder.java index 8fb253087..366f8d35a 100644 --- a/src/main/java/org/seed/core/entity/EntityChangeLogBuilder.java +++ b/src/main/java/org/seed/core/entity/EntityChangeLogBuilder.java @@ -66,7 +66,7 @@ class EntityChangeLogBuilder extends AbstractChangeLogBuilder { private static final String PREFIX_INDEX = "idx_"; private static final String SUFFIX_STATUS = "_status"; private static final String SUFFIX_AUDIT = "_aud"; - private static final String SUFFIX_REV = "_rev"; + private static final String SUFFIX_REVISION = "_rev"; private final EntityUsage entityUsage; @@ -622,7 +622,6 @@ private void buildFieldChanges(Entity entity, EntityField field, EntityField nex buildFieldDropChanges(entity, field); return; } - // rename column if (!field.getEffectiveColumnName().equals(nextVersionField.getEffectiveColumnName())) { buildFieldNameChanges(entity, field, nextVersionField); @@ -637,16 +636,16 @@ private void buildFieldChanges(Entity entity, EntityField field, EntityField nex addAddMandatoryConstraintChangeSet(entity, nextVersionField); } else if (field.isMandatory() && !nextVersionField.isMandatory()) { - addDropMandatoryConstraintChangeSet(entity, field); + addDropMandatoryConstraintChangeSet(entity, nextVersionField); } // unique state changed if (!field.isUnique() && nextVersionField.isUnique()) { addAddUniqueConstraintChangeSet(entity, nextVersionField); } else if (field.isUnique() && !nextVersionField.isUnique()) { - addDropUniqueConstraintChangeSet(entity, field); + addDropUniqueConstraintChangeSet(entity, nextVersionField); } - + // index state changes buildFieldIndex(entity, field, nextVersionField); } @@ -672,7 +671,6 @@ private void buildFieldNameChanges(Entity entity, EntityField field, EntityField } private void buildFieldIndex(Entity entity, EntityField field, EntityField nextVersionField) { - // index state change if (!field.isIndexed() && nextVersionField.isIndexed()) { addCreateIndexChangeSet(entity, nextVersionField); } @@ -947,7 +945,7 @@ private static String getForeignKeyConstraintName(Entity entity, EntityField fie } private static String getRevisionForeignKeyConstraintName(Entity entity) { - return PREFIX_FOREIGN_KEY + TinyId.get(entity.getId()) + SUFFIX_REV; + return PREFIX_FOREIGN_KEY + TinyId.get(entity.getId()) + SUFFIX_REVISION; } private static String getJoinColumnForeignKeyConstraintName(EntityRelation relation) {