Created
August 25, 2017 22:21
-
-
Save codemwnci/97cb0db70b2d4078fa315c3a041226e3 to your computer and use it in GitHub Desktop.
DB Setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package codemwnci | |
import spark.Spark.* | |
import kotliquery.* | |
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper | |
import java.time.LocalDateTime | |
fun main(args: Array<String>) { | |
setupDB() | |
} | |
fun setupDB() { | |
HikariCP.default("jdbc:h2:mem:todo", "user", "pass") | |
// when using in memory DB, create the DDL | |
using(sessionOf(HikariCP.dataSource())) { session -> | |
session.run(queryOf(""" | |
create table todo ( | |
id serial not null primary key, | |
text varchar(255), | |
done boolean default false, | |
created_at timestamp not null default now() | |
) | |
""").asExecute) // returns Boolean | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment