Skip to content

Commit

Permalink
chore: clean codes
Browse files Browse the repository at this point in the history
  • Loading branch information
hantsy committed Mar 22, 2022
1 parent 5928d35 commit 0e21ca1
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 1 deletion.
91 changes: 91 additions & 0 deletions kotlin-co/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<kotlin.version>1.6.10</kotlin.version>
<kotlin-coroutines.version>1.6.0</kotlin-coroutines.version>
<testcontainers.version>1.16.3</testcontainers.version>
<jooq.version>3.16.5</jooq.version>
</properties>
<dependencies>
<dependency>
Expand Down Expand Up @@ -55,6 +56,17 @@
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>org.jooq</groupId>
<artifactId>jooq</artifactId>
<version>${jooq.version}</version>
</dependency>
<dependency>
<groupId>org.jooq</groupId>
<artifactId>jooq-kotlin</artifactId>
<version>${jooq.version}</version>
</dependency>

<!-- test deps -->
<dependency>
<groupId>org.postgresql</groupId>
Expand Down Expand Up @@ -126,6 +138,85 @@
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
<testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.jooq</groupId>
<artifactId>jooq-codegen-maven</artifactId>

<executions>
<execution>
<id>generate-postgres</id>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<generator>
<name>org.jooq.codegen.KotlinGenerator</name>
<database>
<name>org.jooq.meta.extensions.ddl.DDLDatabase</name>
<properties>

<!-- Specify the location of your SQL script.
You may use ant-style file matching, e.g. /path/**/to/*.sql
Where:
- ** matches any directory subtree
- * matches any number of characters in a directory / file name
- ? matches a single character in a directory / file name -->
<property>
<key>scripts</key>
<value>src/main/resources/schema.sql</value>
</property>

<!-- The sort order of the scripts within a directory, where:
- semantic: sorts versions, e.g. v-3.10.0 is after v-3.9.0 (default)
- alphanumeric: sorts strings, e.g. v-3.10.0 is before v-3.9.0
- flyway: sorts files the same way as flyway does
- none: doesn't sort directory contents after fetching them from the directory -->
<!-- <property>-->
<!-- <key>sort</key>-->
<!-- <value>semantic</value>-->
<!-- </property>-->

<!-- The default schema for unqualified objects:
- public: all unqualified objects are located in the PUBLIC (upper case) schema
- none: all unqualified objects are located in the default schema (default)
This configuration can be overridden with the schema mapping feature -->
<property>
<key>unqualifiedSchema</key>
<value>none</value>
</property>

<!-- The default name case for unquoted objects:
- as_is: unquoted object names are kept unquoted
- upper: unquoted object names are turned into upper case (most databases)
- lower: unquoted object names are turned into lower case (e.g. PostgreSQL) -->
<property>
<key>defaultNameCase</key>
<value>lower</value>
</property>
</properties>
</database>
<target>
<packageName>com.example.demo.jooq</packageName>
<!-- <directory>src/main/java</directory>-->
</target>
</generator>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.jooq</groupId>
<artifactId>jooq-meta-extensions</artifactId>
<version>${jooq.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
Expand Down
3 changes: 2 additions & 1 deletion kotlin-co/src/main/resources/schema.sql
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
CREATE TABLE IF NOT EXISTS posts (
id UUID DEFAULT uuid_generate_v4(),
id UUID NOT NULL /* [jooq ignore start] */ DEFAULT uuid_generate_v4()/* [jooq ignore stop] */,
title VARCHAR(255),
content VARCHAR(255),
status VARCHAR(255) default 'DRAFT',
cupsofcoffee NUMERIC[],
created_at TIMESTAMP , --NOT NULL DEFAULT LOCALTIMESTAMP,
version INTEGER,
PRIMARY KEY (id)
Expand Down

0 comments on commit 0e21ca1

Please sign in to comment.