aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZach Smith <zach@driver.xyz>2018-02-01 09:54:26 -0800
committerZach Smith <zach@driver.xyz>2018-02-01 11:27:57 -0800
commitf6d5aed87edf688b768f209eca894631d831b560 (patch)
treed294b5106b0c9359e383bbbccc87757a61c310d6
parent79479db14b8b86c349d3bce0bbc8bba830081841 (diff)
downloadslick-codegen-plugin-f6d5aed87edf688b768f209eca894631d831b560.tar.gz
slick-codegen-plugin-f6d5aed87edf688b768f209eca894631d831b560.tar.bz2
slick-codegen-plugin-f6d5aed87edf688b768f209eca894631d831b560.zip
Apply citextColumnNoLength to indices columns
-rw-r--r--src/main/scala/SchemaParser.scala23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/main/scala/SchemaParser.scala b/src/main/scala/SchemaParser.scala
index a5f0205..5ea61bf 100644
--- a/src/main/scala/SchemaParser.scala
+++ b/src/main/scala/SchemaParser.scala
@@ -9,15 +9,22 @@ import slick.{model => m}
object ModelTransformation {
+ def citextColumnNoLength(column: m.Column): m.Column =
+ if (column.options contains SqlType("citext")) {
+ column.copy(options = column.options.filter {
+ case _: Length => false
+ case _ => true
+ })
+ } else column
+
def citextNoLength(dbModel: m.Model): m.Model =
- dbModel.copy(tables = dbModel.tables.map(table =>
- table.copy(columns = table.columns.map(column =>
- if (column.options contains SqlType("citext")) {
- column.copy(options = column.options.filter {
- case _: Length => false
- case _ => true
- })
- } else column))))
+ dbModel.copy(
+ tables = dbModel.tables.map(
+ table =>
+ table.copy(
+ columns = table.columns.map(citextColumnNoLength),
+ indices = table.indices.map(index => index.copy(columns = index.columns.map(citextColumnNoLength)))
+ )))
def references(
dbModel: m.Model,