When running migrations from the console, it's difficult to tell which log messages relate to which migration. The logs indicate what is happening, but not which migration is responsible for what is happening. It would be great if each migration logged its filename when it started to run, ideally with some sort of visual emphasis, so correlating log messages with a migration is easier to do.
The migrate / migrate/up command already does this:
> php craft migrate/up --track=craft
Yii Migration Tool (based on Yii v2.0.41-dev)
Total 1 new migration to be applied:
m201116_190500_asset_title_translation_method
Apply the above migration? (yes|no) [no]:yes
*** applying m201116_190500_asset_title_translation_method
> add column titleTranslationMethod string NOT NULL DEFAULT 'site' AFTER `url` to table {{%volumes}} ... done (time: 0.071s)
> add column titleTranslationKeyFormat text AFTER `titleTranslationMethod` to table {{%volumes}} ... done (time: 0.060s)
*** applied m201116_190500_asset_title_translation_method (time: 0.186s)
1 migration was applied.
Migrated up successfully.
I just updated the migrate/all command to mirror that for Craft 3.6, listing out the migrations (grouped by migration track) that will be run, and then outputting each migration as it鈥檚 applied.
> php craft migrate/all
Yii Migration Tool (based on Yii v2.0.41-dev)
Total 1 new Craft migration to be applied:
- m201116_190500_asset_title_translation_method
Total 1 new Craft Commerce migration to be applied:
- m201120_093135_add_locale_setting_to_email_and_pdf
Total 1 new content migration to be applied:
- m200719_143002_test
Apply the above migrations? (yes|no) [no]:yes
Backup the database? (yes|no) [no]:
Skipping database backup.
*** applying m201116_190500_asset_title_translation_method
> add column titleTranslationMethod string NOT NULL DEFAULT 'site' AFTER `url` to table {{%volumes}} ... done (time: 0.075s)
> add column titleTranslationKeyFormat text AFTER `titleTranslationMethod` to table {{%volumes}} ... done (time: 0.071s)
*** applied m201116_190500_asset_title_translation_method (time: 0.542s)
*** applying m201120_093135_add_locale_setting_to_email_and_pdf
> add column language string DEFAULT 'orderLanguage' to table {{%commerce_pdfs}} ... done (time: 0.018s)
> add column language string DEFAULT 'orderLanguage' to table {{%commerce_emails}} ... done (time: 0.025s)
*** applied m201120_093135_add_locale_setting_to_email_and_pdf (time: 0.063s)
*** applying m200719_143002_test
*** applied m200719_143002_test (time: 0.009s)
3 migrations were applied.
Migrated up successfully.
@brandonkelly This should probably be documented in the upgrade guide - just ran our first update to 3.6 on a dev site and ran into an issue with CI since migrate/all is now interactive by default. Previously, migrate/all would apply migrations without confirmation. The solution is to simply add the --interactive 0 flag to the command in the deployment process.
Noted it here: https://nystudio107.com/blog/updating-craft-cms-without-headaches#updating-to-craft-cms-3-6
...and changed it here: https://github.com/nystudio107/craft/blob/craft-webpack/cms/composer.json#L38
Even if this does end up getting fixed/changed in Craft core, tacking on an explicit --interactive=0 for commands intended for CI probably isn't a bad thing anyway tho
Fixed this for the next release, which I鈥檒l release a little later today. Craft now detects whether the shell is interactive and sets Controller::$interactive to false automatically if not (something I incorrectly assumed Yii was already doing). Which tells migrate/all (and migrate/up, etc.) to go forward without needing confirmation.
Craft 3.6.1 is out now with that fix.
I just ran a deployment with DeployHQ (Craft 3.6.4.1) and the migrate/all command was interactive. I had to quickly abort the deployment and SSH in to run the migrate/all command.
So it appears this fix hasn't (entirely) worked.
@petehjfd Craft calls ComposerUtilPlatform::isTty() to determine if it鈥檚 an interactive shell, which is a pretty well tested in the wild. So most likely the issue here is that DeployHQ is running your commands in an interactive shell, even though it鈥檚 automated. In which case you鈥檒l just need to add --interactive=0 to your migrate/all command.
Just added a note about this to the 3.6 upgrade guide.
Most helpful comment
Craft 3.6.1 is out now with that fix.