sam-w
sam-w

Reputation: 7687

Errors when converting to postgres

Background

I have a pretty basic Play and Slick-based application. Up to now I've been using the in-memory h2 database used by default in most of the examples.

In application.conf I have the following lines:

db.default.driver=org.h2.Driver
db.default.url="jdbc:h2:mem:play"

If I use

import play.api.db.slick.Config.driver.simple._

for any code which interacts with the database, the application knows to pull in the defines in application.conf and the following happens when I run my application:

Problem

I want to migrate to using a Postgres db, so I've changed application.conf to:

db.default.driver=org.postgresql.Driver
db.default.url="jdbc:postgresql://localhost:5432/testdb"
db.default.user=testuser

and I've added the following to my build.sbt

libraryDependencies ++= Seq(
  ...
  "org.postgresql" % "postgresql" % "9.3-1100-jdbc4"
)

However, if I write a test like the following:

import models._
import org.specs2.mutable.Specification
import play.api.db.slick.Config.driver.simple._
import play.api.db.slick.DB
import scala.language.reflectiveCalls
import play.api.test.{FakeApplication, WithApplication}

class FooSpec extends Specification {    
  "DB" should {    
    "store Foos" in new WithApplication {    
      val foos = TableQuery[FooTable]    
      DB.withSession { implicit s: Session =>
        foos.insert(Foo("bar"))
      }
    }
  }
}

I get a few errors which I don't understand:

[error] p.a.d.s.d.TableScanner$ - Got an error converting to DDL. Check whether the profile used for the Table/TableQuery is the same one used by DDL generation.

[info] foospec

[info] DB should

[info] ! store Foos

[error] SlickException: JdbcProfile has no TypeInfo for type Int/INTEGER

(I have a stack trace for the error if needed, but I've left it out for now)

Any idea what I've done wrong?

Upvotes: 3

Views: 190

Answers (1)

cvogt
cvogt

Reputation: 11270

I don't know exactly where, but you are importing different Slick drivers in different places. When artifacts taken from them get mixed up you get SlickException: JdbcProfile has no TypeInfo for type Int/INTEGER.

Upvotes: 1

Related Questions