-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Down migration on MariaDB fails if down file is empty #244
Comments
This is a bug and I've been able to reproduce it. I'm exploring potential fixes for this issue. However, I'm pretty busy right now (that's why my response was delayed), so if you know where to make the fix in I believe that |
I have a fix ready and am working on tests. Don't have a ETA on when I'll finish the tests and ship the fix. Also, I'm also not sure if this issue should be fixed. e.g. if users create a migration (empty by default) this fix will allow them to apply it. This is probably more of an issue for applying empty up migrations than empty down migrations. |
That's a good point without possibly separating the processing of up and down migrations that might be difficult and could cause other issues (have not thoroughly read the code but I do see your point).
I did test what happens when the So maybe this could be approached as less of a code issue and more of a documentation issue by updating this file https://github.com/golang-migrate/migrate/blob/master/MIGRATIONS.md to define an "empty migration" as being a missing file. |
Since migrate should be as safe as possible by default, let's leave the current behavior. e.g. migrate will continue to run empty migration files and if the database doesn't like empty queries, it'll error out appropriately. I've updated the MIGRATIONS.md file accordingly. |
Correct and clarify information around empty migrations Addresses: #244
@dhui That is acceptable and the changes to the MIGRATIONS.md file makes it clear as far as the workaround any issues with an empty (zero byte file as you cleanly put it). Thank you for taking a look into this. |
Correct and clarify information around empty migrations Addresses: golang-migrate/migrate#244
According to the documentation found here it states that having empty migrations is permitted by
migrate
:But in my experience this does not seem to be the case as trying to rollback a migration where the down file is empty results in the following error:
Steps to Reproduce
Steps to reproduce the behavior:
Expected Behavior
Since the down migration file was empty there should be no action taken other than updating the schema_migrations table to the new version and mark it as being in a clean state (as it already was before trying to rollback the migration).
Migrate Version
v4.4.0
Loaded Source Drivers
godoc-vfs, gcs, file, s3, github, gitlab, go-bindata
Loaded Database Drivers
stub, cockroach, cockroachdb, mongodb, postgresql, redshift, spanner, cassandra, clickhouse, crdb-postgres, mysql, postgres, sqlserver
Go Version
go version go1.11.5 linux/amd64
Additional context
This was tested using the prebuilt v4.4.0 binaries available on this project's releases page, and using MariaDB .5.5.60. A usable but annoying work around is to use the
force
command to skip the down migrations that are a noop like this case.Has
migrate
's stance on empty migrations file changed, thus the docs are out dated or is this something else?The text was updated successfully, but these errors were encountered: