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.

Migrations in sqlite returns no error but it doesn't do anything

See original GitHub issue
Which version and edition of Flyway are you using?

6.4.4 (latest as today)

Which client are you using? (Command-line, Java API, Maven plugin, Gradle plugin)

Gradle Plugin

Which database are you using (type & version)?

Sqlite 3.28.0 org.xerial:sqlite-jdbc:3.28.0

Which operating system are you using?

macOS Catalina 10.15.4 (19E287) Java info: openjdk 11.0.2 2019-01-15 OpenJDK Runtime Environment 18.9 (build 11.0.2+9) OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+9, mixed mode)

What did you do?

I replaced postgres with sqlite on a legacy Spark project with Gradle. Everything works well (app and tests) if I create the database and run SQL from migrations manually using a 3rd. party db client. The issue here is flywayMigrate command is not returning errors as if it ran correctly. But no database was created anywhere. Even if I created an empty file with the same name, it doesn’t apply migrations on it.

Repo: https://github.com/TwilioDevEd/browser-calls-spark/tree/next Note: Make sure you are on the next branch.

Easy to reproduce:

  1. Just clone, check out that branch
  2. source .env.example you don’t need the rest of the variables.
  3. Execute the migration command ./gradle flywayMigrate.

As a workaround, I had to create the DB manually using sqlite3 CLI so CI can pass.

What did you expect to see?
  • Creating of the mydb.db file
  • Migrations run on that file
What did you see instead?
❱ ./gradlew flywayMigrate -i
.
.
.
> Task :flywayMigrate
Caching disabled for task ':flywayMigrate' because:
  Build cache is disabled
Task ':flywayMigrate' is not up-to-date because:
  Task has not declared any outputs despite executing actions.
Database: jdbc:sqlite:mydb.db (SQLite 3.28)
Successfully validated 1 migration (execution time 00:00.000s)
Creating Schema History table "main"."flyway_schema_history" ...
Current version of schema "main": << Empty Schema >>
Migrating schema "main" to version 1 - Create ticket table
Successfully applied 1 migration to schema "main" (execution time 00:00.004s)
:flywayMigrate (Thread[Execution worker for ':',5,main]) completed. Took 0.246 secs.

BUILD SUCCESSFUL in 1s
1 actionable task: 1 executed

But no mydb.db file is created anywhere on the project.

❱ ./gradlew flywayInfo      

> Task :flywayInfo
Schema version: 1
+-----------+---------+---------------------+------+---------------------+---------+
| Category  | Version | Description         | Type | Installed On        | State   |
+-----------+---------+---------------------+------+---------------------+---------+
| Versioned | 1       | Create ticket table | SQL  | 2020-06-17 21:04:22 | Success |
+-----------+---------+---------------------+------+---------------------+---------+


BUILD SUCCESSFUL in 1s
1 actionable task: 1 executed

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
sinkcupcommented, Aug 15, 2020

@po5i if you use jdbc:h2:file:./mydb, gradle flyway will create db file at ~/.gradle/

$ find ~/.gradle/ -name '*.db'
/Users/sinkcup/.gradle/daemon/6.4.1/mydb.mv.db

if you want db file be created to current dir, you should use this config:

flyway {
    url = "jdbc:h2:file:${System.getProperty('user.dir')}/database"
    user = 'sa'
}
1reaction
DoodleBobBuffPantscommented, Aug 27, 2020

We have now documented how gradle relative paths work and this work around. Thank you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Migrations fail when SQLite database file does not exist?
It seems that migrations (sort of) fail silently when the database file does not exist. The migration executes but no db file is...
Read more >
Changes to Model does not migrate to sqlite with Django 1.7?
I just added a couple of new fields to my existing models but when I run manage makemigrations it says: No changes detected....
Read more >
Fixing ALTER TABLE errors with Flask-Migrate and SQLite
When working with a migration framework such as Flask-Migrate, it is common to end up with migration scripts that fail to upgrade or...
Read more >
SQLite Foreign Key Support
Attempting to do so does not return an error; it simply has no effect. ... The child key index does not have to...
Read more >
Prisma Migrate limitations and known issues
The datasource provider `postgresql` specified in your schema does not match the one specified in the migration_lock.toml, mysql. Please remove your current ...
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