Skip to content

Postgres Driver - Flyway non-empty schema "public" without metadata table #503

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
pierrepadrixe opened this issue Jun 13, 2016 · 7 comments

Comments

@pierrepadrixe
Copy link

pierrepadrixe commented Jun 13, 2016

I've tried the postgres sqldao driver in version 0.6.2 and I am encountering the following error

Caused by: org.flywaydb.core.api.FlywayException: Found non-empty schema "public" without metadata table! Use baseline() or set baselineOnMigrate to true to initialize the metadata table.
at org.flywaydb.core.Flyway$1.execute(Flyway.java:1035)
at org.flywaydb.core.Flyway$1.execute(Flyway.java:1006)
at org.flywaydb.core.Flyway.execute(Flyway.java:1418)
at org.flywaydb.core.Flyway.migrate(Flyway.java:1006)
at spark.jobserver.io.JobSqlDAO.init(JobSqlDAO.scala:103)
at spark.jobserver.io.JobSqlDAO.(JobSqlDAO.scala:88)
... 16 more

After some research I've found that we should put initOnMigrate to true, is it a viable solution or is there another issue I could fix? Thanks

@pierrepadrixe
Copy link
Author

I am using the following sqldao in conf:

sqldao {
  # Slick database driver, full classpath
  slick-driver = scala.slick.driver.PostgresDriver

  # JDBC driver, full classpath
  jdbc-driver = org.postgresql.Driver

  jdbc {
    url = "jdbc:postgresql://xxxxx"
    user = "xxx"
    password = "xxxx"
  }

  dbcp {
    maxactive = 20
    maxidle = 10
    initialsize = 10
  }
}
flyway.locations="db/postgresql/migration"

@noorul
Copy link
Contributor

noorul commented Jun 13, 2016

Maybe dropping the database and re-creating it would fix it.

@pierrepadrixe
Copy link
Author

pierrepadrixe commented Jun 13, 2016

I created a dedicated db for spark-jobserver and it worked fine, thanks noorul.

Getting next issue which seems to be #486

Migration V0_7_0__init_tables.sql failed

SQL State : 42601
Error Code : 0
Message : ERROR: syntax error at or near "AUTO_INCREMENT"
Position: 55
Location : db/h2/migration/V0_7_0__init_tables.sql (/file:/app/spark-job-server.jar!/db/h2/migration/V0_7_0__init_tables.sql)

@noorul
Copy link
Contributor

noorul commented Jun 13, 2016

Since you are using postgresql, you should not see this getting executed.

@noorul
Copy link
Contributor

noorul commented Jun 13, 2016

This flyway.locations="db/postgresql/migration" should be at the root level, not inside jobserver namespace

@pierrepadrixe
Copy link
Author

pierrepadrixe commented Jun 13, 2016

I moved flyway.locations outside jobserver scope but didn't change anything :(

EDIT: worked fine @noorul !
while reading code I noticed that I was setting flyway.locations in spark scope and not root level :) Thanks! We should specify that in README, also shouldn't we open a GH issue tagged as "improvement" for having flyway working with already existing database (first issue that I was getting in this topic). We can close the ticket! Thanks!

val migrateLocations = config.getString("flyway.locations")

@noorul
Copy link
Contributor

noorul commented Jun 13, 2016

cdde1ca

Closing

@noorul noorul closed this as completed Jun 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants