dbmate icon indicating copy to clipboard operation
dbmate copied to clipboard

Support go1.16 io/fs.FS concept for file embedding

Open bouk opened this issue 4 years ago • 3 comments

Hi there, it would be cool if the dbmate.DB type supported an FS field, so it can be used with go 1.16 file embedding. My use case is that I want to embed dbmate into my go program, and also embed the migrations using the //go:embed directive so I don't have to ship the files separately.

I will gladly make a PR that adds this feature.

bouk avatar Feb 15 '21 15:02 bouk

Hi - I haven't used go embedding yet, but if you can make a PR and do this in a way that is not too invasive I'm happy to look at it.

amacneil avatar Feb 16 '21 07:02 amacneil

+1 I would also like to bake in my migrations using embed. It would also be great if the documentation had a quick example of using this project as an included module.

jc21 avatar Jun 13 '21 22:06 jc21

Hi ! I'm also looking to embed migrations in my binary.

@bouk can you expand about what is blocking the PR ? Go 1.16 is out for a while now so I guess we don't need to support previous versions. Golang-migrate also included this feature recently.

Thanks!

gnuletik avatar Apr 13 '22 08:04 gnuletik

@amacneil Are you open to accept a PR to support this feature?

gnuletik avatar Nov 23 '22 08:11 gnuletik

I've done some experiments here: https://github.com/Enrico204/dbmate/commit/7571bc6e5f5218601a8ca93e15977f4a6021c288

I'm using that code in production projects to apply migrations. Migrations are embedded using the standard go:embed directive.

@amacneil if you're interested, I can rebase that branch to the latest development branch and send a PR :-)

Enrico204 avatar Nov 24 '22 20:11 Enrico204

Yes I'm open to a PR for this (as long as it includes unit tests, add readme docs, etc)

amacneil avatar Nov 26 '22 20:11 amacneil

I created the PR #346 , I added a test but I'm open to suggestions. I'll add an example and the documentation asap :-)

Enrico204 avatar Dec 03 '22 16:12 Enrico204