Compile goose into executable: what about migrations?

Issue #34 new
Ruben Vermeersch created an issue

The README (briefly) mentions that you can embed goose into the application.

Is there a way to embed the migrations into the executable as well? I'd like to keep the executable self-contained, so that it upgrades the database automatically upon start.

I'm mainly using SQL migrations, but I'll happily convert them to go migrations if needed.

Comments (5)

  1. Ruben Vermeersch reporter

    As far as I know, bindata is indeed the way to do this. The API of goose seems to be based around files, so that won't work with packaged assets.

    I'll just package the migrations alongside the app for now, probably not worth the pain to try to embed it.

  2. Ruben Vermeersch reporter

    If I were more experienced with Go (just making the switch) I'd offer to help out / would be able to tell what exactly I need to make it work.

    For now however, I'll refrain from doing that. I guess it'll be a matter of replacing the filenames / directory handling with a more general interface (plus a default implementation that uses files / directories), but I'd like to be slightly more familiar with the usual Go patterns before I can say something meaningful on the subject.

    Nonetheless, goose is an excellent module, enjoying it a lot. Thanks!

  3. jreg

    Until then a hack is to dump the migrations bindata to a tmpdir on disk to be read in by goose. I'm doing that on server startup to check for migrations though you could make it optional.

    Or re-implement goose.RunMigrations (goose.CollectMigrations being the important part).

  4. Log in to comment