我想通过maven liquibase插件命令自动生成一个变更日志文件。变更日志应该包含一个为DiscountCode实体创建数据库表的变更集。diff是这种情况下正确的插件命令吗?
@Entity
@Table(name = "discount_code")
public class DiscountCode {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long discountId;
private String discountCode;
private LocalDate expiration;
private BigDecimal discountValue;
public DiscountCode() {}
public DiscountCode(String discountCode, LocalDate expiration, BigDecimal discountValue) {
this.discountCode = discountCode;
this.expiration = expiration;
this.discountValue = discountValue;
}
public Long getDiscountId() {
return discountId;
}
public void setDiscountId(Long discountId) {
this.discountId = discountId;
}
public String getDiscountCode() {
return discountCode;
}
public void setDiscountCode(String discountCode) {
this.discountCode = discountCode;
}
public LocalDate getExpiration() {
return expiration;
}
public void setExpiration(LocalDate expiration) {
this.expiration = expiration;
}
public BigDecimal getDiscountValue() {
return discountValue;
}
public void setDiscountValue(BigDecimal discountValue) {
this.discountValue = discountValue;
}
@Override
public String toString() {
return (
"DiscountCode{" +
"discountId=" +
discountId +
", discountCode='" +
discountCode +
'\'' +
", expiration=" +
expiration +
", discountValue=" +
discountValue +
'}'
);
}
}
以下是可用的liquibase命令:
1条答案
按热度按时间7cwmlq891#
解决方案是使用Liquibase Hibernate插件。
插件配置:
液体基质性质:
有关详细信息,请查看此页面:https://www.baeldung.com/liquibase-refactor-schema-of-java-app