Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
A

atlas

> 编程语言
Open source

Declarative schema migrations with schema-as-code workflows

8.6K stars0 likes1 views
WebsiteGitHub

About

Declarative schema migrations with schema-as-code workflows

Atlas - Manage Your Database Schema as Code

Atlas is a language-agnostic tool for managing and migrating database schemas using modern DevOps principles. It offers two workflows:

  • Declarative: Similar to Terraform, Atlas compares the current state of the database to the desired state, as defined in an [HCL], [SQL], or [ORM] schema. Based on this comparison, it generates and executes a migration plan to transition the database to its desired state.

  • Versioned: Unlike other tools, Atlas automatically plans schema migrations for you. Users can describe their desired database schema in [HCL], [SQL], or their chosen [ORM], and by utilizing Atlas, they can plan, lint, and apply the necessary migrations to the database.

Supported Databases

PostgreSQL · MySQL · MariaDB · SQL Server · SQLite · ClickHouse · Redshift · Oracle · Snowflake · CockroachDB · TiDB · Databricks · Spanner · Aurora DSQL · Azure Fabric

Installation

macOS + Linux:

bash
curl -sSf https://atlasgo.sh | sh

Homebrew:

bash
brew install ariga/tap/atlas

Docker:

bash
docker pull arigaio/atlas

NPM:

bash
npx @ariga/atlas

See installation docs for all platforms.

Key Features

  • Declarative schema migrations: The atlas schema command offers various options for inspecting, diffing, comparing, planning and applying migrations using standard Terraform-like workflows.
  • Versioned migrations: The atlas migrate command provides a state-of-the-art experience for planning, linting, and applying migrations.
  • Schema as Code: Define your desired database schema using [SQL], [HCL], or your chosen [ORM]. Atlas supports 16 ORM loaders across 6 languages.
  • Security-as-Code: Manage roles, permissions, and row-level security policies as version-controlled code.
  • Data management: Manage seed and lookup data declaratively alongside your schema.
  • Cloud-native CI/CD: Kubernetes operator, Terraform provider, GitHub Actions, GitLab CI, ArgoCD, and more.
  • Testing framework: Unit test schema logic (functions, views, triggers, procedures) and migration behavior.
  • 50+ safety analyzers: Database-aware migration linting that detects destructive changes, data-dependent modifications, table locks, backward-incompatible changes, and more.
  • Multi-tenancy: Built-in support for multi-tenant database migrations.
  • Drift detection: Monitoring as Code with automatic schema drift detection and remediation.
  • Cloud integration: IAM-based authentication for AWS RDS and GCP Cloud SQL, secrets management via AWS Secrets Manager, GCP Secret Manager, HashiCorp Vault, and more.

Getting Started

Get started with Atlas by following the Getting Started docs.

Inspect an existing database schema:

bash
atlas schema inspect -u "postgres://localhost:5432/mydb"

Apply your desired schema to the database:

bash
atlas schema apply \
  --url "postgres://localhost:5432/mydb" \
  --to file://schema.hcl \
  --dev-url "docker://postgres/16/dev"

Getting Started docs

Migration Linting

Atlas ships with 50+ built-in analyzers that review your migration files and catch issues before they reach production. Analyzers detect destructive changes like dropped tables or columns, data-dependent modifications such as adding non-nullable columns without defaults, and database-specific risks like table locks and table rewrites that can cause downtime on busy tables. You can also define your own custom policy rules.

bash
atlas migrate lint --dev-url "docker://postgres/16/dev"

Schema Testing

Test database logic (functions, views, triggers, procedures) and data migrations with .test.hcl files:

hcl
test "schema" "postal" {
  # Valid postal codes pass
  exec {
    sql = "SELECT '12345'::us_postal_code"
  }
  # Invalid postal codes fail
  catch {
    sql = "SELECT 'hello'::us_postal_code"
  }
}

test "schema" "seed" {
  for_each = [
    {input: "hello", expected: "HELLO"},
    {input: "world", expected: "WORLD"},
  ]
  exec {
    sql    = "SELECT upper('${each.value.input}')"
    output = each.value.expected
  }
}
bash
atlas schema test --dev-url "docker://postgres/16/dev"

Testing docs

Security-as-Code

Manage database roles, permissions, and row-level security as version-controlled code:

…

Security-as-Code docs

