I was looking for this precise feature. There's a `--log-sql` option for the migrate task that dumps the SQL executed for the migration, but I see no way to dump the SQL migration script
before actually applying the migration.
In our particular case, we have a high-volume and high-traffic production database for which the wrong migration (columns added in the wrong position, types changed without a proper non-locking strategy,...) could lock tables in the database for hours. We would like to be able to run a `dry-run` migration in the pipeline outputting the SQL that would be executed on the production DB in order for the DB administrator to review the changes and manually approve them before they get applied to the production database.
Nick mentioned Laravel provides this feature through the `--pretend` flag. Doctrine also has this feature with the `--dry-run` option, as Flyway in the Java world does. I believe this feature could not only be beneficial for all, but a requirement for some enterprise level applications where DBA approval for any database changes is a mandatory step towards production. Though theoretically a DBA could examine the Ecto migration files, DBAs I know aren't usually comfortable with (and don't even trust) anything other than SQL.