Postgres Partitioning with JPA and migration with Liquibase

47 views Asked by At

I need to create partitioned table acts, and want to generate migration changelog using liquibase. How to make JPA entity to be written as PARTITION BY list(code). And how to manage multicolumn primary key (id, code)?

My entity

@Entity
@Getter
@Setter
@ToString
@Table(name = "acts")
@EntityListeners(AuditingEntityListener.class)
public class ActEntity extends BaseEntity {

  public static final String GENERATOR_NAME = "acts_gen";
  public static final String SEQUENCE_NAME = "acts_seq";

  @Id
  @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = GENERATOR_NAME)
  @SequenceGenerator(name = GENERATOR_NAME, sequenceName = SEQUENCE_NAME, allocationSize = 1)
  private Long id;

  @PartitionKey
  @Column(name = "code", nullable = false, length = 20)
  private String code;

  @NotNull
  @Column(name = "status", nullable = false)
  private Boolean status;
}
0

There are 0 answers