Data Management

Manage seed and lookup data declaratively alongside your schema:

sql
CREATE TABLE countries (
  id INT PRIMARY KEY,
  code VARCHAR(2) NOT NULL,
  name VARCHAR(100) NOT NULL
);

INSERT INTO countries (id, code, name) VALUES
  (1, 'US', 'United States'),
  (2, 'IL', 'Israel'),
  (3, 'DE', 'Germany');

Data management docs

ORM Support

Define your schema in any of the 16 supported ORMs. Atlas reads your models and generates migrations:

Language ORMs
Go GORM, Ent, Bun, Beego, sqlc
TypeScript Prisma, Drizzle, TypeORM, Sequelize
Python Django, SQLAlchemy
Java Hibernate
.NET EF Core
PHP Doctrine

ORM integration docs

Integrations

Lint, test, and apply migrations automatically in your CI/CD pipeline or infrastructure-as-code workflow:

Integration Docs
GitHub Actions Versioned guide · Declarative guide
GitLab CI Versioned guide · Declarative guide
CircleCI Versioned guide · Declarative guide
Bitbucket Pipes Versioned guide · Declarative guide
Azure DevOps GitHub repos · Azure repos
Terraform Provider atlasgo.io/integrations/terraform-provider
Kubernetes Operator atlasgo.io/integrations/kubernetes
ArgoCD atlasgo.io/guides/deploying/k8s-argo
Flux atlasgo.io/guides/deploying/k8s-flux
Crossplane atlasgo.io/guides/deploying/crossplane
Go SDK pkg.go.dev/ariga.io/atlas-go-sdk/atlasexec

AI Agent Integration

Atlas provides Agent Skills, an open standard for packaging migration expertise for AI coding assistants: Claude Code, GitHub Copilot, Cursor, OpenAI Codex. Learn more at AI tools docs.

CLI Usage

schema inspect

Easily inspect your database schema by providing a database URL and convert it to HCL, JSON, SQL, ERD, or other formats.

Inspect a specific MySQL schema and get its representation in Atlas DDL syntax:

bash
atlas schema inspect -u "mysql://root:pass@localhost:3306/example" > schema.hcl
Result
hcl
table "users" {
  schema = schema.example
  column "id" {
    null = false
    type = int
  }
  ...
}

Inspect the entire MySQL database and get its JSON representation:

bash
atlas schema inspect \
  --url "mysql://root:pass@localhost:3306/" \
  --format '{{ json . }}' | jq
Result
json
{
  "schemas": [
    {
      "name": "example",
      "tables": [
        {
          "name": "users",
          "columns": [
            ...
          ]
        }
      ]
    }
  ]
}

Inspect a specific PostgreSQL schema and get its ERD representation in Mermaid syntax:

bash
atlas schema inspect \
  --url "postgres://root:pass@:5432/test?search_path=public&sslmode=disable" \
  --format '{{ mermaid . }}'
mermaid
erDiagram
    users {
      int id PK
      varchar name
    }
    blog_posts {
      int id PK
      varchar title
      text body
      int author_id FK
    }
    blog_posts }o--o| users : author_fk

Use the split format for one

Issues· 275 open

View all issuesOpen on GitHub
  • #2492

    Postgres serial and long table name

    Updated Sep 29, 2026
  • #2115

    Postgres schema inspect on Partitioned table - Error: referenced view ...

    Updated Sep 29, 2026
  • #1597

    SQLite: index dropped and created always

    Updated Sep 29, 2026
  • #3397

    [Bug?] error calling MarshalHCL when trying to inspect schema

    Updated Sep 29, 2026
  • #1351

    sql/mysql: modifying foreign-key should drop the supporting key between drop and add

    Updated Sep 29, 2026
  • #1794

    Trying to drop non existing index

    Updated Sep 29, 2026
  • #1952

    `AUTO_INCREMENT` do not work with `atlas schema diff` in mysql

    Updated Sep 29, 2026
  • #1654

    CockroachDB (and postgres?) `gin_trgm_ops` and `gist_trgm_ops` can't be set using HCL

    Updated Sep 29, 2026
  • #3644

    Some TiDB features not supported when generating migrations

    Updated Sep 29, 2026
  • #1377

    Posgtres Identity Field Error

    Updated Sep 29, 2026

> Tags

Go

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 30, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言