mattes / migrate

Database migrations. CLI and Golang library.
Other
2.29k stars 326 forks source link

Don't error if there are no up migrations #250

Closed icco closed 7 years ago

icco commented 7 years ago
  mig, err := migrate.New("file://./db/migrations", dbUrl)
  if err != nil {
    return err
  }

  err = mig.Up()
  if err != nil {
    return err
  }

This code returns Error migrating database: no change when there are no migrations to run. That's fine tho, I just always want the database to be up to date when this function runs. How do I return healthy, should I just inspect the error?

mattes commented 7 years ago

yes, check against database.ErrNoChange (https://godoc.org/github.com/mattes/migrate#pkg-variables)