Let‘s say I have implemented Micronaut Data JDBC entity such as
@MappedEntity
record Book(
@Id @GeneratedValue @Nullable Long id,
@DateCreated @Nullable Date dateCreated,
String title,
int pages) {
}
and I would like generate the DDL representing my entities. Using the «ORM» approach, my development workflow is usually
For 2), in the Hibernate world I simply use SchemaExport and this creates the dialect specific DDL such as this listing for MariaDB/MySQL below.
CREATE TABLE book (
id UUID NOT NULL,
date_created DATE,
title VARCHAR(255) NOT NULL,
pages INT NOT NULL,
PRIMARY KEY(id)
) ENGINE=InnoDB;
So I got two questions here:
Micronaut Data JDBC comes with just a basic schema generator, you cannot enable the file export, but you can enable the query logging:
<logger name="io.micronaut.data.query" level="trace" />
And schema creation for your data source with schema-generate
property:
datasources:
default:
url: jdbc:h2:mem:devDb
driverClassName: org.h2.Driver
username: sa
password: ''
schema-generate: CREATE_DROP
dialect: H2