-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
Added support for specifying aliases for migrationNamespaces #14241
Conversation
Thank you for putting effort in the improvement of the Yii framework. In order for the framework and your solution to remain stable in the future, we have a unit test requirement in place. Therefore we can only accept your pull request if it is covered by unit tests. Could you add these please? Thanks! P.S. If you have any questions about the creation of unit tests? Don't hesitate to ask for support. More information about unit tests This is an automated comment, triggered by adding the label |
I am against such change as it mixing up different terms 'namespace' and 'path alias'. |
@klimov-paul I partly agree with that. We could alternatively add another property or make |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree on having this in a separate property called $migrationPaths
a1567fc
to
2195e33
Compare
This is used to specify pathes to migrations that do not have namespaces. While not directly supported by the migration command provideded by the framework, these migrations exist in a lot of extensions because custom implementations of migration controllers out of the framework were using this approach to load multiple migrations from multiple paths. Even the framework itself currently ships non-namespaced migrations: - https://github.com/yiisoft/yii2/blob/17a1d91e4a517f4f15dce973bf3c50dd939dce63/framework/rbac/migrations/m140506_102106_rbac_init.php - https://github.com/yiisoft/yii2/blob/17a1d91e4a517f4f15dce973bf3c50dd939dce63/framework/caching/migrations/m150909_153426_cache_init.php - https://github.com/yiisoft/yii2/blob/17a1d91e4a517f4f15dce973bf3c50dd939dce63/framework/log/migrations/m141106_185632_log_init.php This change allows existing applications to adopt the new namespace-based approach while keeping existing migrations. While it would be possible to add namespaces to migrations in the application itself, it is not easily possible to add namespaces to migrations that come from external sources like extensions.
fixes yiisoft#13356 fixes yiisoft#13359
d943033
to
6ec6f8d
Compare
to be merged when yiisoft/yii2#14241 is ready.
Works nicely with this rather complex setup:
End of output:
Also work via the command line:
If the default is wrapped in |
* as the migration name contains the origin of the migration in the history, which is not the case when | ||
* using multiple migration paths. | ||
* | ||
* @see $migrationNamespaces | ||
*/ | ||
public $migrationPath = '@app/migrations'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to wrap this in brackets, so the CLI can recognize it as an array
public $migrationPath = ['@app/migrations'];
At the moment there is What's about having a singular and plural form for both - background is that you could use the singular form to inject just a single folder, while having the basic configuration still available in the plural form. So you do not have to override it with all values, plus the one you want to inject. We use this workflow i.e. for demo-data or test-data. |
The naming in plural and singluar has historical reason, in oder to keep BC we can not change it. |
Basically I am fine with this, just a more general thing from my side to add: I'd find it helpful, if I could see in advance, if a property of method accepts an alias or requires a path. So having [edit] I know that |
a general rule for this is that all parts that receive input via console or configuration accept an alias. Methods that are only called via code, e.g. FileHelper do not. |
make sure console arguments are recognized as array.
This is used to specify pathes to migrations that do not have
namespaces.
While not directly supported by the migration command provided by the
framework, these migrations exist in a lot of extensions because custom implementations
of migration controllers out of the framework were using this approach
to load multiple migrations from multiple paths.
Even the framework itself currently ships non-namespaced migrations:
This change allows existing applications to adopt the new namespace-based approach
while keeping existing migrations. While it would be possible to add
namespaces to migrations in the application itself, it is not easily possible
to add namespaces to migrations that come from external sources like
extensions.
related discussion in #13359 and #13356.
this replaces #13359