diff options
author | Zach Smith <zach@driver.xyz> | 2018-02-01 09:54:26 -0800 |
---|---|---|
committer | Zach Smith <zach@driver.xyz> | 2018-02-01 11:27:57 -0800 |
commit | f6d5aed87edf688b768f209eca894631d831b560 (patch) | |
tree | d294b5106b0c9359e383bbbccc87757a61c310d6 | |
parent | 79479db14b8b86c349d3bce0bbc8bba830081841 (diff) | |
download | slick-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.scala | 23 |
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, |