mysql: Create the schema_migrations table using latin1 charset (#172)

Force the `schema_migrations` table to be created with `latin1` character set, to fix the behavior of dbmate in MariaDB 10.1 and older (or MySQL 5.6 and older) when the system charset has more than 1 byte per character (e.g. utf8mb4)

Closes #85
This commit is contained in:
Enrico 2020-11-02 00:02:28 +01:00 committed by GitHub
parent 5b7e6cef18
commit 2950db7131
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -194,7 +194,7 @@ func (drv MySQLDriver) DatabaseExists(u *url.URL) (bool, error) {
// CreateMigrationsTable creates the schema_migrations table
func (drv MySQLDriver) CreateMigrationsTable(u *url.URL, db *sql.DB) error {
_, err := db.Exec("create table if not exists schema_migrations " +
"(version varchar(255) primary key)")
"(version varchar(255) primary key) character set latin1 collate latin1_bin")
return err
}