gitmyhub

atlas

Go ★ 8.5k updated 3d ago

Declarative schema migrations with schema-as-code workflows

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.

GoSQLHCLTerraformKubernetesGitHub Actionssetup: moderatecomplexity 3/5

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.

Where it fits