mirror of https://github.com/status-im/migrate.git
Prevents MySQL driver to failing when version table alredy exists
The MySQL driver is using `CREATE TABLE IF NOT EXISTS`, which causes the MySQL database to raise warnings. The golang driver collects the warnings and return a composite object (mysql.MySQLWarnings) as an error that needs to be properly handled. This change stops the driver from failing in case there are only warnings.
This commit is contained in:
parent
150ce9b524
commit
c94461932f
|
@ -50,9 +50,12 @@ func (driver *Driver) Close() error {
|
|||
}
|
||||
|
||||
func (driver *Driver) ensureVersionTableExists() error {
|
||||
if _, err := driver.db.Exec("CREATE TABLE IF NOT EXISTS " + tableName + " (version int not null primary key);"); err != nil {
|
||||
_, err := driver.db.Exec("CREATE TABLE IF NOT EXISTS " + tableName + " (version int not null primary key);")
|
||||
|
||||
if _, isWarn := err.(mysql.MySQLWarnings); err != nil && !isWarn {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue