flarum / issue-archive

0 stars 0 forks source link

There is no proper error message for a missing migration file on disk on rollback #201

Open clarkwinkelmann opened 4 years ago

clarkwinkelmann commented 4 years ago

Bug Report

Current Behavior This issue mainly affects developers but could also apply to released extensions in case the developers mess something up

Steps to Reproduce

  1. Install an extension with migrations
  2. Enable the extension to run the migrations
  3. Delete one of the migration files from the vendor folder
  4. Alternative to 3: create a fake migration entry in the database for this extension
  5. Select "uninstall" in the admin or use the migrate:reset command to rollback the migrations
  6. Error "Migration file should contain an array with up/down." will be shown

Expected Behavior A separate error message should be displayed for missing files.

Additionally it would be nice for the error message to contain the name of the file causing the issue, for both types of errors. Right now it's difficult to find which file is causing the issue. I didn't manage to see it with -vvv but we can see the start of the migration name in the backtrace in the log file, but it will be truncated if it's long so it might not help.

Environment

Output of "php flarum info", run this in terminal in your Flarum directory.

Possible Solution

I suggest adding a throw in Migrator::resolve() when the file doesn't exist instead of ignoring it and inevitably resulting in the array error.

https://github.com/flarum/core/blob/d492579638fb52dafbfe65f1f36a95eb6047f7f3/src/Database/Migrator.php#L236-L243

Additional Context Related https://discuss.flarum.org/d/24453-help-with-migrations-part-2/4

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. We do this to keep the amount of open issues to a manageable minimum. In any case, thanks for taking an interest in this software and contributing by opening the issue in the first place!