migrate
migrate copied to clipboard
'migrate create' will generate filenames that cannot be parsed
Describe the Bug
migrate create allows you to generate filenames that cannot be parsed
Steps to Reproduce
Use migrate create to create a migration:
my_name="init"
go run -tags 'postgres' -- \
github.com/golang-migrate/migrate/v4/cmd/migrate create \
-dir ./migrations/
-tz 'America/Denver'
-format '2006-01-02_15-04-05-0700'
-ext sql "$my_name"
migrations/2022-04-21_16-26-25-0600_init.up.sql
migrations/2022-04-21_16-26-25-0600_init.down.sql
Try to run the migration:
go run -tags 'postgres' -- \
github.com/golang-migrate/migrate/v4/cmd/migrate
-source file://migrations/ \
-database "$DB_URL" \
up
error: first .: file does not exist
Expected Behavior
- Error out when
-format <date string>will generate a filename that can't be parsed - Accept the same
-formatwithupas can be used withcreate
Migrate Version
v4.15.1
Loaded Source Drivers
N/A (file)
Loaded Database Drivers
postgres
Go Version
go version go1.18.1 darwin/amd64
Since you're using a custom time format that's incompatible with the default one, you'll also need to use a custom parser or regex