Repository navigation
Description
Goal
Document, and cover with a test, how to point Flyway at a libSQL database:
pass a DataSource, or use URL configuration with the jdbc:sqlite: alias and
an explicit driver class.
Why
Flyway resolves its database plugin from the URL before it opens a connection,
and it never asks DriverManager which driver accepts the URL. As a result:
-
jdbc:libsql:is not claimed by Flyway's SQLite plugin, which accepts only
jdbc:sqlite:,jdbc:sqldroid:and the p6spy prefixes:No Flyway database plugin found to handle jdbc:libsql:******** -
jdbc:sqlite:is claimed, but Flyway's plugin resolves the driver to
org.sqlite.JDBC. ProgrammaticFlyway.configure().dataSource(url, ...)
builds theDriverDataSourceeagerly and passes a null driver class, so a
laterdriver(...)is ignored:No JDBC driver found to handle jdbc:sqlite:********
This is not fixable inside the driver. It is a configuration and documentation
gap.
Workarounds that work today
- DataSource (Spring Boot, HikariCP, any pool) with either
jdbc:libsql:
orjdbc:sqlite:. Pinned by
FlywayMigrationIT#migratesThroughADataSource. - URL + explicit driver with the
jdbc:sqlite:alias, for example
Flyway.configure(new ClassicConfiguration())withsetUrl(...)and
setDriver("io.github.magnusp.libsql.jdbc.LibsqlDriver"), or the equivalent
Flyway Maven plugin /flyway.propertiesurlanddriversettings. Pinned
byFlywayMigrationIT#migrateWithUrlConfigurationAndExplicitDriver. jdbc:libsql:cannot be used with URL-based configuration at all, even with
an explicit driver, because the plugin lookup fails first. Pinned by
FlywayKnownGapsIT#libsqlUrlIsNotRecognizedByFlyway.
Session-state note
Flyway's initSql / afterConnect cannot tune connection-scoped state such as
PRAGMA foreign_keys: each auto-commit statement runs on a fresh Hrana stream
(see #83). Configure such state in the DataSource/pool, or run the statements in
an explicit transaction. The Flyway clean() consequence is tracked in #258.
Where
- Add a Flyway section to
docs/(or extendREADME.md) with the working
configurations above. - Keep the two negative pins in
FlywayKnownGapsIT. - Cross-link Keep a connection-scoped Hrana stream for auto-commit: fix last_insert_rowid() and Flyway clean() #258 for
clean()support.
Verification
- The documented snippets run against the pinned sqld container.
./mvnw -pl libsql-jdbc -am verify -Dit.test='Flyway*IT'./mvnw spotless:check
Found while adding the Flyway integration tests in #259.
Activity
test(jdbc): add Flyway integration smoke tests (#259)
docs: document the Flyway bootstrap for jdbc:libsql URLs
docs: document the Flyway bootstrap for jdbc:libsql URLs
docs: document the Flyway bootstrap for jdbc:libsql URLs
docs: document the Flyway bootstrap for jdbc:libsql URLs
docs: document the Flyway bootstrap for jdbc:libsql URLs
docs: document the Flyway bootstrap for jdbc:libsql URLs
docs: document the Flyway bootstrap for jdbc:libsql URLs (#271)