-
Notifications
You must be signed in to change notification settings - Fork 112
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
Skip to and up to options feature #137
Skip to and up to options feature #137
Conversation
*/ | ||
protected function isUpTo(InputInterface $input) | ||
{ | ||
return NULL !== $input->getOption('up-to'); |
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.
We usually do it the other way around with the null lowercased :
if ($var === null)
Other than my comments, this is looking good 👍 |
And the doc is going to need an update as well. |
@@ -63,6 +63,12 @@ bin/cake migrations mark_migrated 20150417223600 | |||
# Since Migrations 1.3.1, a new `all` special value for the version argumentwas added. | |||
# The following will mark all migrations found as migrated. | |||
bin/cake migrations mark_migrated all | |||
|
|||
# The following option up-to will try to mark the migrations from beginning to the given version (including it) |
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.
--up-to
with backticks
*/ | ||
protected function isAllVersion($version) | ||
{ | ||
return $version == 'all' || $version == '*'; |
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.
´===´
@HavokInspiration now I implemented it as you ask. Using Take a look and let me know if you have any else advice :) Cheers! |
Would you mind squashing your commits into one ? I'll try to fully review it tonight if I get the time. |
bin/cake migrations mark_migrated 20150417223600 --target | ||
|
||
# You can use the option `--exclude` along with `--target` and it will try to mark the migrations from beginning until the given version (excluding it) | ||
bin/cake migrations mark_migrated 20150417223600 --target --exclude |
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.
These options don't make sense in context of how Phinx works.
Should rather be:
bin/cake migrations mark_migrated
instead of bin/cake migrations mark_migrated all
bin/cake migrations mark_migrated --target=20150417223600
instead of bin/cake migrations mark_migrated 20150417223600 --target
bin/cake migrations mark_migrated --target=20150417223600 --exclude
instead of bin/cake migrations mark_migrated 20150417223600 --target --exclude
With Phinx, the target (when migrating) is always assumed to be the latest version unless a --target
is specified
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.
@dakota That is a good point.
However, when the mark_migrated
command was designed, it was to only mark a bake snapshot as migrated, which is why a mandatory "target" was needed as console argument.
But now that it is becoming a full featured command, I agree it should comply with the rest of the commands.
If we are going down that path, that will break compability with userland code using the command.
It also should be known that when a snapshot is baked, all migrations up to that new one will be marked as migrated, unless we provide a way to target only one migration (even though off the top of my head, this behavior should not cause trouble).
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.
The current way of doing it would need to still function as is (but possibly show an deprecation message).
As for marking only a single migration as migrated, perhaps a --only
option is needed?
@HavokInspiration take a look. After your review I can go on with the squashing :) |
InputArgument::REQUIRED, | ||
'What is the version of the migration? Use the special value `all` to mark all migrations as migrated.' | ||
InputArgument::OPTIONAL, | ||
'DEPRECATED: use `bin/cake migrations mark_migrated`' |
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.
It should be DEPRECATED: use
bin/cake migrations mark_migrated --target=VERSION instead
} | ||
|
||
/** | ||
* Checks if the it is for only one migration |
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.
This comment should be corrected.
Looks good to me once corrected. My comments are mainly around docblocks and output. |
3b36e31
to
de3bdff
Compare
@HavokInspiration I did the squashing using Before starting out this branch I updated my master branch getting changes from upstream. I think thats because there are these two commits. Do you know how can I fix it? Thanks. |
You need to rebase your branch on cakephp repo Something like that :
This will make the diff of your branch start from the cakephp repo master branch. |
de3bdff
to
44742c1
Compare
@HavokInspiration thanks man. It seems good now! ps: I used |
Upgrade the `mark_migrated` to match other phinx command behavior
Yes, I do that because I usually sync the master of my fork. But that works too ! 👍 great work @pedrofs |
Finally now it seems right!!
Sorry for the mess.
Recommenting:
The way it was implemented it should be used like:
bin/cake migrations mark_migrated VERSION --skip-to
will mark all migrations from beginning until VERSIONbin/cake migrations mark_migrated VERSION --up-to
will mark all migrations from beginning to VERSION (including it)@HavokInspiration does it seem good?
Right now there are some duplicated logic (the migrations are being marked as migrated inside execute($input, $output) and markVersionsAsMigrated($path, $versions)). I can refactor it if you intend to merge :)