A lightweight, embeddable Go library for database migrations using pure Go code and database/sql.
Migrator is a minimalistic, embeddable database migration library for Go applications. It provides a simple, extensible way to manage database schema changes using Go code migrations, supporting both transactional and non-transactional operations. The library is designed to be embedded directly into applications without requiring external binaries or complex dependencies.
Go developers building applications that require database schema management, particularly those who prefer writing migrations as Go functions for complex logic and want a lightweight, library-based solution.
Developers choose Migrator for its simplicity, embeddability, and support for Go code migrations with transactional flexibility, avoiding the overhead of external tools and heavy dependencies found in alternatives.
Dead simple Go database migration library.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
The entire library is a single file under 200 lines of code with minimal dependencies, making it easy to audit and embed. The README emphasizes its 'dummy implementation' and lack of heavy libraries.
Supports writing migrations as Go functions, enabling complex logic beyond plain SQL, with flexibility for transactional (*sql.Tx) or non-transactional (*sql.DB) operations. The README highlights this as a key feature over SQL-only alternatives.
Designed to integrate directly into Go applications without external binaries, avoiding separate CLI tools. The README states it's 'usage as a library, embeddable and extensible on your behalf.'
Eliminates ID collisions by ordering migrations based on the sequence passed to the migrator. The README explains that 'the order of the migrations is just the order being passed to the migrator.'
Lacks rollback functionality, following an append-only philosophy that requires adding corrective migrations instead of reverting changes. The README admits this adds complexity for error recovery and states it's not a goal.
Only explicitly tested with PostgreSQL and MySQL, so compatibility with other database/sql drivers may be uncertain. The README notes 'at the moment only PostgreSQL and MySQL are being explicitly tested.'
Missing utilities like version listing or CLI tools, requiring users to implement such features manually. The README explicitly lists these as 'not migrator objectives' that could be done in userland.