#822·goose

Migrations table creation and insert fails on MySQL during transaction

Author: JuozasVainauskasCreated Sep 9, 2024Updated Sep 22, 2026
Labelsneeds investigation

MySQL does not support transactions on CREATE operation:

https://github.com/pressly/goose/blob/198457304dfe6074066746ba4e1869f00dd7517c/migrate.go#L249-L263 part fails because transactions are used. When this code is invoked, the table is created successfully but insert fails and we get the state where we have empty goose_db_version table since transaction does not rollback table creation. Later, following migrations fail with error:

2024/09/09 13:01:19 database migration failed: no next version found

Would it be possible to run createVersionTable function without transaction for MySQL dialect? This solution would work and fix our problem. I could implement this but need some guidance and ideas how I could code it up.