Atlas
Declarative schema migrations with schema-as-code workflows
Install / Use
/learn @ariga/AtlasREADME
Atlas - Manage Your Database Schema as Code
<p> <a href="https://atlasgo.io" target="_blank"> <img alt="Atlas banner" src="https://github.com/ariga/atlas/assets/7413593/2e27cb81-bad6-491a-8d9c-20920995a186"> </a> </p>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:
curl -sSf https://atlasgo.sh | sh
Homebrew:
brew install ariga/tap/atlas
Docker:
docker pull arigaio/atlas
NPM:
npx @ariga/atlas
See installation docs for all platforms.
Key Features
- Declarative schema migrations: The
atlas schemacommand offers various options for inspecting, diffing, comparing, planning and applying migrations using standard Terraform-like workflows. - Versioned migrations: The
atlas migratecommand 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:
atlas schema inspect -u "postgres://localhost:5432/mydb"
Apply your desired schema to the database:
atlas schema apply \
--url "postgres://localhost:5432/mydb" \
--to file://schema.hcl \
--dev-url "docker://postgres/16/dev"
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.
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:
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
}
}
atlas schema test --dev-url "docker://postgres/16/dev"
Security-as-Code
Manage database roles, permissions, and row-level security as version-controlled code:
role "app_readonly" {
comment = "Read-only access for reporting"
}
role "app_writer" {
comment = "Read-write access for the application"
member_of = [role.app_readonly]
}
user "api_user" {
password = var.api_password
conn_limit = 20
comment = "Application API service account"
member_of = [role.app_writer]
}
permission {
for_each = [table.orders, table.products, table.users]
for = each.value
to = role.app_readonly
privileges = [SELECT]
}
policy "tenant_isolation" {
on = table.orders
for = ALL
to = ["app_writer"]
using = "(tenant_id = current_setting('app.current_tenant')::integer)"
check = "(tenant_id = current_setting('app.current_tenant')::integer)"
}
Data Management
Manage seed and lookup data declaratively alongside your schema:
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');
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 |
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](https://atlasgo.io/guides/ci-platfo
Related Skills
node-connect
327.7kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
80.7kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
327.7kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
80.7kCommit, push, and open a PR
