Home:ALL Converter>Slick ddl create table order with foreign key dependency on other tables

Slick ddl create table order with foreign key dependency on other tables

Ask Time:2014-09-23T06:00:31         Author:Vikas Pandya

Json Formatter

I am using Slick code generator. with Postgresql. slick generates

lazy val ddl = table1.ddl ++ table2.ddl ++ table3.ddl ++ table4.ddl 

Now writing a beforeEach()

 override def beforeEach() {
    testdb withSession { implicit session =>
      ddl.drop
      ddl.create
 }

In running ddl it throws sql exceptions due to it trying to create tables which have foreign key on other tables which aren't yet created. how do you run slick created ddl to get away with this issue? I would imagine this to be a common situation of how you use ddl in slick

Author:Vikas Pandya,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/25983759/slick-ddl-create-table-order-with-foreign-key-dependency-on-other-tables
yy