silverstripe / silverstripe-linkfield

Silverstripe module for managing links
BSD 3-Clause "New" or "Revised" License
4 stars 14 forks source link

NEW Add migration task from older versions of the module #244

Closed GuySartorelli closed 3 months ago

GuySartorelli commented 4 months ago

Description

Provides a migration task and docs for upgrading from 2.x or 3.x to 4.x

Dependencies

Requires https://github.com/silverstripe/silverstripe-framework/pull/11171 for one of the unit tests.

Manual testing steps

  1. Set up some links with v3 of the module
    • be as creative as you want with it, hopefully the guide tells you how to deal with your scenario.
    • Minimally have a has_one relation to Link and a has_many relation to Link using gridfield to manage the has_many.
  2. Use the upgrade guide. Where it says to update to ^4 obviously you'll need to pull in this PR instead.

Issues

Pull request checklist

GuySartorelli commented 4 months ago

Retargetted to 4.0 so it gets included in the initial stable release.

GuySartorelli commented 3 months ago

Do a test I got this warning which is correct because I missed a step:

Migrating has_many relations.
has_one relation 'SilverStripe\LinkField\Models\Link.MyPage still exists. Cannot migrate has_many relation 'Page.MyPhoneLinks'.

However the rest of the script still processed and now my data is possibly is a weird state. What should have happened is the script should have stopped immediately and told me to fix my issues.

I don't think it matters too much, since you should create a snapshot before starting which you can roll back to. But it is friendlier to rollback for you in this case, since has_many is explicitly declared as opposed to the has_one stuff. I'll make this rollback for you.

Edit: This now throws an exception, which will trigger the rollback, and tell you that it rolled back.

GuySartorelli commented 3 months ago

Made requested changes - since they're all docs changes I haven't updated the CI run.

emteknetnz commented 3 months ago

Broken builds are expected