aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStewart Stewart <stewinsalot@gmail.com>2017-05-30 17:26:36 -0700
committerStewart Stewart <stewinsalot@gmail.com>2017-05-30 17:32:17 -0700
commit793c81dd4678c7594189ebf6912890232c6e9112 (patch)
tree952ce63d79093296102fa53d90175344f4a27d45
parent0410511e2e4fc3eaacc4c58f8fd71d343be54b50 (diff)
downloadslick-codegen-plugin-793c81dd4678c7594189ebf6912890232c6e9112.tar.gz
slick-codegen-plugin-793c81dd4678c7594189ebf6912890232c6e9112.tar.bz2
slick-codegen-plugin-793c81dd4678c7594189ebf6912890232c6e9112.zip
alter model so postgres `citext` has same length options as `text`
-rw-r--r--src/main/scala/SchemaParser.scala15
1 files changed, 14 insertions, 1 deletions
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)
}
}