gogoose

Is there a way to set the database(test, prod) when performing a goose migration?


I'm trying to create 3 different inserts for each stand, but didn't found the correct way to do it. For example, in liquidbase it was possible to specify the desired context and then migrations were applied only in the right places. I want to see something like: -- +goose context:test, dev


Solution

  • It could be a decision to create separated directories for each stand, and call the goose for the needed one:

    migrations/
    ├── test/
    │   └── 20240404140605_create_table.sql
    └── dev/
        └── 20240404140605_create_table.sql
    
    goose -dir ./migrations/dev up
    

    As I know, there is no feature in goose to separate the "contexts" inside the migration file.