peterldowns / pgmigrate

a modern Postgres migrations CLI and library
MIT License
63 stars 3 forks source link

fix error when absolute path is provied in 'pgmigrate new --migrations' #2

Closed vvkh closed 1 year ago

vvkh commented 1 year ago

A possible fix for #1. Not sure why we need filepath.Rel at all. os.WriteFile works with both absolute and relative paths, so user can provide either and it should work out of the box.

Smoke test after the fix:

 ./main new --migrations $(pwd)/example/migrations
INFO created id=00004_generated path=/Users/vvkh/Projects/pgmigrate/example/migrations/00004_generated.sql

./main new --migrations example/migrations 
INFO created id=00004_generated path=example/migrations/00004_generated.sql
peterldowns commented 1 year ago

Not sure why we need filepath.Rel at all.

os.WriteFile works with both absolute and relative paths, so user can provide either and it should work out of the box.

You're entirely correct, we don't need it. I'm going to add a test for this case and then merge the PR. Thank you for the clear bug report and the fix.

EDIT: huh I don't have tests for the CLI yet. I'll figure that out later, and merge this now. Thanks!