Snippets
CLI
Remove AUTO_INCREMENT altering with atlas schema diff
atlas schema diff --to "<TARGET_SCHEMA>" --from "<ORIGINAL_SCHEMA>" --format "{{ sql . \" \"}}" | sed 's|AUTO_INCREMENT \+[0-9]\+,\?||g'
- GNU-sed is necessary
- Pattern
AUTO_INCREMENT \d+\,
will replaced with a single space character
Java
Automatically set current UTC date time with Hibernate/JPA in Spring Boot
Make sure the field is
Instant
type.@Entity @Table(name = "table") class T { @Column(name = "created_at", nullable = false) @CreationTimestamp private Instant createdAt; }
Forcedly setup hibernate works in UTC time zone:
#application.properties spring.jpa.properties.hibernate.jdbc.timezone=UTC
Set JDBC connection with UTC time zone:
spring.datasource.url=jdbc:mysql://localhost:3306/db?connectionTimeZone=UTC