Skip to content

Commit

Permalink
entity changelog fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
seed-master committed Sep 16, 2023
1 parent 78bb879 commit 9fbe901
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/main/java/org/seed/core/entity/EntityChangeLogBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class EntityChangeLogBuilder extends AbstractChangeLogBuilder<Entity> {
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;

Expand Down Expand Up @@ -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);
Expand All @@ -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);
}

Expand All @@ -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);
}
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 9fbe901

Please sign in to comment.