explaingit

ariga/atlas

8,373GoAudience · developerComplexity · 3/5Setup · moderate

TLDR

A command-line tool that manages your database structure as code, automatically calculating and applying the changes needed to bring a database from its current state to the structure you describe, with built-in safety checks before anything runs.

Mindmap

mindmap
  root((repo))
    What it does
      Manages DB structure as code
      Auto-calculates changes
      Runs safety checks
    Workflows
      Declarative apply
      Versioned migrations
      Drift detection
    Databases supported
      PostgreSQL MySQL SQLite
      SQL Server ClickHouse
      Snowflake and others
    Integrations
      GitHub Actions
      Kubernetes
      Terraform
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Describe what your database tables should look like, then let Atlas calculate and apply only the changes needed instead of writing migration scripts by hand.

USE CASE 2

Generate a numbered series of migration files from schema changes and commit them to version control so every environment gets the same updates.

USE CASE 3

Add Atlas to your CI pipeline to automatically catch dangerous changes like dropped tables or columns before they reach production.

USE CASE 4

Manage database user permissions and roles alongside your schema so access control is also version-controlled.

Tech stack

GoSQLHCLTerraformKubernetesGitHub Actions

Getting it running

Difficulty · moderate Time to first run · 30min

Requires a running database to connect to, works with PostgreSQL, MySQL, SQLite, and many others out of the box.

License not specified in the explanation.

In plain English

Atlas is a command-line tool for managing the structure of a database as version-controlled code. Instead of writing migration scripts by hand each time you want to change a database table or column, Atlas lets you describe what you want the database to look like, then figures out the steps needed to get there and either shows them to you or applies them directly. There are two ways to use it. In the declarative workflow, you write a file describing your desired database structure, run a command, and Atlas calculates the difference between what the database looks like now and what you want, then applies only the changes needed. This is similar to how infrastructure tools like Terraform work. In the versioned workflow, Atlas generates a numbered series of migration files based on changes you describe, which you can review, commit to version control, and apply to any environment. The tool works with a wide range of databases including PostgreSQL, MySQL, MariaDB, SQL Server, SQLite, ClickHouse, Snowflake, and several others. Database structure can be written in SQL, in an HCL format Atlas defines, or pulled directly from the models of existing programming frameworks across multiple languages. Before applying any change, Atlas runs it through more than 50 built-in safety checks that look for things like accidentally dropped tables, columns being made non-nullable without a default value, or locks that could slow down a busy database during a deployment. These checks can be run in CI pipelines to catch problems before they reach production. There is also a testing framework that lets you write small tests for database functions, views, and triggers. Atlas includes integrations for Kubernetes, GitHub Actions, GitLab CI, Terraform, and other common deployment tools. It can manage database permissions and roles as code alongside the schema itself, and it supports detecting when a database has drifted from the expected state over time.

Copy-paste prompts

Prompt 1
I use PostgreSQL and want to try Atlas in declarative mode. Show me how to write an HCL schema file for a users table with id, email, and created_at columns, then apply it with Atlas.
Prompt 2
How do I add Atlas to a GitHub Actions workflow to check my database migration files for unsafe changes on every pull request? Give me the workflow YAML.
Prompt 3
I have an existing PostgreSQL database and want Atlas to generate a baseline migration file from its current structure. What command do I run?
Prompt 4
Atlas supports more than 50 safety checks before applying migrations. How do I see the list of checks and how do I skip one check I know is safe in my case?
Open on GitHub → Explain another repo

← ariga on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.