Transaction is necessary in the migration file?
Hi
May I know if we need to wrap the migration in a transaction like the following?
or this is taken care by the migrator?
4 Replies
Hey 👋
Taken care of in the migrator, if you're using a database that supports transactional DDL.
@Igal (mobile) Uh ... it looks like MySQL 8 is not supporting transactional DDL, and I will have to add the transaction in the migration file.
Thanks to point out this and this could be useful to mention in https://kysely.dev/docs/migrations too
See also https://www.bytebase.com/blog/postgres-vs-mysql-ddl-transaction/
Migrations | Kysely
Migration files
Bytebase
Postgres vs. MySQL: DDL Transaction Difference
Database schema changes are critical operations that require careful planning and execution. The ability to perform these changes safely and reliably is a key c...
It won't help you.
MySQL doesnt support transactional DDL. The trandaction will commit prematurely after the first DDL query you run with it.
You're right, I'm seeing the issue now.