Create DSL for schema and database/keyspace creation
Would like the ability to create a keyspace and schema directly from Quill.
Keyspace creation possibly to be accomplished by adding some new config properties:
db.createKeyspace=true
db.keyspaceStrategy=simple
db.replicationFactor=3
Schema creation possibly looking something like:
val q = quote {
query[Table].create.primaryKey(p => (p.field1, p.field2))
.partitionKey(_.field3)
.clusteringOrder(p => (p.field2, p.field3))(Ord(Ord.asc, Ord.desc))
}
@getquill/maintainers
I think schema creation would be an interesting feature. Could you give more details on why a DSL as opposed to raw CQL strings? A DSL doesn't seem to provide much benefit as DDL statements aren't composable.
I guess the main point is automatically mapping case classes into DB fields. This way we keep model and DB to be strictly consistent during whole dev/testing phase. +1
This is a essential feature.can we get some info from quill ast? BTW,is this related? https://github.com/getquill/quill/pull/226
I'm upvoting this because it's the only thing preventing me from using Quill (both hibernate and slick has this feature).
If this feature is implemented, could we maybe also add annotation support so we can do something like the following?
case class SomeEntity(
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
identifier: Int,
@Length(32)
shortString: String,
// ...
)
I'm also upvoting this feature.
My use case is to create tables in test with H2, but the production code is using Postgres. Unlike the full-feature table creation support, we have some tolerance on the difference between test database and production DB scheme.
With this feature, we could simply create table before each test case:
// instead of this
override def beforeEach(): Unit = {
super.beforeEach()
ctx.run(quote(
infix"""CREATE TABLE the_schema.file_info (
id UUID NOT NULL,
file_name TEXT,
file_extension TEXT,
size_bytes BIGINT NOT NULL
)
""".as[Action[Nothing]]
))
}
// we could run something like
override def beforeEach(): Unit = {
super.beforeEach()
ctx.run(quote(fileInfoTable.createTableAction))
}
I'd advise people to use something like flyway or liquibase for such needs