userfrosting / UserFrosting

Modern PHP user login and management framework

Home Page:https://www.userfrosting.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[FR] Order migrations by sprinkle

avsdev-cw opened this issue · comments

When we spin up a new instance of UF with some of our stock sprinkles, the migration order is fairly random (whilst being somewhat alphabetically ordered).

It would be a lot more useful if the migration order was more predictable, e.g:

  1. Order by sprinkle
  2. Order by dependency
  3. Order alphabetically

This would be particularly helpful if we needed to roll-back a sprinkle as at the moment the sessions and throttles tables are nearly always the last to migrate. To get around it, we add the sprinkles in one by one and migrate between each step, which gets laborious for 5+ sprinkles.

P.S. I know there is an option to rollback a migration by specifying the name, but perhaps an option to rollback all migrations from a particular sprinkle would be a better feature request?

This is kind of already implement in V5 (check out the beta, wink wink). Migrations are loaded by the Sprinkle order, then by the order defined in each Sprinkle Recipe class.

But in any case (and in V4), dependent sprinkle will always be loaded first.

I don't think it's explicitly tested that way, but with the new SprinkleMigrationLocator it should be easy to add if required.

https://github.com/userfrosting/sprinkle-core/blob/e0083e514d371220a9909d65ab0269f94e9b308d/app/src/Database/Migrator/SprinkleMigrationLocator.php#L43-L62

Closing, as it shouldn't be an issue with UF5, if dependency are correctly applied in the migration definition.