Use createIfNotExsists in Slick 3.3.0
See original GitHub issueSlick 3.3.0 is out and Lagom should move to it.
That will allow us to update the docs.
The example code:
def createTable = {
MTable.getTables.flatMap { tables =>
if (!tables.exists(_.name.name == postSummaries.baseTableRow.tableName)) {
postSummaries.schema.create
} else {
DBIO.successful(())
}
}.transactionally
}
as seen here:
Can be replacted by:
def createTable = postSummaries.schema.createIfNotExists
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Schemas - Scala's SLICK
This chapter describes how to work with database schemas in Scala code, in particular how to write them manually, which is useful when...
Read more >Scala Slick, how to create Schema ONLY if it does not exist
In Slick 3.3.0 createIfNotExists and dropIfExists schema methods were added. So: db.run(coffees.schema.createIfNotExists). Googled this question and tried ...
Read more >createIfNotExists doesn't create foreign key constraints - Lagom
DESCRIPTION: In slick 3.3.0, using createIfNotExists for a schema with composite primary key results in 'Multiple Primary Keys' error.
Read more >slick/slick - Gitter
I'm using slick 3.3.0 and have a schema that has composite primary key. I also use createIfNotExists during setting up the schema.
Read more >Slick 3.3.0 released! - Announce - Scala Users
Added createIfNotExists and dropIfExists schema methods #1704. See GitHub for the full list of commits and the issues and pull requests assigned ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
createIfNotExists still tries to create indexes even if the tables exist
@leozilla I will try it. I think their is only a small change. At the underlying library (slick) could be added “if not exists” to the index creation process. That will also prevent of this bug.