Artboard
Classic Docs
Docs Navigation

Branch specific database adapters

Let's say you are migrating your project from MySQL to PostgreSQL. You want one or more branches to use PostgreSQL, but you have chosen MySQL in your build settings on Semaphore.

One way of doing that on Semaphore is to use a custom database.yml and conditionally set an environment variable in your build commands to differentiate between adapters.

In the build command, depending on the branch name, export the environment variable like shown below.

if [ "$BRANCH_NAME" = "pg-branch"  ]; then export DB_ADAPTER=postgresql; else export DB_ADAPTER=mysql ; fi

Optionally, you can use one or more elif statements to detect more branches if needed. In the database.yml file, the adapter should be configured as follows:

...
adapter: <%= ENV["DB_ADAPTER"]%>
...

Semaphore Docs are open source — Edit on GitHub

Newsletter

Occasional lightweight product and blog updates. Unsubscribe at any time.

2009-2020 © Rendered Text. All rights reserved. Terms of Service, Privacy policy, Security.