I had a good experience with go-bindata and sql-migrate. Recently I switched to https://github.com/rakyll/statik for a number of reasons. To get statik and sql-migrate to work I did the following (note that I use latest master to get the name-spacing feature):
migrationFS, err := fs.NewWithNamespace("migrations")
if err != nil {
return fmt.Errorf("create migrations file system: %w", err)
}
migrations := &migrate.HttpFileSystemMigrationSource{
FileSystem: migrationFS,
}
// ...
But migrating fails with Error while opening 000_my_migration.sql: file does not exist.
I double checked and the file is there. So I tried to open it:
f, err := migrationFS.Open("000_my_migration.sql")
if err != nil {
return err
}
defer f.Close()
And it failed to!
To get this working, I had to prefix the filename with a /;
f, err := migrationFS.Open("/000_my_migration.sql")
if err != nil {
return err
}
defer f.Close()
I wonder if the issue is on statik side or sql-migrate. A quick upstream fix would be to just prefix the info.Name() in findMigrations() with a /. But I can't tell if this will affect others.
I had a good experience with
go-bindataandsql-migrate. Recently I switched to https://github.com/rakyll/statik for a number of reasons. To getstatikandsql-migrateto work I did the following (note that I use latest master to get the name-spacing feature):But migrating fails with
Error while opening 000_my_migration.sql: file does not exist.I double checked and the file is there. So I tried to open it:
And it failed to!
To get this working, I had to prefix the filename with a
/;I wonder if the issue is on
statikside orsql-migrate. A quick upstream fix would be to just prefix theinfo.Name()infindMigrations()with a/. But I can't tell if this will affect others.