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

Conditionally running scripts in a folder #31

Open
benfoster opened this issue Jun 8, 2023 · 3 comments
Open

Conditionally running scripts in a folder #31

benfoster opened this issue Jun 8, 2023 · 3 comments

Comments

@benfoster
Copy link

Hi, thanks for your work on this project.

I wondered if it would be possible to conditionally run the scripts in a folder based on an environment variable? For example, I only to load the DB with test data when running db-up locally.

@drwatson1
Copy link
Owner

Hi,

I'm not fully understand your case. You can use environment variables in config file or scripts. For example, you can use environment variable for connection string:

dbup:
  # other options
  connectionString: $CONNSTR$
SET CONNSTR=your connection string
./dbup upgrade

Could this solve your case?

@benfoster
Copy link
Author

Hi,
Perhaps I didn't explain well. I have a collection of seed data scripts. I would like to run these after my schema changes, but only in a specific environment. Does that make sense?

@drwatson1
Copy link
Owner

Environment variables can be used almost anywhere in config file, including script folder names.

You may have two or more folders with your seed data scripts, one for each environment. Specify one of them using an environment variable: https://github.com/drwatson1/dbup-cli/wiki#script-selection.

Something like:

  scripts:
# other lines are omitted

    -   folder: $SEED_DATA$           # <<<<< Add this line

Now you can select an appropriate folder just specifying SEED_DATA environment variable.

May be this will work for you?

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

2 participants