FriendsOfFlarum / byobu

Well integrated, advanced private discussions for your Flarum forum.
https://discuss.flarum.org/d/4762-flagrow-by-bu-well-integrated-advanced-private-discussions
MIT License
54 stars 33 forks source link

Down migration fails trying to delete an index that doesn't exist #160

Closed matteocontrini closed 2 years ago

matteocontrini commented 2 years ago

Bug Report

Current Behavior

When trying to run "down" migrations after clicking "Uninstall" on the admin page, the operation fails with:

PDOException: SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP 'users_unified_index_with_byobu_index'; check that column/key exists

The stack trace reveals the index is:

#8 /usr/local/openresty/nginx/html/flarum1/vendor/fof/byobu/migrations/2021_01_13_000000_unified_index_index.php(25): Illuminate\Database\Schema\Builder->table('users', Object(Closure))

And then it's impossible to recover from the admin panel because enabling the extension doesn't work either.

Steps to Reproduce

  1. Install the extension, enable it
  2. Disable it
  3. Attempt to "uninstall" it from the admin panel
  4. See error

Environment

BBaoVanC commented 2 years ago

I'm getting this too. Is there any workaround?

EDIT: It seems to work if you just create an index with that same name manually so it can be deleted during the uninstall. For example, this is the mysql command I used:

CREATE INDEX users_unified_index_with_byobu_index ON users (username);
clarkwinkelmann commented 2 years ago

Thanks for the report. I can confirm the issue is reproducible all of the time, if all the migrations were previously applied.

I have created a PR to fix this issue. I'll try to get it merged in the next few days.

The workarounds are indeed to either re-create the missing index so Flarum can delete it again, or drop 2021_01_13_000000_unified_index_index from the list or migrations in the migrations table to tell Flarum the index has already been removed.