Skip to content

Commit a266d32

Browse files
committed
Generate jOOQ Schema
1 parent 7d0a18e commit a266d32

File tree

16 files changed

+664
-0
lines changed

16 files changed

+664
-0
lines changed

build.gradle.kts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
plugins {
2+
alias(libs.plugins.kotlin.jvm).apply(false)
3+
}

docker-compose.dev.yml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# docker-compose -f docker-compose.dev.yml up -d
2+
services:
3+
kotbot_database:
4+
image: postgres:15.4
5+
container_name: kotbot_database
6+
restart: always
7+
mem_limit: 128m
8+
memswap_limit: 0m
9+
environment:
10+
POSTGRES_PASSWORD: "kotbot"
11+
POSTGRES_USER: "kotbot"
12+
POSTGRES_DB: "kotbot"
13+
volumes:
14+
- pgdata:/var/lib/postgresql/data
15+
ports:
16+
- "127.0.0.1:9577:5432"
17+
volumes:
18+
pgdata:

settings.gradle.kts

+1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ include(
77
"core-gen",
88
"tgkotbot",
99
"tgkotbot-dataops",
10+
"tgkotbot-database",
1011
)

tgkotbot-database/build.gradle.kts

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
plugins {
2+
alias(libs.plugins.kotlin.jvm)
3+
}
4+
5+
repositories {
6+
mavenCentral()
7+
}
8+
9+
dependencies {
10+
api(libs.jooq.core)
11+
api(libs.hikari)
12+
api(libs.postgresql)
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* This file is generated by jOOQ.
3+
*/
4+
package io.heapy.kotbot.database
5+
6+
7+
import kotlin.collections.List
8+
9+
import org.jooq.Constants
10+
import org.jooq.Schema
11+
import org.jooq.impl.CatalogImpl
12+
13+
14+
/**
15+
* This class is generated by jOOQ.
16+
*/
17+
@Suppress("UNCHECKED_CAST")
18+
open class DefaultCatalog : CatalogImpl("") {
19+
companion object {
20+
21+
/**
22+
* The reference instance of <code>DEFAULT_CATALOG</code>
23+
*/
24+
public val DEFAULT_CATALOG: DefaultCatalog = DefaultCatalog()
25+
}
26+
27+
/**
28+
* The schema <code>public</code>.
29+
*/
30+
val PUBLIC: Public get(): Public = Public.PUBLIC
31+
32+
override fun getSchemas(): List<Schema> = listOf(
33+
Public.PUBLIC
34+
)
35+
36+
/**
37+
* A reference to the 3.18 minor release of the code generator. If this
38+
* doesn't compile, it's because the runtime library uses an older minor
39+
* release, namely: 3.18. You can turn off the generation of this reference
40+
* by specifying /configuration/generator/generate/jooqVersionReference
41+
*/
42+
private val REQUIRE_RUNTIME_JOOQ_VERSION = Constants.VERSION_3_18
43+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* This file is generated by jOOQ.
3+
*/
4+
package io.heapy.kotbot.database
5+
6+
7+
import io.heapy.kotbot.database.tables.UpdateRaw
8+
9+
import kotlin.collections.List
10+
11+
import org.jooq.Catalog
12+
import org.jooq.Table
13+
import org.jooq.impl.SchemaImpl
14+
15+
16+
/**
17+
* This class is generated by jOOQ.
18+
*/
19+
@Suppress("UNCHECKED_CAST")
20+
open class Public : SchemaImpl("public", DefaultCatalog.DEFAULT_CATALOG) {
21+
public companion object {
22+
23+
/**
24+
* The reference instance of <code>public</code>
25+
*/
26+
val PUBLIC: Public = Public()
27+
}
28+
29+
/**
30+
* The table <code>public.update_raw</code>.
31+
*/
32+
val UPDATE_RAW: UpdateRaw get() = UpdateRaw.UPDATE_RAW
33+
34+
override fun getCatalog(): Catalog = DefaultCatalog.DEFAULT_CATALOG
35+
36+
override fun getTables(): List<Table<*>> = listOf(
37+
UpdateRaw.UPDATE_RAW
38+
)
39+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* This file is generated by jOOQ.
3+
*/
4+
package io.heapy.kotbot.database.keys
5+
6+
7+
import io.heapy.kotbot.database.tables.UpdateRaw
8+
import io.heapy.kotbot.database.tables.records.UpdateRawRecord
9+
10+
import org.jooq.UniqueKey
11+
import org.jooq.impl.DSL
12+
import org.jooq.impl.Internal
13+
14+
15+
16+
// -------------------------------------------------------------------------
17+
// UNIQUE and PRIMARY KEY definitions
18+
// -------------------------------------------------------------------------
19+
20+
val UPDATE_RAW_PK: UniqueKey<UpdateRawRecord> = Internal.createUniqueKey(UpdateRaw.UPDATE_RAW, DSL.name("update_raw_pk"), arrayOf(UpdateRaw.UPDATE_RAW.ID), true)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
/*
2+
* This file is generated by jOOQ.
3+
*/
4+
package io.heapy.kotbot.database.tables
5+
6+
7+
import io.heapy.kotbot.database.Public
8+
import io.heapy.kotbot.database.keys.UPDATE_RAW_PK
9+
import io.heapy.kotbot.database.tables.records.UpdateRawRecord
10+
11+
import java.time.LocalDateTime
12+
import java.util.function.Function
13+
14+
import org.jooq.Field
15+
import org.jooq.ForeignKey
16+
import org.jooq.JSONB
17+
import org.jooq.Name
18+
import org.jooq.Record
19+
import org.jooq.Records
20+
import org.jooq.Row3
21+
import org.jooq.Schema
22+
import org.jooq.SelectField
23+
import org.jooq.Table
24+
import org.jooq.TableField
25+
import org.jooq.TableOptions
26+
import org.jooq.UniqueKey
27+
import org.jooq.impl.DSL
28+
import org.jooq.impl.Internal
29+
import org.jooq.impl.SQLDataType
30+
import org.jooq.impl.TableImpl
31+
32+
33+
/**
34+
* This class is generated by jOOQ.
35+
*/
36+
@Suppress("UNCHECKED_CAST")
37+
open class UpdateRaw(
38+
alias: Name,
39+
child: Table<out Record>?,
40+
path: ForeignKey<out Record, UpdateRawRecord>?,
41+
aliased: Table<UpdateRawRecord>?,
42+
parameters: Array<Field<*>?>?
43+
): TableImpl<UpdateRawRecord>(
44+
alias,
45+
Public.PUBLIC,
46+
child,
47+
path,
48+
aliased,
49+
parameters,
50+
DSL.comment(""),
51+
TableOptions.table()
52+
) {
53+
companion object {
54+
55+
/**
56+
* The reference instance of <code>public.update_raw</code>
57+
*/
58+
val UPDATE_RAW: UpdateRaw = UpdateRaw()
59+
}
60+
61+
/**
62+
* The class holding records for this type
63+
*/
64+
override fun getRecordType(): Class<UpdateRawRecord> = UpdateRawRecord::class.java
65+
66+
/**
67+
* The column <code>public.update_raw.id</code>.
68+
*/
69+
val ID: TableField<UpdateRawRecord, Long?> = createField(DSL.name("id"), SQLDataType.BIGINT.nullable(false), this, "")
70+
71+
/**
72+
* The column <code>public.update_raw.created</code>.
73+
*/
74+
val CREATED: TableField<UpdateRawRecord, LocalDateTime?> = createField(DSL.name("created"), SQLDataType.LOCALDATETIME(6).nullable(false), this, "")
75+
76+
/**
77+
* The column <code>public.update_raw.update</code>.
78+
*/
79+
val UPDATE: TableField<UpdateRawRecord, JSONB?> = createField(DSL.name("update"), SQLDataType.JSONB.nullable(false), this, "")
80+
81+
private constructor(alias: Name, aliased: Table<UpdateRawRecord>?): this(alias, null, null, aliased, null)
82+
private constructor(alias: Name, aliased: Table<UpdateRawRecord>?, parameters: Array<Field<*>?>?): this(alias, null, null, aliased, parameters)
83+
84+
/**
85+
* Create an aliased <code>public.update_raw</code> table reference
86+
*/
87+
constructor(alias: String): this(DSL.name(alias))
88+
89+
/**
90+
* Create an aliased <code>public.update_raw</code> table reference
91+
*/
92+
constructor(alias: Name): this(alias, null)
93+
94+
/**
95+
* Create a <code>public.update_raw</code> table reference
96+
*/
97+
constructor(): this(DSL.name("update_raw"), null)
98+
99+
constructor(child: Table<out Record>, key: ForeignKey<out Record, UpdateRawRecord>): this(Internal.createPathAlias(child, key), child, key, UPDATE_RAW, null)
100+
override fun getSchema(): Schema? = if (aliased()) null else Public.PUBLIC
101+
override fun getPrimaryKey(): UniqueKey<UpdateRawRecord> = UPDATE_RAW_PK
102+
override fun `as`(alias: String): UpdateRaw = UpdateRaw(DSL.name(alias), this)
103+
override fun `as`(alias: Name): UpdateRaw = UpdateRaw(alias, this)
104+
override fun `as`(alias: Table<*>): UpdateRaw = UpdateRaw(alias.getQualifiedName(), this)
105+
106+
/**
107+
* Rename this table
108+
*/
109+
override fun rename(name: String): UpdateRaw = UpdateRaw(DSL.name(name), null)
110+
111+
/**
112+
* Rename this table
113+
*/
114+
override fun rename(name: Name): UpdateRaw = UpdateRaw(name, null)
115+
116+
/**
117+
* Rename this table
118+
*/
119+
override fun rename(name: Table<*>): UpdateRaw = UpdateRaw(name.getQualifiedName(), null)
120+
121+
// -------------------------------------------------------------------------
122+
// Row3 type methods
123+
// -------------------------------------------------------------------------
124+
override fun fieldsRow(): Row3<Long?, LocalDateTime?, JSONB?> = super.fieldsRow() as Row3<Long?, LocalDateTime?, JSONB?>
125+
126+
/**
127+
* Convenience mapping calling {@link SelectField#convertFrom(Function)}.
128+
*/
129+
fun <U> mapping(from: (Long?, LocalDateTime?, JSONB?) -> U): SelectField<U> = convertFrom(Records.mapping(from))
130+
131+
/**
132+
* Convenience mapping calling {@link SelectField#convertFrom(Class,
133+
* Function)}.
134+
*/
135+
fun <U> mapping(toType: Class<U>, from: (Long?, LocalDateTime?, JSONB?) -> U): SelectField<U> = convertFrom(toType, Records.mapping(from))
136+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
2+
* This file is generated by jOOQ.
3+
*/
4+
package io.heapy.kotbot.database.tables.daos
5+
6+
7+
import io.heapy.kotbot.database.tables.UpdateRaw
8+
import io.heapy.kotbot.database.tables.records.UpdateRawRecord
9+
10+
import java.time.LocalDateTime
11+
12+
import kotlin.collections.List
13+
14+
import org.jooq.Configuration
15+
import org.jooq.JSONB
16+
import org.jooq.impl.DAOImpl
17+
18+
19+
/**
20+
* This class is generated by jOOQ.
21+
*/
22+
@Suppress("UNCHECKED_CAST")
23+
open class UpdateRawDao(configuration: Configuration?) : DAOImpl<UpdateRawRecord, io.heapy.kotbot.database.tables.pojos.UpdateRaw, Long>(UpdateRaw.UPDATE_RAW, io.heapy.kotbot.database.tables.pojos.UpdateRaw::class.java, configuration) {
24+
25+
/**
26+
* Create a new UpdateRawDao without any configuration
27+
*/
28+
constructor(): this(null)
29+
30+
override fun getId(o: io.heapy.kotbot.database.tables.pojos.UpdateRaw): Long = o.id
31+
32+
/**
33+
* Fetch records that have <code>id BETWEEN lowerInclusive AND
34+
* upperInclusive</code>
35+
*/
36+
fun fetchRangeOfId(lowerInclusive: Long, upperInclusive: Long): List<io.heapy.kotbot.database.tables.pojos.UpdateRaw> = fetchRange(UpdateRaw.UPDATE_RAW.ID, lowerInclusive, upperInclusive)
37+
38+
/**
39+
* Fetch records that have <code>id IN (values)</code>
40+
*/
41+
fun fetchById(vararg values: Long): List<io.heapy.kotbot.database.tables.pojos.UpdateRaw> = fetch(UpdateRaw.UPDATE_RAW.ID, *values.toTypedArray())
42+
43+
/**
44+
* Fetch a unique record that has <code>id = value</code>
45+
*/
46+
fun fetchOneById(value: Long): io.heapy.kotbot.database.tables.pojos.UpdateRaw? = fetchOne(UpdateRaw.UPDATE_RAW.ID, value)
47+
48+
/**
49+
* Fetch records that have <code>created BETWEEN lowerInclusive AND
50+
* upperInclusive</code>
51+
*/
52+
fun fetchRangeOfCreated(lowerInclusive: LocalDateTime, upperInclusive: LocalDateTime): List<io.heapy.kotbot.database.tables.pojos.UpdateRaw> = fetchRange(UpdateRaw.UPDATE_RAW.CREATED, lowerInclusive, upperInclusive)
53+
54+
/**
55+
* Fetch records that have <code>created IN (values)</code>
56+
*/
57+
fun fetchByCreated(vararg values: LocalDateTime): List<io.heapy.kotbot.database.tables.pojos.UpdateRaw> = fetch(UpdateRaw.UPDATE_RAW.CREATED, *values)
58+
59+
/**
60+
* Fetch records that have <code>update BETWEEN lowerInclusive AND
61+
* upperInclusive</code>
62+
*/
63+
fun fetchRangeOfUpdate(lowerInclusive: JSONB, upperInclusive: JSONB): List<io.heapy.kotbot.database.tables.pojos.UpdateRaw> = fetchRange(UpdateRaw.UPDATE_RAW.UPDATE, lowerInclusive, upperInclusive)
64+
65+
/**
66+
* Fetch records that have <code>update IN (values)</code>
67+
*/
68+
fun fetchByUpdate(vararg values: JSONB): List<io.heapy.kotbot.database.tables.pojos.UpdateRaw> = fetch(UpdateRaw.UPDATE_RAW.UPDATE, *values)
69+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* This file is generated by jOOQ.
3+
*/
4+
package io.heapy.kotbot.database.tables.interfaces
5+
6+
7+
import java.io.Serializable
8+
import java.time.LocalDateTime
9+
10+
import org.jooq.JSONB
11+
12+
13+
/**
14+
* This class is generated by jOOQ.
15+
*/
16+
@Suppress("UNCHECKED_CAST")
17+
interface IUpdateRaw : Serializable {
18+
val id: Long
19+
val created: LocalDateTime
20+
val update: JSONB
21+
}

0 commit comments

Comments
 (0)