Skip to content

Conversation

@0legovich
Copy link

Closes #707

path := filepath.Join(dir, filename)
if _, err := os.Stat(path); !os.IsNotExist(err) {
_, err := os.Stat(path)
if err != nil && !os.IsNotExist(err) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest replacing this with the code mentioned in the documentation to os.IsNotExist function
!errors.Is(err, fs.ErrNotExist)

Copy link
Contributor

Choose a reason for hiding this comment

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

Also this code could be simplidfied in fort of fast failure:

_, err := os.Stat(path)
if err == nil {
	return fmt.Errorf("failed to create migration file: %w", os.ErrExist)
}

if !errors.Is(err, fs.ErrNotExist){
        return fmt.Errorf("failed to create migration file: %w", err)
}

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.

Creating two migrations at the same time

2 participants