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

Skip to and up to options feature #137

Merged
merged 1 commit into from
Oct 16, 2015

Conversation

pedrofs
Copy link
Contributor

@pedrofs pedrofs commented Oct 10, 2015

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 VERSION

bin/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 :)

*/
protected function isUpTo(InputInterface $input)
{
return NULL !== $input->getOption('up-to');
Copy link
Member

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)

@HavokInspiration
Copy link
Member

Other than my comments, this is looking good 👍

@HavokInspiration
Copy link
Member

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--up-to with backticks

@HavokInspiration HavokInspiration self-assigned this Oct 11, 2015
*/
protected function isAllVersion($version)
{
return $version == 'all' || $version == '*';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

´===´

@pedrofs
Copy link
Contributor Author

pedrofs commented Oct 11, 2015

@HavokInspiration now I implemented it as you ask. Using --target and --exclude.

Take a look and let me know if you have any else advice :)

Cheers!

@HavokInspiration
Copy link
Member

Would you mind squashing your commits into one ?

I'll try to fully review it tonight if I get the time.
Looks good from an overall point of view though.

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
Copy link
Member

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

Copy link
Member

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).

Copy link
Member

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?

@pedrofs
Copy link
Contributor Author

pedrofs commented Oct 13, 2015

@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`'
Copy link
Member

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
Copy link
Member

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.

@HavokInspiration
Copy link
Member

Looks good to me once corrected. My comments are mainly around docblocks and output.

@pedrofs pedrofs force-pushed the skip_to_and_up_to_options branch 2 times, most recently from 3b36e31 to de3bdff Compare October 15, 2015 13:30
@pedrofs
Copy link
Contributor Author

pedrofs commented Oct 15, 2015

@HavokInspiration I did the squashing using git rebase -i origin/master and git push --force and now there are two commits that shouldn't be there (they already are on master).

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.

@HavokInspiration
Copy link
Member

You need to rebase your branch on cakephp repo master branch.
Add the cakephp repo as upstream, merge upstream/master in your local master and rebase on it.

Something like that :

git remote add upstream https://github.com/cakephp/migrations.git
git checkout master
git fetch upstream
git merge upstream/master
git checkout skip_to_and_up_to_options
git rebase master

This will make the diff of your branch start from the cakephp repo master branch.
And then do the git push with --force

@pedrofs
Copy link
Contributor Author

pedrofs commented Oct 15, 2015

@HavokInspiration thanks man. It seems good now!

ps: I used git rebase upstream/master instead

HavokInspiration added a commit that referenced this pull request Oct 16, 2015
Upgrade the `mark_migrated` to match other phinx command behavior
@HavokInspiration HavokInspiration merged commit f5bdfb5 into cakephp:master Oct 16, 2015
@HavokInspiration
Copy link
Member

Yes, I do that because I usually sync the master of my fork. But that works too !

👍 great work @pedrofs

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

Successfully merging this pull request may close these issues.

None yet

5 participants