Home:ALL Converter>How to drop tables in slick cascade (postgreSQL)?

How to drop tables in slick cascade (postgreSQL)?

Ask Time:2016-06-24T16:48:24         Author:Der_Lump

Json Formatter

I'm using PostgreSQL. I need to drop the tables cascade, here is a code snippet from Scala-Forklift I need to override it in order to drop tables despite unknown foreign keys:

override def reset = {
val drop = MTable.getTables(None, None, None, None).flatMap { s =>
  DBIO.sequence(s filter { t =>
      t.tableType != null && t.tableType.toLowerCase == "table"
    } map { t =>
      TableQuery(new DummyTable(_, t.name.name)).schema.drop
    })
  }
  val f = db.run(drop)
  Await.result(f, Duration.Inf)
}

But I don't know how. Is it possible with the slick schemas? If not, can you please give me an example how to do it with SQL integrated in this method for all Tables in "MTable"?

Thank you very much in advance!

Author:Der_Lump,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/38009199/how-to-drop-tables-in-slick-cascade-postgresql
yy