Make current environment available in running migrations.

Issue #39 new
Timo Keßler created an issue

Dear Liam,

thanks for creating this great tool. I have a suggested extension, that I'm willing to implement. However I'd like to hear your thoughts before moving forward and sending a pull request.

Objective:

Make the current environment available inside a running migration.

Rationale:

Some of our go migrations need to execute specific sql depending on the target environment. E.g if env == development insert test data else insert prod data.

Suggested Solution:

  • Either declare conf globally (outside main) in goMigrationDriverTemplate (migration_go.go:113)
  • or a more conservative approach: declare a global string var initialised from conf.Env

What do think:

  • Is this an acceptable change?
  • Do you see problems that we need to address, before moving forward on this?

Thank you very much for your feedback,

Timo

Comments (4)

  1. Chad Nicely

    I agree that this would be very helpful, Timo. In a go migration that fetches values from an external configuration management system (e.g. fetch password for user creation), it's necessary to pass the environment.

    Was work ever started on this? Or did you find another solution?

  2. Log in to comment