Answer the question
In order to leave comments, you need to log in
Why do fields disappear when evolution rolls on?
Hello, I'm learning the Play Framework The created_at and updated_at fields disappear from the table when I roll up the evolution. Moreover, the problem manifests itself only on the test database, with a normal start in dev mod, everything is fine, the fields are in place.
Here is the table creation code:
create table if not exists cash_services (
id serial PRIMARY KEY,
percent_value numeric,
calculation_type int4 not null,
constant_value numeric,
direction int4 not null,
owner_type int4 not null,
finance_event_id int4 not null,
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT clock_timestamp(),
updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT clock_timestamp()
);
package entities;
import entities.base.OwnerType;
import entities.base.PersistenceEntity;
import exceptions.FinanceEventException;
import io.ebean.Finder;
import modules.db_convertations.DatabaseAmount;
import play.data.validation.Constraints;
import play.data.validation.Constraints.Required;
import javax.persistence.*;
import javax.validation.Valid;
import java.math.BigInteger;
import static play.data.validation.Constraints.*;
@Validate
@Entity
@Table(name = "cash_services")
public class CashService implements PersistenceEntity, Validatable<String> {
public static final Finder<Integer, CashService> finder = new Finder<>(CashService.class);
public enum Direction {
FROM,
TO
}
public enum CalculationType {
PERCENT_PLUS,
PERCENT_MINUS
}
@Id
@SequenceGenerator(name="cash_services_id_seq",
sequenceName="cash_services_id_seq",
allocationSize=1)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "cash_services_id_seq")
private int id;
@Column(name = "percent_value")
private DatabaseAmount percentValue;
@Enumerated(EnumType.ORDINAL)
@Column(name = "calculation_type")
private CalculationType calculationType;
@Column(name = "constant_value")
private DatabaseAmount constantValue;
@Column(name = "fix_value")
private DatabaseAmount fixValue;
@Required
@Enumerated(EnumType.ORDINAL)
private Direction direction;
@Required
@Enumerated(EnumType.ORDINAL)
@Column(name = "owner_type")
private OwnerType ownerType;
@OneToOne(optional = false)
@JoinColumn(name = "finance_event_id", referencedColumnName = "id")
private FinanceEvent createdEvent;
public void setId(int id) {
this.id = id;
}
public void setPercentValue(DatabaseAmount percentValue) {
this.percentValue = percentValue;
}
public void setCalculationType(CalculationType calculationType) {
this.calculationType = calculationType;
}
public void setConstantValue(DatabaseAmount constantValue) {
this.constantValue = constantValue;
}
public void setDirection(Direction direction) {
this.direction = direction;
}
public void setOwnerType(OwnerType ownerType) {
this.ownerType = ownerType;
}
public void setCreatedEvent(FinanceEvent createdEvent) {
this.createdEvent = createdEvent;
}
public void setFixValue(DatabaseAmount fixValue) {
this.fixValue = fixValue;
}
public int getId() {
return id;
}
public DatabaseAmount getPercentValue() {
return percentValue;
}
public CalculationType getCalculationType() {
return calculationType;
}
public DatabaseAmount getConstantValue() {
return constantValue;
}
public Direction getDirection() {
return direction;
}
public OwnerType getOwnerType() {
return ownerType;
}
public FinanceEvent getCreatedEvent() {
return createdEvent;
}
public DatabaseAmount getFixValue() {
return fixValue;
}
@Override
public String validate() {
//Код валидации
return null;
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question