pressly / goose

A database migration tool. Supports SQL migrations and Go functions.

Home Page:http://pressly.github.io/goose/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Creating two migrations at the same time

0legovich opened this issue · comments

When creating a migration file, goose adds a prefix in timestamp format with precision to the second. If you run the goose create command twice in a second, you will get unexpected behavior:

➜  goose create test
2024/02/29 16:39:34 Created new file: 20240229133934_test.go
➜  goose create test
2024/02/29 16:39:34 goose run: failed to create migration file: %!w(<nil>)

Error in the line https://github.com/pressly/goose/blob/master/create.go#L61

To be honest with the user, I think it is necessary to return an error indicating that such a file already exists.

To be honest with the user, I think it is necessary to return an error indicating that such a file already exists.

Good catch, we should certainly expose a better error like "file already exists".