Automatic YugabyteDB Schema Migrations with Atlas
YugabyteDB is a distributed SQL database with a PostgreSQL-compatible YSQL API.
Atlas supports YugabyteDB through the ysql:// driver, so you can inspect schemas, plan migrations, and manage schema
changes as code.
Enter: Atlas
Atlas helps developers manage their database schema as code. You provide the desired state of the schema, and Atlas plans the migration needed to move the database to that state.
In this guide, we will set up Atlas with YugabyteDB and walk through both declarative and versioned migration workflows.
Prerequisites
- Docker
- Atlas installed on your machine:
- macOS + Linux
- Homebrew
- Docker
- Windows
- CI
- Manual Installation
To download and install the latest release of the Atlas CLI, simply run the following in your terminal:
curl -sSf https://atlasgo.sh | sh
Get the latest release with Homebrew:
brew install ariga/tap/atlas
To pull the Atlas image and run it as a Docker container:
docker pull arigaio/atlas
docker run --rm arigaio/atlas --help
If the container needs access to the host network or a local directory, use the --net=host flag and mount the desired
directory:
docker run --rm --net=host \
-v $(pwd)/migrations:/migrations \
arigaio/atlas migrate apply \
--url "mysql://root:pass@:3306/test"
Download the latest release and move the atlas binary to a file location on your system PATH.
GitHub Actions
Use the setup-atlas action to install Atlas in your GitHub Actions workflow:
- uses: ariga/setup-atlas@v0
with:
cloud-token: ${{ secrets.ATLAS_CLOUD_TOKEN }}
Other CI Platforms
For other CI/CD platforms, use the installation script. See the CI/CD integrations for more details.
- An Atlas Pro account.
YugabyteDB support is available to Pro users. To use this feature, run atlas login.
Logging in to Atlas
YugabyteDB is only available on the Pro plan or during a Trial. Upgrade your plan to get started.
To use YugabyteDB with Atlas, you'll need to log in to Atlas. If it's your first time, you will be prompted to create both an account and a workspace (organization):
- Via Web
- Via Token
- Via Environment Variable
atlas login
atlas login --token "ATLAS_TOKEN"
ATLAS_TOKEN="ATLAS_TOKEN" atlas login