From f6d5aed87edf688b768f209eca894631d831b560 Mon Sep 17 00:00:00 2001 From: Zach Smith Date: Thu, 1 Feb 2018 09:54:26 -0800 Subject: Apply citextColumnNoLength to indices columns --- src/main/scala/SchemaParser.scala | 23 +++++++++++++++-------- 1 file 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, -- cgit v1.2.3