{"id":13411998,"url":"https://github.com/ariga/atlas","last_synced_at":"2025-05-14T11:08:17.513Z","repository":{"id":36953975,"uuid":"363232643","full_name":"ariga/atlas","owner":"ariga","description":"Manage your database schema as code","archived":false,"fork":false,"pushed_at":"2025-05-06T19:41:45.000Z","size":15780,"stargazers_count":6800,"open_issues_count":202,"forks_count":290,"subscribers_count":33,"default_branch":"master","last_synced_at":"2025-05-07T10:52:36.540Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://atlasgo.io","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ariga.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-04-30T18:56:42.000Z","updated_at":"2025-05-07T10:35:42.000Z","dependencies_parsed_at":"2024-02-11T08:26:59.121Z","dependency_job_id":"8059dd1e-c57d-439e-8b7c-148f07123dd5","html_url":"https://github.com/ariga/atlas","commit_stats":{"total_commits":2616,"total_committers":78,"mean_commits":33.53846153846154,"dds":0.4766819571865444,"last_synced_commit":"dbea2268a46fab89528b9104b0d4b97f3c8ad5de"},"previous_names":[],"tags_count":93,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ariga%2Fatlas","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ariga%2Fatlas/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ariga%2Fatlas/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ariga%2Fatlas/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ariga","download_url":"https://codeload.github.com/ariga/atlas/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253788416,"owners_count":21964515,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T20:01:19.940Z","updated_at":"2025-05-14T11:08:17.445Z","avatar_url":"https://github.com/ariga.png","language":"Go","readme":"## Atlas: manage your database schema as code\n\n[![Twitter](https://img.shields.io/twitter/url.svg?label=Follow%20%40ariga%2Fatlas\u0026style=social\u0026url=https%3A%2F%2Ftwitter.com%2Fatlasgo_io)](https://twitter.com/atlasgo_io)\n[![Discord](https://img.shields.io/discord/930720389120794674?label=discord\u0026logo=discord\u0026style=flat-square\u0026logoColor=white)](https://discord.com/invite/zZ6sWVg6NT)\n\n\u003cp\u003e\n  \u003ca href=\"https://atlasgo.io\" target=\"_blank\"\u003e\n  \u003cimg alt=\"image\" src=\"https://github.com/ariga/atlas/assets/7413593/2e27cb81-bad6-491a-8d9c-20920995a186\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\nAtlas is a language-agnostic tool for managing and migrating database schemas using modern DevOps principles.\nIt offers two workflows:\n\n- **Declarative**: Similar to Terraform, Atlas compares the current state of the database to the desired state, as\ndefined in an [HCL], [SQL], or [ORM] schema. Based on this comparison, it generates and executes a migration plan to \ntransition the database to its desired state.\n\n- **Versioned**: Unlike other tools, Atlas automatically plans schema migrations for you. Users can describe their desired\ndatabase schema in [HCL], [SQL], or their chosen [ORM], and by utilizing Atlas, they can plan, lint, and apply the\nnecessary migrations to the database.\n\n## Quick installation\n\n**macOS + Linux:**\n\n```bash\ncurl -sSf https://atlasgo.sh | sh\n```\n\n**Homebrew:**\n\n```bash\nbrew install ariga/tap/atlas\n```\n\n**Docker:**\n\n```bash\ndocker pull arigaio/atlas\n```\n\n**NPM:**\n\n```bash\nnpx @ariga/atlas\n```\n\nClick [here](https://atlasgo.io/getting-started#installation) to read instructions for other platforms.\n\n## Getting started\nGet started with Atlas by following the [Getting Started](https://atlasgo.io/getting-started/) docs.\nThis tutorial teaches you how to inspect a database, generate a migration plan and apply the migration to your database.\n\n## Key features:\n\n- **Schema management**: The `atlas schema` command offers various options for inspecting, diffing, comparing, and modifying\n  database schemas.\n- **Versioned migration**: The `atlas migrate` command provides a state-of-the-art experience for planning, linting, and\n  applying migrations.\n- **Terraform support**: Managing database changes as part of a Terraform deployment workflow.\n- **[SQL], [HCL] and [ORM] support**: Atlas enables users to define their desired database schema using [HCL], [SQL], or their chosen [ORM].\n- **Multi-tenancy**: Atlas includes built-in support for multi-tenant database schemas.\n- **Cloud integration**: Atlas integrates with standard cloud services and provides an easy way to read secrets from cloud\n  providers such as AWS Secrets Manager and GCP Secret Manager.\n\n## `schema inspect`\n_**Easily inspect your database schema by providing a database URL and convert it to HCL, JSON, SQL, ERD, or other formats.**_\n\nInspect a specific MySQL schema and get its representation in Atlas DDL syntax:\n```shell\natlas schema inspect -u \"mysql://root:pass@localhost:3306/example\" \u003e schema.hcl\n```\n\n\u003cdetails\u003e\u003csummary\u003eResult\u003c/summary\u003e\n\n```hcl\ntable \"users\" {\n  schema = schema.example\n  column \"id\" {\n    null = false\n    type = int\n  }\n  ...\n}\n```\n\u003c/details\u003e\n\nInspect the entire MySQL database and get its JSON representation:\n```shell\natlas schema inspect \\\n  --url \"mysql://root:pass@localhost:3306/\" \\\n  --format '{{ json . }}' | jq\n```\n\n\u003cdetails\u003e\u003csummary\u003eResult\u003c/summary\u003e\n\n```json\n{\n  \"schemas\": [\n    {\n      \"name\": \"example\",\n      \"tables\": [\n        {\n          \"name\": \"users\",\n          \"columns\": [\n            ...\n          ]\n        }\n      ]\n    }\n  ]\n}\n```\n\u003c/details\u003e\n\nInspect a specific PostgreSQL schema and get its representation in SQL DDL syntax:\n```shell\natlas schema inspect \\\n  --url \"postgres://root:pass@:5432/test?search_path=public\u0026sslmode=disable\" \\\n  --format '{{ sql . }}'\n```\n\n\u003cdetails\u003e\u003csummary\u003eResult\u003c/summary\u003e\n\n```sql\n-- create \"users\" table\nCREATE TABLE \"users\" (\"id\" integer NULL, ...);\n-- create \"posts\" table\nCREATE TABLE \"posts\" (\"id\" integer NULL, ...);\n```\n\u003c/details\u003e\n\nInspect a specific PostgreSQL schema and get its ERD representation in the browser:\n```shell\natlas schema inspect \\\n  --url \"postgres://root:pass@:5432/test?search_path=public\u0026sslmode=disable\" \\\n  -w\n```\n\n[![ERD](https://atlasgo.io/uploads/erd-example.png)](https://gh.atlasgo.cloud/explore/40d83919)\n\n\nInspect a specific PostgreSQL schema and get its ERD representation Mermaid syntax:\n```shell\natlas schema inspect \\\n  --url \"postgres://root:pass@:5432/test?search_path=public\u0026sslmode=disable\" \\\n  --format '{{ mermaid . }}'\n```\n\n```mermaid\nerDiagram\n    users {\n      int id PK\n      varchar name \n    }\n    blog_posts {\n      int id PK\n      varchar title \n      text body \n      int author_id FK\n    }\n    blog_posts }o--o| users : author_fk\n```\n\n## `schema diff`\n_**Compare two schema states and get a migration plan to transform one into the other. A state can be specified using a\ndatabase URL, HCL or SQL schema, or a migration directory.**_\n\nCompare two MySQL schemas:\n```shell\natlas schema diff \\\n  --from mysql://root:pass@:3306/db1 \\\n  --to mysql://root:pass@:3306/db2\n```\n\n\u003cdetails\u003e\u003csummary\u003eResult\u003c/summary\u003e\n\n```sql\n-- Drop \"users\" table\nDROP TABLE `users`;\n```\n\u003c/details\u003e\n\nCompare a MySQL schema with a migration directory:\n```shell\natlas schema diff \\\n  --from mysql://root:pass@:3306/db1 \\\n  --to file://migrations \\\n  --dev-url docker://mysql/8/db1\n````\n\nCompare a PostgreSQL schema with an Atlas schema in HCL format:\n```shell\natlas schema diff \\\n  --from \"postgres://postgres:pass@:5432/test?search_path=public\u0026sslmode=disable\" \\\n  --to file://schema.hcl \\\n  --dev-url \"docker://postgres/15/test\"\n````\n\nCompare an HCL schema with an SQL schema:\n```shell\natlas schema diff \\\n  --from file://schema.sql \\\n  --to file://schema.hcl \\ \n  --dev-url docker://postgres/15/test  \n````\n\n## `schema apply`\n_**Generate a migration plan and apply it to the database to bring it to the desired state. The desired state can be\nspecified using a database URL, HCL or SQL schema, or a migration directory.**_\n\nUpdate the database to the state defined in the HCL schema:\n```shell\natlas schema apply \\\n  --url mysql://root:pass@:3306/db1 \\\n  --to file://schema.hcl \\\n  --dev-url docker://mysql/8/db1\n```\n\n\u003cdetails\u003e\u003csummary\u003eResult\u003c/summary\u003e\n\n```shell\n-- Planned Changes:\n-- Modify \"users\" table\nALTER TABLE `db1`.`users` DROP COLUMN `d`, ADD COLUMN `c` int NOT NULL;\nUse the arrow keys to navigate: ↓ ↑ → ← \n? Are you sure?: \n  ▸ Apply\n    Abort\n```\n\u003c/details\u003e\n\nUpdate the database to the state defined in a specific version of the migration directory:\n```shell\natlas schema apply \\\n  --url mysql://root:pass@:3306/db1 \\\n  --to \"file://migrations?version=20221118091226\" \\\n  --dev-url docker://mysql/8/db1\n```\n\n### Additional `schema` commands\nAtlas offers additional commands to assist users managing their database schemas. These include `schema clean` and\n`schema fmt`. For more information, see the versioned migration documentation at https://atlasgo.io/declarative/inspect.\n\n## `migrate diff`\n_**Write a new migration file to the migration directory that bring it to the desired state. The desired state can be\nspecified using a database URL, HCL or SQL schema, or a migration directory.**_\n\nCreate a migration file named `add_blog_posts` in the migration directory to bring the database to the state defined\nin an HCL schema:\n```shell\natlas migrate diff add_blog_posts \\           \n  --dir file://migrations \\\n  --to file://schema.hcl \\\n  --dev-url docker://mysql/8/test\n```\n\nCreate a migration file named `add_blog_posts` in the migration directory to bring the database to the state defined\nin an SQL schema:\n```shell\natlas migrate diff add_blog_posts \\           \n  --dir file://migrations \\\n  --to file://schema.sql \\\n  --dev-url docker://mysql/8/test\n```\n\nCreate a migration file named `add_blog_posts` in the migration directory to bring the database to the state defined\nby another database:\n```shell\natlas migrate diff add_blog_posts \\           \n  --dir file://migrations \\\n  --to mysql://root:pass@host:3306/db \\\n  --dev-url docker://mysql/8/test\n```\n\n## `migrate apply`\n_**Apply all or part of pending migration files in the migration directory on the database.**_\n\nApply all pending migration files in the migration directory on a MySQL database:\n```shell\natlas migrate apply \\\n  --url mysql://root:pass@:3306/db1 \\\n  --dir file://migrations\n```\n\nApply in **dry run** mode the first the pending migration file in the migration directory on a PostgreSQL schema:\n```shell\natlas migrate apply \\\n  --url \"postgres://root:pass@:5432/test?search_path=public\u0026sslmode=disable\" \\\n  --dir file://migrations \\\n  --dry-run\n```\n\n### Additional `migrate` commands\nAtlas offers additional commands to assist users managing their database migrations. These include `migrate lint`,\n`migrate status`, and more. For more information, see the versioned migration documentation at https://atlasgo.io/versioned/diff.\n\n### Supported databases\nMySQL, MariaDB, PostgresSQL, SQLite, TiDB, CockroachDB, SQL Server, ClickHouse, Redshift.\n\n## Supported Version Policy\n\nTo ensure the best performance, security and compatibility with the Atlas Cloud service, the Atlas team\nwill only support the two most recent minor versions of the CLI. For example, if the latest version is\n`v0.25`, the supported versions will be `v0.24` and `v0.25` (in addition to any patch releases and the\n\"canary\" release which is built twice a day).\n\n### Old Binaries\n\nAs part of the *Supported Version Policy* mentioned above, binaries for versions that were published\nmore than 6 months ago will be removed from the CDN and Docker Hub.\n\n[HCL]: https://atlasgo.io/atlas-schema/hcl\n[SQL]: https://atlasgo.io/atlas-schema/sql\n[ORM]: https://atlasgo.io/orms\n","funding_links":[],"categories":["HarmonyOS","Go","others","Database","数据库","Uncategorized","Schema","Compiled list","Data Integration Frameworks","Generators","CLI"],"sub_categories":["Windows Manager","Database Schema Migration","数据库模式迁移","Changes","plv8:"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fariga%2Fatlas","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fariga%2Fatlas","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fariga%2Fatlas/lists"}