From 793c81dd4678c7594189ebf6912890232c6e9112 Mon Sep 17 00:00:00 2001 From: Stewart Stewart Date: Tue, 30 May 2017 17:26:36 -0700 Subject: alter model so postgres `citext` has same length options as `text` --- src/main/scala/SchemaParser.scala | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/main/scala/SchemaParser.scala b/src/main/scala/SchemaParser.scala index 1186f11..b86990f 100644 --- a/src/main/scala/SchemaParser.scala +++ b/src/main/scala/SchemaParser.scala @@ -3,9 +3,22 @@ import scala.concurrent.ExecutionContext.Implicits.global import slick.dbio.DBIO import slick.driver.JdbcProfile import slick.jdbc.meta.MTable +import slick.profile.RelationalProfile.ColumnOption.Length +import slick.profile.SqlProfile.ColumnOption.SqlType import slick.{model => m} object SchemaParser { + + 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: Length => false + case option => true + }) + } else column)))) + def references(dbModel: m.Model, tcMappings: Map[(String, String), (String, String)]) : Map[(String, String), (m.Table, m.Column)] = { @@ -55,6 +68,6 @@ object SchemaParser { } } - jdbcProfile.createModel(filteredTables) + jdbcProfile.createModel(filteredTables).map(citextNoLength) } } -- cgit v1.2.3