$ show ariga/atlas
Atlas is a database schema management tool that supports both declarative and versioned workflows. It provides a CLI interface for inspecting, diffing, and applying schema changes across multiple databases (MySQL, PostgreSQL, SQLite, SQL Server, CockroachDB, etc.). The architecture is modular, with core packages for database drivers (sqlclient), migration planning/execution (migrate), HCL-based schema definition (schemahcl), and safety checking (sqlcheck). Key entry points are in cmd/atlas/internal/cmdapi for schema, migrate, and version commands. The system uses Ent ORM for migration state tracking and includes advanced features like drift detection, cloud integration, and a scripting engine for conditional migrations.
The LLM identified 5 files worth highlighting for reuse:
Implements the Analyzer interface for detecting backward-incompatible schema changes. Part of a pluggable checker framework that is isolated, well-tested, and reusable for SQL linting in other projects. Demonstrates clean separation of concerns and extensible design.
Provides bidirectional conversion between HCL and internal schema objects with an extension system for custom attributes and functions. The codec is self-contained and could be extracted for HCL-based configuration in other applications. Shows advanced HCL usage and thoughtful extensibility.
Implements a driver registration system for pluggable database support. The abstraction is clean, minimal, and follows common patterns making it highly reusable in other Go projects needing multi-database support. Well-tested and isolated from higher-level logic.
Core migration planning logic that computes schema differences and generates executable SQL. Includes efficient change grouping for ALTER statements and dialect-specific planning. The planner/executor pattern is isolated and reusable for migration systems beyond Atlas.
Implements a safe scripting engine for migration files with conditionals, assertions, and loops. The engine is self-contained and could be extracted for SQL templating in other migration tools. Demonstrates non-obvious skill in designing a limited, secure DSL for schema changes.