-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Improved migration creation + Windows fix #352
Merged
dhui
merged 19 commits into
golang-migrate:master
from
r3code:cli-create-validate-version
Mar 10, 2020
Merged
Improved migration creation + Windows fix #352
dhui
merged 19 commits into
golang-migrate:master
from
r3code:cli-create-validate-version
Mar 10, 2020
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* Validates migration version on creation, to avoid creation of duplicated versions * Uses `os.OpenFile` with `O_CREATE|O_EXCL` to create files to avoid file collisions * Uses `filepath.Join` to concatenate paths, making `cleanPath()` not necessary * Prints generated filenames * Fixes golang-migrate#238 * Supersedes golang-migrate#250
Better for Windows OS when specify -dir as /subdir, user will see C:/subdir/0001_name.up.sql rather than /subdir/0001_name.up.sql
abs path tests fails because filepath.IsAbs() treats `/subdir` path as invalid abs path at windows when drive letter is not present
Better for Windows OS systems where `/path` can be interpreted in different ways depending on working dir
OS Windows has different interpretation of `/path`, it depends on working dir. If working dir D:\test it interprets `/path` as `D:\path`
Linux OS has less restriction on a filepath than Windows, so path invalid in windows is perfectly valid for Linux. The only invalid dir name in Linux is one ending with null string terminator (\000)
…de/migrate into cli-create-validate-version
…de/migrate into cli-create-validate-version
@dhui can you conduct a review? |
Pull Request Test Coverage Report for Build 715
💛 - Coveralls |
Pull Request Test Coverage Report for Build 709
💛 - Coveralls |
dhui
requested changes
Mar 8, 2020
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.
Thanks so much for addressing the issues in the other PR. Having all of the internal cli command methods return errors is so much cleaner!
Just a few minor fixes and this PR is ready to be merged
dhui
approved these changes
Mar 10, 2020
1 task
FPiety0521
pushed a commit
to FPiety0521/Golang-SQL
that referenced
this pull request
May 24, 2023
* CLI: Improve migration creation. * Validates migration version on creation, to avoid creation of duplicated versions * Uses `os.OpenFile` with `O_CREATE|O_EXCL` to create files to avoid file collisions * Uses `filepath.Join` to concatenate paths, making `cleanPath()` not necessary * Prints generated filenames * Fixes #238 * Supersedes #250 * CLI: change `createCmd` to return error and accept `print` parameter * feat: print out an abs path Better for Windows OS when specify -dir as /subdir, user will see C:/subdir/0001_name.up.sql rather than /subdir/0001_name.up.sql * test: fixed abs path test fail for OS Windows abs path tests fails because filepath.IsAbs() treats `/subdir` path as invalid abs path at windows when drive letter is not present * feat: print absolute path for created files Better for Windows OS systems where `/path` can be interpreted in different ways depending on working dir * test: corrected tests for OS Windows OS Windows has different interpretation of `/path`, it depends on working dir. If working dir D:\test it interprets `/path` as `D:\path` * test: fixed `dir invalid` test Linux OS has less restriction on a filepath than Windows, so path invalid in windows is perfectly valid for Linux. The only invalid dir name in Linux is one ending with null string terminator (\000) * refac(cli): *Cmd() now returns an error and not uses log.fatalErr(err) * docs: added godoc, migarate usage updated * refac(cli): code refactored * refac: removed unnecessary path covert * docs: comment added * test: fixed code review issue, noErrorExpected var removed golang-migrate/migrate#352 (comment) * docs: fixed godoc Co-authored-by: Kiyoshi '13k' Murata <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR incorporates all the features added by PR #312 to
migrate
tool, so it supersedes it.What the difference?
CreateCmd
tests fixed for Windows and Linux (dir invalid
case especially)*Cmd()
incommands.go
now returns an error on fail and do not use log.fatalErr(err).migrate create
now prints out absolute path to created files.migrate
usage docs updated.