cohere-toolkit

GitHub Actions for Automated DB Migrations

This guide provides instructions for setting up a GitHub Action to automatically run database migrations whenever you push changes to your repository.

Prerequisites

To set up the GitHub Action, ensure you have the following:

Steps to Set Up GitHub Actions

Overview

This guide covers different methods for executing migrations:

Setting Up the GitHub Environment and Secrets

Follow these steps to configure the GitHub environment and secrets:

  1. Navigate to your repository on GitHub.
  2. Click on the Settings tab.
  3. Select the Environments menu on the left.
  4. Click on the New environment button or choose an existing environment (we will use the Production environment in this guide).
  5. Enter the environment name and click on the Configure environment button.
  6. (Optional) Set rules for the environment, such as restricting the Production environment to the main branch.
  7. Click on the Add secret button to define the required secrets.

Running Migrations Using SSH Access

To run migrations via SSH to a remote server, set up the following secrets:

Use the sample GitHub Action workflow file located at .github/workflows/run_alembic_migrations.yml. Set the SSH_PROJECT_DIR variable to the path of your project directory on the remote server.

The action scripts are located in the .github/scripts directory:

Note:

Running Migrations on a Remote Database Using Connection Strings

To run migrations on a remote database using connection strings, configure the following secret:

If you’re using a private database, you may need to establish a VPN or SSH tunnel for access.

Running Migrations Using Cohere Toolkit’s API Migrations Endpoint

For migrations using the Cohere Toolkit’s API migrations endpoint, set up these secrets:

Default Migration Behavior