Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support upgrade steps in subdirectories #217

Open
ale-rt opened this issue Jun 25, 2021 · 3 comments · May be fixed by #226
Open

Support upgrade steps in subdirectories #217

ale-rt opened this issue Jun 25, 2021 · 3 comments · May be fixed by #226

Comments

@ale-rt
Copy link
Contributor

ale-rt commented Jun 25, 2021

I would like to organize the upgrade steps in a way similar to what https://github.com/plone/plone.app.upgrade/tree/master/plone/app/upgrade/ does, i.e. all the upgrade steps for version X.Y.Z will be stored in the folder vX.

If I try to configure multiple folders for the same profile, something like:

    <upgrade-step:directory
        profile="my.package:default"
        directory="v1"
        />
    <upgrade-step:directory
        profile="my.package:default"
        directory="v2"
        />

The main advantage is that I can easily remove the old upgrade steps when wanted.
Let's say I want to support the upgrades for two versions, when I switch to version 3 I can simply remove the v1 folder.

The problem is that with the configuration above I get a ConfigurationConflictError:

zope.configuration.config.ConfigurationConflictError: Conflicting configuration actions
...
    <upgrade-step:directory
        profile="my.package:default"
        directory="v1"
        />
    <upgrade-step:directory
        profile="my.package:default"
        directory="v2"
        />
...

If I change the zcml like:

    <upgrade-step:directory
        profile="my.package:default"
        directory="."
        />

the directory scanner will not look inside the v1 and v2 folders.

Do you guys have any idea on how to achieve my goal?

@ale-rt
Copy link
Contributor Author

ale-rt commented Jun 25, 2021

BTW with this patch ale-rt@5e480a6 the directory scanner can find the upgrade steps in the subdirs, but before adding a PR I would like to know what do you think about that.

@buchi
Copy link
Member

buchi commented Jul 4, 2021

@ale-rt No objections for supporting upgrade steps in subdirectories.

The approach by patching the directory scanner to search recursively for upgrades seems simple and ok to me.

Supporting multiple directories in ZCML should be easy as well. Basically we just need to add directory to the list of discriminators. However there's a check that ensures that the profile does not define a version. But the first upgrade-step:directory directive will set the version and the check will fail for subsequent directives. This can be easily solved by adding some marker to the profile info when the version was set by ftw.upgrade.

So it's basically a question wether to declare directories explicitly or include subdirectories implicitly. Both approaches seem ok to me and I do not really prefer either one.

ale-rt added a commit to ale-rt/ftw.upgrade that referenced this issue Jun 29, 2022
ale-rt added a commit to ale-rt/ftw.upgrade that referenced this issue Jun 29, 2022
@ale-rt
Copy link
Contributor Author

ale-rt commented Jun 29, 2022

Almost a year later I found some time to contribute a patch, see #226.
I went for the explicit way (allowing to declare multiple upgrade folders in the zcml) because the version proposed in ale-rt@5e480a6 caused a test failure.

Speaking about tests, I tried to play with ftw.builder a bit but I had some troubles to grok how to use it to cover this feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants