Skip to content
This repository has been archived by the owner on Jun 28, 2018. It is now read-only.

sqlite3.go is included even when not needed. #40

Closed
didip opened this issue Apr 24, 2015 · 9 comments
Closed

sqlite3.go is included even when not needed. #40

didip opened this issue Apr 24, 2015 · 9 comments

Comments

@didip
Copy link

didip commented Apr 24, 2015

The database I am using is PostgreSQL and I got this error when calling migrate upSync method:

../../mattes/migrate/driver/sqlite3/sqlite3.go:10:2: C source files not allowed when not using cgo: sqlite3-binding.c

The error breaks GOOS=linux go build on darwin machine. Is it possible to include driver only when needed?

For example, instead of having 1 constructor that handles them all here: https://github.com/mattes/migrate/blob/master/driver/driver.go#L44, maybe you can have 1 constructor per driver file.

@twirrim
Copy link

twirrim commented May 15, 2015

It's not particularly clear to me what it's expecting to find, either, though I may be being completely blind. I ran into this even though I have, and am using, sqlite3 and its libraries on my machine.

@ansel1
Copy link

ansel1 commented May 26, 2015

Would it be possible to enable database drives via build constraints? i.e. +build mysql. Most projects will only ever need a single database. Without build constraints, we end up pulling in many unnecessary dependencies. Or, support databases executable plugins.

@mattes
Copy link
Owner

mattes commented May 28, 2015

Copied from #37. I think we should follow the database/sql approach:

import (
  "github.com/mattes/migrate/migrate"
  _ "github.com/mattes/migrate/driver/mysql"
)

func main() {
  migrate.MigrateUp("mysql", ...)
}

The binary migrate would still include all drivers.

@didip
Copy link
Author

didip commented May 29, 2015

Yes! That would be a good solution.

@didip
Copy link
Author

didip commented May 31, 2015

Also, just an idea, you can start the refactoring from the sqlite driver first since it is the most problematic ones. And then, progressively work on the other drivers.

lepoetemaudit added a commit to lepoetemaudit/migrate that referenced this issue Jun 11, 2015
Requires activating drivers with a _ style import, e.g.
import "_ github.com/mattes/migrate/driver/postgres"
@schickling
Copy link

+1 any news on this?

@maxekman
Copy link

I would also like to see this added! We build with cgo off and sqlite3 can't do that.

@przmv
Copy link

przmv commented Sep 29, 2015

+1
we aren't able to build our project with CGO_ENABLED=0 because of it, and we aren't even using sqlite

@mattes
Copy link
Owner

mattes commented Sep 30, 2015

Closing in favor of #43

@mattes mattes closed this as completed Sep 30, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants