question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Use createIfNotExsists in Slick 3.3.0

See original GitHub issue

Slick 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:

https://www.lagomframework.com/documentation/current/scala/ReadSideSlick.html#Slick-Read-Side-support

Can be replacted by:

def createTable = postSummaries.schema.createIfNotExists

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

5reactions
alternegrocommented, Jun 16, 2019

createIfNotExists still tries to create indexes even if the tables exist

0reactions
ASchmidt84commented, Jul 3, 2020

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found