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

Why goose is saying "no migrations to run..." #303

Closed
akefirad opened this issue Jan 26, 2022 · 5 comments
Closed

Why goose is saying "no migrations to run..." #303

akefirad opened this issue Jan 26, 2022 · 5 comments

Comments

@akefirad
Copy link

akefirad commented Jan 26, 2022

I've got a very simple example:

//go:embed migrations/*.sql
var embedMigrations embed.FS

func main() {
	db, cleanup := newDBConn(dbConnParams{password: "letmein"})
	defer cleanup()

	goose.SetBaseFS(embedMigrations)
	goose.SetDialect("postgres")

	goose.Up(db, "migrations")
}

And one migration file 1001_users.sql in the migrations folder.
I build my goose and when I run it I see:

$ build/goose
2022/01/26 17:22:14 OK    1001_users.sql
2022/01/26 17:22:14 goose: no migrations to run. current version: 1001

Everything seems to be working just fine. But I was wondering what is the second line in the log? Nothing critical, but the line is a bit confusing. I just ran the migration and everything went through, so why goose is saying "no migration to run...".
Or am I missing something?
Thanks.

@mfridman
Copy link
Collaborator

There are a few log.Printf(...) statements in goose, so this is expected behaviour.

In hindsight, we should have made explicit log output an opt-in instead of the default. We take breaking-changes very seriously so we cannot address this in the current /v3 release.. but it's something to consider for a /v4.

@mfridman
Copy link
Collaborator

One possibility would be to introduce a new flag, such as --disable-logging. But I think we want to move in the opposite direction in a future release. So this flag would be at odds with something like --verbose.

Oh, and we'll also want to make output machine-friendly too, so it can be piped into jq. This was mentioned previously here: #225

I'm going to close this issue shortly, but please feel free to share your thoughts or opinions.

@mfridman mfridman closed this as completed Feb 8, 2022
@michaelangeloio
Copy link

@mfridman can this re-examined? I'm building a CLI tool and it would be nice to disable the logging for end users.

@michaelangeloio
Copy link

For those who end up here somehow, I have the following that works:

func (cDB *CommitDB) _RunGooseMigration() error {
	originalOutput := nativeLog.Writer()
	if log.DefaultLogger.Level != log.DebugLevel {
		nativeLog.SetOutput(io.Discard)
	}
	log.Debug().Msg("Running goose migration")
	goose.SetBaseFS(embedMigrations)
	if err := goose.SetDialect("sqlite3"); err != nil {
		return err
	}
	err := goose.Up(cDB.db, "migrations")
	if err != nil {
		return err
	}
	nativeLog.SetOutput(originalOutput)
	return nil

}

@mfridman
Copy link
Collaborator

mfridman commented Dec 9, 2023

@michaelangeloio let's continue the conversation in the filed issue, see my #657 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants