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

v2 #9

Merged
merged 2 commits into from
Jan 23, 2018
Merged

v2 #9

merged 2 commits into from
Jan 23, 2018

Conversation

josephbuchma
Copy link
Member

@josephbuchma josephbuchma commented Dec 26, 2017

Compiles with db-journey/migrate#3

UPDATE

Now all original behavior is restored (including progress logging, ctrl-c to stop & repeat to force stop)
Also got rid of migrate "shortcut" functions.

New features

  • apply specific version (run up migration)
  • rollback specific version (run down migration)

@gravis
Copy link
Member

gravis commented Jan 9, 2018

LGTM.
I'm reviewing all projects before merging anything. Btw, db-journey already hit v2 because of incompatible changes, so it's going to be v3 :)

@gravis
Copy link
Member

gravis commented Jan 9, 2018

hmm, the api doesn't change here, no need for v3, ignore my last comment.

@josephbuchma
Copy link
Member Author

It still needs small updates, like bringing back migrations progress logging, or "press Ctrl-c to interrupt immediately" etc.
I'll wait until you review everything to be sure you're ok with what I've done so far.

@gravis
Copy link
Member

gravis commented Jan 18, 2018

Thanks for all your changes.
I have a lot of things ongoing this week, and will do my best to merge everything before next week.
Thanks for your patience.

Also moved to using instance methods
rather than migrate package funcs.
@josephbuchma
Copy link
Member Author

josephbuchma commented Jan 18, 2018

Now all original behavior is restored (including progress logging, ctrl-c to stop & repeat to force stop)
Also got rid of migrate "shortcut" functions.

New features

apply specific version (run up migration)
rollback specific version (run down migration)

@gravis
Copy link
Member

gravis commented Jan 21, 2018

You're changing too many things at once, it's becoming harder and harder to merge... :)

Copy link
Member

@gravis gravis left a comment

Choose a reason for hiding this comment

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

context is the responsibility of the caller.
Apart from that, we're good to go

func newOsInterruptCtx(done <-chan struct{}) (context.Context, func()) {
ctx, cancel := context.WithCancel(context.Background())
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt)
Copy link
Member

Choose a reason for hiding this comment

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

A lib should never presume of context behaviour.
You must pass a context to migrate, and handle this stuff in https://github.com/db-journey/journey/ instead.
That way, you let the users chose where context.Background() is created.

Copy link
Member Author

@josephbuchma josephbuchma Jan 22, 2018

Choose a reason for hiding this comment

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

I thought that commands package is not supposed to be used apart from journey CLI. And it doesn't presume context behavior. The only thing it "presumes" is that context might be canceled, which is kind of normal thing to presume when you work with context.
So passing context here from journey or whatever else won't change/break anything.

Copy link
Member Author

Choose a reason for hiding this comment

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

If you talking about os signals processing - yes, it does makes sense to move it to journey's main package if commands is used elsewhere beyond journey.

Copy link
Member

Choose a reason for hiding this comment

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

my bad, I mixed up with the migrate project.
You're right!

return nil
},
}

func logErr(err error) *log.Entry {
return log.WithError(err)
func newMigrateWithCtx(url, migrationsPath string) (*migrate.Handle, context.Context, func()) {
Copy link
Member

Choose a reason for hiding this comment

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

So, why the context.Context is not a field of *migrate.Handle?
I smell a wrong utilization of context here.

Copy link
Member Author

@josephbuchma josephbuchma Jan 22, 2018

Choose a reason for hiding this comment

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

It shouldn't be a field of *migrate.Handle. If you add context to Handle at create time, it will make this Handle useless once you cancel this context.

@gravis gravis merged commit 9088371 into db-journey:master Jan 23, 2018
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 this pull request may close these issues.

2 participants