Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add migrations path to config #64

Open
seregayoga opened this issue Aug 4, 2022 · 5 comments
Open

Add migrations path to config #64

seregayoga opened this issue Aug 4, 2022 · 5 comments

Comments

@seregayoga
Copy link

My use case: I always run tern <command> --migrations ./migrations ... so the config is in the root of the project and migrations are in ./migrations.
So I would like to omit --migrations ./migrations when calling commands. What if we can have it in the config?

@jackc
Copy link
Owner

jackc commented Aug 5, 2022

I've found that inconvenient as well.

In the v2-dev branch I've 4bdf795 added TERN_CONFIG and TERN_MIGRATIONS environment variables to eliminate the need to specify the config path or migrations path. Combine that with https://direnv.net/ and you shouldn't have to specify paths again.

As far as also putting it in the config, it's possible. But one annoying issue is how to handle relative paths. Is it relative to the config file or the working directory tern is run from?

@seregayoga
Copy link
Author

But one annoying issue is how to handle relative paths. Is it relative to the config file or the working directory tern is run from?

Is it allowed to have relative path for config in TERN_CONFIG? I would say relative to the working directory as how I typically run migrations in the terminal open in the root of the project. But it would be nice to hear other opinions.

@jackc
Copy link
Owner

jackc commented Aug 6, 2022

Is it allowed to have relative path for config in TERN_CONFIG?

Yes. That's exactly what I do. My .envrc has this in it:

export TERN_CONFIG=postgresql/tern.conf
export TERN_MIGRATIONS=postgresql/migrations

@jrschumacher
Copy link

Given that tern must be run in the same directory as the config file (when not using --config) I would think that the relative paths would resolve to being relative to the config.

The direnv approach is nice for my local setup, but I won't be able to convince my team to install yet another dev tool. Currently, to make migrations friendly to the team, I am mapping tern in our make file make tern ARG="new init".

Would this work:

[migrations]
# path to migrations (default: current directory)
# path = 
# resolve path based on config or command (default: config)
# path_resolver = config 

@iamwavecut
Copy link

Concider documenting it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants