Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can you guys just provide some good documentation and some examples with mysql also? #611

Open
2kAyush opened this issue Oct 12, 2023 · 4 comments
Labels

Comments

@2kAyush
Copy link

2kAyush commented Oct 12, 2023

There are literally no help for some commands like build and init.. and there is literally no documentation for initial setup Please make a good documentation. Also if possible add some example for .go file migrations with mysql as the driver.

@mfridman
Copy link
Collaborator

Thanks for the feedback, there's definitely room for improvement.

We've been meaning to find time to update the examples, docs and add more tutorials, examples and in-depth posts, but with a small team of maintainers it's been challenging.

@2kAyush
Copy link
Author

2kAyush commented Oct 12, 2023

Thanks for the feedback, there's definitely room for improvement.

We've been meaning to find time to update the examples, docs and add more tutorials, examples and in-depth posts, but with a small team of maintainers it's been challenging.

Actually I went through it used the same example.. but it's not working properly. I wrote simple migration in go and then did binary build of it and then ran it as said in the example but I am getting this error:

$ ./goose-custom mysql "api:password@/goose_test?parseTime=true" up
./goose-custom: line 1: syntax error near unexpected token newline' ./goose-custom: line 1: !'

my folder structure is this:

migrations
- 20231012171221_init_db.go
- goose-custom

please tell me what to do here!.

@2kAyush
Copy link
Author

2kAyush commented Oct 13, 2023

I am getting this error also even tho I did a binary build it's still saying the same.
@mfridman
I tried a lot of things but it's still not working..

2023/10/13 09:05:54 Goose failed: ERROR migrations/20231012171221_init_db.go: failed to run Go migration: Go functions must be registered and built into a custom binary (see https://github.com/pressly/goose/tree/master/examples/go-migrations)

@mfridman
Copy link
Collaborator

You typically have to do a blank import of the package your go migrations are in.

I updated a goose demo repository that does both embedding and go migrations, which can be found here:

https://github.com/mfridman/goose-demo

If you put together a reproducible example and push it up to GitHub I can take a look at what's wrong.

The most important thing is this line:

import (
	"database/sql"
	"log"
	"os"

# In this example we're importing migrations because we're also embedding, if you're not embedding, 
# then you'll need to have a blank import like so:
-	"github.com/mfridman/goose-demo/migrations"
+      _ "github.com/mfridman/goose-demo/migrations"
	"github.com/pressly/goose/v3"
	_ "modernc.org/sqlite"
)

@mfridman mfridman added the Docs label Nov 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants