Skip to content

Unable to execute sqlite migrations in memory mode on sqlite driver #878

Open

Description

@maciekzieba

Describe the Bug
I am using sqlite (not sqlite3) driver to execute migrations on in memory db. Db connection string:
sqlite://file:db-e0e78fb5.db?&mode=memory
with this driver if you want to have additional query parsed you need to add file: prefix (https://www.sqlite.org/uri.html)
this is different from sqlite3 which is able parse query without this prefix.

If I try to migrate with such db connection string: sqlite://file:db-e0e78fb5.db?&mode=memory
I got error:

parse "sqlite://file:db-e0e78fb5.db?mode=memory": invalid port ":db-e0e78fb5.db" after host

it is due to url parser:
https://github.com/golang-migrate/migrate/blob/master/database/sqlite/sqlite.go#L96

Steps to Reproduce
Steps to reproduce the behavior:

  1. My migration dsn 'sqlite://file:db-e0e78fb5.db?mode=memory'
  2. See error: parse "sqlite://file:db-e0e78fb5.db?mode=memory": invalid port ":db-e0e78fb5.db" after host

Expected Behavior
sqlite driver should allow to add file: prefix

Migrate Version
v4.15.2

Loaded Source Drivers
file

Loaded Database Drivers
sqlite

Go Version
go version go1.19.1 darwin/amd64

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions