Many libraries that we use in everyday work have options that we may not know about. One of them may be the option to check what SQL code is executed in case of migration in Ecto.
Checking the generated SQL
Understanding exactly what SQL commands are running is helpful to ensure safe migrations. By default, Ecto does not log the raw SQL. However, we can change it.
The following code works for both
1 mix ecto.migrate --log-migrations-sql --log-migrator-sql
--log-migrations-sql, we can get a log of SQL commands created from our migration file.
--log-migrator-sql option allows us to determine what the migrator did (transactions, table lock).
It may seem unnecessary, but sometimes it can come in handy. Especially if we want to understand how certain operations are performed or how long it will take to complete the migration.
The indicated commands apply to version 3.7.1 and later. For older versions, use
I encourage you to read more in Hexdocs.