Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[BUG] MYSQL driver no longer respects safe updates #864

@ping-localhost

Description

@ping-localhost

Describe the Bug

golang-migrate no longer respects safe updates within MySQL.

Steps to Reproduce

  1. Create a database that has SQL_SAFE_UPDATES enabled.
  2. Run any migration which causes the migrations table to be updated.
  3. query := "DELETE FROM `" + m.config.MigrationsTable + "`" will be executed and golang-migrate will error out:

Error 1175: You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column in line 0: DELETE FROM schema_migrations

Expected Behavior

I would expect golang-migrate to respect this flag by using an additional WHERE-statement (or by using TRUNCATE).

Migrate Version

github.com/golang-migrate/migrate/v4 v4.15.2

Loaded Source Drivers

iofs (so I can use go:embed)

Loaded Database Drivers

mysql

Go Version

go version go1.19.3 darwin/amd64

Additional context

This does not happen in v4.15.1 as it used TRUNCATE (changed with #656), which is acceptable for safe updating. Might be nice if I, as a user, could select what I want to use?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions