From atlas-db-plugin
This skill should be used when the user asks to "integrate Atlas with CI/CD", "set up GitHub Actions for Atlas", "configure GitLab CI migrations", "automate database migrations", "Atlas in CI pipeline", "Docker with Atlas", "migration approval workflow", "lint migrations in CI", or needs guidance on integrating Atlas into continuous integration and deployment platforms
How this skill is triggered — by the user, by Claude, or both
Slash command
/atlas-db-plugin:skills/cicd-integrationThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Automate database migrations in your CI/CD pipelines using Atlas with GitHub Actions, GitLab CI, and other platforms.
Automate database migrations in your CI/CD pipelines using Atlas with GitHub Actions, GitLab CI, and other platforms.
name: Database Migration
on:
push:
branches: [main]
paths:
- 'schema/**'
- 'migrations/**'
- 'atlas.hcl'
jobs:
migrate:
runs-on: ubuntu-latest
steps:
# Setup Atlas
- uses: ariga/setup-atlas@v0
with:
cloud-token: ${{ secrets.ATLAS_CLOUD_TOKEN }}
# Checkout code
- uses: actions/checkout@v4
# Run migrations
- name: Apply migrations
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
run: |
atlas migrate apply \
--url "$DATABASE_URL" \
--dir file://migrations
name: Schema Migration Plan
on:
pull_request:
paths:
- 'schema/**'
- 'atlas.hcl'
jobs:
plan:
runs-on: ubuntu-latest
steps:
- uses: ariga/setup-atlas@v0
- uses: actions/checkout@v4
- name: Plan migrations
env:
DATABASE_URL: ${{ secrets.STAGING_DB_URL }}
run: |
atlas migrate diff plan_${{ github.run_id }} \
--env staging
- name: Comment PR with migration plan
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const plan = fs.readFileSync('plan.sql', 'utf8');
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '## Migration Plan\n```sql\n' + plan + '\n```'
});
name: Declarative Migration
on:
push:
branches: [main]
env:
ATLAS_CLOUD_TOKEN: ${{ secrets.ATLAS_CLOUD_TOKEN }}
jobs:
migrate-dev:
runs-on: ubuntu-latest
steps:
- uses: ariga/setup-atlas@v0
- uses: actions/checkout@v4
- name: Migrate dev database
run: |
atlas migrate apply \
--env dev \
--url "mysql://root:password@localhost/dev_db"
migrate-prod:
runs-on: ubuntu-latest
needs: migrate-dev
if: github.ref == 'refs/heads/main'
steps:
- uses: ariga/setup-atlas@v0
- uses: actions/checkout@v4
- name: Migrate production database
env:
PROD_DB_URL: ${{ secrets.PROD_DATABASE_URL }}
run: |
atlas migrate apply \
--url "$PROD_DB_URL" \
--dir file://migrations
name: Migration Lint
on:
pull_request:
paths:
- 'migrations/**'
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: ariga/setup-atlas@v0
- uses: actions/checkout@v4
- name: Lint migrations
run: |
atlas migrate lint \
--env local \
--latest 10
- name: Report results
if: failure()
run: |
echo "Migration lint failed. Review the logs above."
exit 1
stages:
- plan
- apply
variables:
ATLAS_VERSION: latest
before_script:
- curl -sSf https://atlasgo.sh | sh
plan:migration:
stage: plan
only:
- merge_requests
script:
- atlas migrate diff my_migration --env staging
artifacts:
paths:
- migrations/
expire_in: 1 hour
apply:migration:
stage: apply
only:
- main
script:
- atlas migrate apply --url $PROD_DATABASE_URL --dir file://migrations
environment:
name: production
stages:
- lint
- plan
- apply-dev
- apply-prod
variables:
ATLAS_URL_DEV: $CI_ENVIRONMENT_SLUG-db
lint:migrations:
stage: lint
script:
- atlas migrate lint --env local --latest 5
plan:staging:
stage: plan
environment:
name: staging
action: prepare
script:
- atlas migrate diff staging_$CI_COMMIT_SHA --env staging
artifacts:
paths:
- migrations/
apply:dev:
stage: apply-dev
environment:
name: development
script:
- atlas migrate apply --env dev
apply:prod:
stage: apply-prod
when: manual
environment:
name: production
script:
- atlas migrate apply --env prod
FROM arigaio/atlas:latest
WORKDIR /workspace
COPY atlas.hcl .
COPY migrations/ ./migrations/
COPY schema.hcl .
# Run migrations
CMD ["migrate", "apply", "--url", "mysql://user:pass@db/mydb"]
Use in docker-compose:
version: '3'
services:
db:
image: mysql:8
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: mydb
migrate:
image: atlas-migrations:latest
depends_on:
- db
environment:
DATABASE_URL: "mysql://root:password@db/mydb"
# GitHub Actions
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
ATLAS_CLOUD_TOKEN: ${{ secrets.ATLAS_CLOUD_TOKEN }}
# GitLab CI
variables:
DATABASE_URL: $PROD_DB_URL
ATLAS_TOKEN: $CI_JOB_TOKEN
env "prod" {
url = getenv("DATABASE_URL")
migration {
dir = "file://migrations"
auto_approve = false
}
}
apply:prod:
stage: deploy
when: manual
environment:
name: production
script:
- atlas migrate apply --env prod
review:migration:
stage: plan
script:
- atlas migrate diff preview --env staging
- cat migrations/preview.sql
artifacts:
paths:
- migrations/preview.sql
validate:migration:
stage: validate
script:
- atlas migrate apply --env staging --dry-run
# On every push to main, apply migrations
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: ariga/setup-atlas@v0
- uses: actions/checkout@v4
- run: |
atlas migrate apply \
--url ${{ secrets.PROD_DB_URL }}
# On pull request, plan & show migrations
on:
pull_request:
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: ariga/setup-atlas@v0
- uses: actions/checkout@v4
- run: |
atlas migrate diff \
--url "mysql://user:pass@localhost/test_db" \
--dir file://migrations
deploy:
strategy:
matrix:
database: [mysql, postgres, sqlite]
steps:
- run: |
atlas migrate apply \
--env ${{ matrix.database }}
DATABASE_URL secret is set--dry-run to test without connecting# Check migration status
atlas migrate status --url $DATABASE_URL
# Set to specific version if needed
atlas migrate set --url $DATABASE_URL 20240115120000
# Increase timeout for slow databases
script:
- atlas migrate apply --url $DATABASE_URL --timeout 10m
when: manualFor complete CI/CD documentation, see:
references/atlas-docs-full/guides/ci-platforms/github-declarative.md - GitHub Actions declarativereferences/atlas-docs-full/guides/ci-platforms/github-versioned.md - GitHub Actions versionedreferences/atlas-docs-full/guides/ci-platforms/gitlab-declarative.md - GitLab CI declarativereferences/atlas-docs-full/guides/ci-platforms/gitlab-versioned.md - GitLab CI versionedreferences/atlas-docs-full/guides/ci-platforms/ - All CI platform guides (Azure, Bitbucket, CircleCI)references/atlas-docs-full/guides/deploying/ - Complete deployment guidesreferences/README.md - Full documentation indexnpx claudepluginhub epochtime-ai/cc-plugins --plugin atlas-db-pluginAutomates database infrastructure as code and CI/CD with Terraform (RDS, Cloud SQL, Atlas), Kubernetes operators (CloudNativePG, Percona, CrunchyData PGO), Helm charts, GitOps configs, schema migrations, Testcontainers testing, and chaos engineering.
Provides GitOps CI/CD patterns for Atmos Terraform stacks with GitHub Actions, Spacelift, Atlantis using `atmos describe affected` for change detection in PR workflows.
Configures GitHub Actions CI/CD for Supabase: link projects, push migrations, deploy Edge Functions, generate types, test locally, create preview branches.