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

add "plan" command #16

Merged
merged 3 commits into from
Sep 28, 2018
Merged

add "plan" command #16

merged 3 commits into from
Sep 28, 2018

Conversation

emicklei
Copy link
Owner

No description provided.

@@ -60,6 +61,14 @@ func cmdCreateMigration(c *cli.Context) error {
}

func cmdMigrationsUp(c *cli.Context) error {
return runMigrations(c, !true)

Choose a reason for hiding this comment

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

why !true instead of false?

Copy link
Owner Author

Choose a reason for hiding this comment

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

looks nice

Choose a reason for hiding this comment

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

:' )

@@ -139,6 +160,17 @@ func cmdMigrationsDown(c *cli.Context) error {
return nil
}

func largestWithOf(list []Migration) int {

Choose a reason for hiding this comment

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

largestWidthOf, not largestWithOf

Copy link
Owner Author

Choose a reason for hiding this comment

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

typo

reportError(mtx.stateProvider.Config(), "save state", err)
return errAbort
log.Printf("%s %-"+strconv.Itoa(prettyWidth)+"s (%s)\n", leadingTitle, pretty(each.Filename), each.Filename)
if isLogOnly {

Choose a reason for hiding this comment

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

Extract to a func that accepts 1 param (isLogOnly)

will reduce the size of this function significantly maybe a runAll private function?

prettyWidth = len(pf)
}
}
prettyWidth := largestWithOf(all)

Choose a reason for hiding this comment

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

Don't forget to rename this after renaming the function

Copy link
Owner Author

Choose a reason for hiding this comment

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

refactor tooling helps here

@@ -84,26 +93,38 @@ func cmdMigrationsUp(c *cli.Context) error {
reportError(mtx.stateProvider.Config(), "up until stop", errors.New("No such migration file: "+stopAfter))
return errAbort
}
prettyWidth := largestWithOf(all)

Choose a reason for hiding this comment

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

largestWidthOf
note the D

@emicklei emicklei merged commit db5c2cc into master Sep 28, 2018
@emicklei emicklei deleted the plan branch November 7, 2018 12:33
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