For an ORM for Go that handles migrations, the first results are go-xorm/xorm (xorm is a Go ORM that includes a built-in schema synchronizer for automatic database migrations, a fluent query builder, and supports multiple SQL dialects, directly matching the need for a lightweight ORM with integrated migration capabilities), uptrace/bun (uptrace/bun is a type-safe Go ORM with a built-in schema migration tool and a SQL-first query builder, making it a comprehensive fit for this search without needing external migration tools) and go-gorm/gorm (GORM is the most popular Go ORM and natively includes AutoMigrate for schema changes, giving you a built-in migration system alongside its type-safe query builder, CRUD operations, and relational associations—exactly the all-in-one, lightweight ORM you’re looking for). go-pg/pg and ent/ent round out the shortlist. Compare the match explanations and check the project documentation against your requirements.
Discover efficient Go object-relational mapping libraries that include integrated database schema migration and versioning tools.
xorm is a relational mapper and object-relational mapping tool for Go. It translates Go structures into SQL queries and maps database rows back into native objects, providing a multi-dialect database driver that supports MySQL, PostgreSQL, SQLite, Oracle, SQL Server, and TiDB. The project features a read-write splitting manager that routes modification requests to a primary database and read requests to replicas. It includes a database schema synchronizer to automatically align table structures and indexes with application data models, as well as a fluent SQL query builder for constructing co
xorm is a Go ORM that includes a built-in schema synchronizer for automatic database migrations, a fluent query builder, and supports multiple SQL dialects, directly matching the need for a lightweight ORM with integrated migration capabilities.
Bun is a type-safe object relational mapper for Go that prioritizes SQL-first query construction and result mapping. It functions as a programmable SQL query builder, a database connection manager, and a tool for mapping database tables to Go structs. The project distinguishes itself through a multi-dialect SQL support system, allowing a single codebase to interact with different database engines via a consistent interface. It includes a built-in database observability tool for query interception, distributed tracing, and logging, as well as a schema migration tool for versioning structural c
uptrace/bun is a type-safe Go ORM with a built-in schema migration tool and a SQL-first query builder, making it a comprehensive fit for this search without needing external migration tools.
GORM is a developer-focused object-relational mapping library for Go that provides a comprehensive data persistence framework. It serves as a database access layer, allowing developers to map application structures to database tables and perform CRUD operations using a fluent, type-safe query builder instead of writing raw SQL. The library distinguishes itself through its association-aware persistence, which automatically tracks and synchronizes complex entity relationships during database operations. It utilizes a driver-agnostic interface to maintain consistent behavior across various stora
GORM is the most popular Go ORM and natively includes AutoMigrate for schema changes, giving you a built-in migration system alongside its type-safe query builder, CRUD operations, and relational associations—exactly the all-in-one, lightweight ORM you’re looking for.
pg is a PostgreSQL object-relational mapper (ORM) for Go that maps Go structs to database tables and provides a fluent query builder for constructing SQL statements programmatically. At its core, it automatically generates CREATE TABLE statements from Go struct definitions using struct tags and naming conventions, and builds queries through method chaining with placeholder-based parameter binding to prevent SQL injection. The library distinguishes itself through relation-aware join generation that automatically constructs JOIN clauses for has-one, has-many, many-to-many, and polymorphic assoc
go-pg/pg is a Go ORM for PostgreSQL that auto-generates tables from struct definitions and provides a fluent query builder, fitting the core request for an ORM with built-in migration support, though its migration capabilities are limited to schema generation rather than providing versioned up/down migrations.
Ent is a statically typed entity framework for Go that models database structures as a graph of nodes and edges. It functions as a code generation engine that transforms schema definitions into type-safe database clients, query builders, and migration scripts. By representing data as interconnected entities, the framework enables intuitive traversal of complex relationships and ensures that database interactions remain consistent with the application model at compile time. The framework distinguishes itself through its graph-based approach to data modeling and its reliance on compile-time cod
Ent is a statically typed entity framework and ORM for Go that includes a built-in migration system via code-generated migration scripts, making it a solid fit for your need for a Go ORM with integrated migrations, though its code-generation approach adds complexity beyond what "lightweight" typically implies.
Data Access Layer (DAL) for PostgreSQL, CockroachDB, MySQL, SQLite and MongoDB with ORM-like features.
upper/db is a Go database abstraction layer with ORM-like features and support for multiple databases, fitting the lightweight ORM requirement, but it does not include a built-in migration system, so it falls short of the migration capability specified.
sqlboiler is a database-first ORM generator for Go that analyzes an existing database schema to produce strongly typed structures and query helpers. It functions as a schema-driven code generator, transforming database tables and relationships into executable Go source code. The project distinguishes itself through a type-safe query builder that uses chainable modifiers to construct SQL statements, eliminating the need for raw string concatenation. It utilizes customizable text templates to generate source code, allowing for the aliasing of schema entities and the creation of custom templates
Sqlboiler is a database-first code generator that produces Go ORM code from an existing schema, rather than a lightweight runtime ORM with its own built-in migration system, so it does not directly match your need for migration capabilities.
This project is a command-line utility designed to manage database schema versioning and automate incremental schema updates. It functions as a version control system for database structures, ensuring consistency across environments by tracking applied migrations in a dedicated metadata table and executing scripts in a sequential, reliable manner. The tool distinguishes itself through a driver-based abstraction layer that supports a wide range of database engines, including various SQL and distributed cloud databases. It provides robust concurrency control through advisory locking, which prev
golang-migrate/migrate is a database schema migration tool, not an ORM—it handles versioning and incremental schema updates but does not provide the object-relational mapping, model definitions, query builder, or CRUD operations you need for a lightweight ORM.
Goose is a database schema versioning system and SQL migration tool designed for Go applications. It functions as a framework for tracking and applying incremental database changes through versioned SQL scripts, ensuring consistency across different environments. The project distinguishes itself by providing a build-time capability to exclude unused database drivers to optimize binary size and a filesystem abstraction that allows migration scripts to be bundled directly into a compiled executable. It also supports out-of-order execution logic to apply missing scripts that were created after a
Goose is a dedicated database migration tool for Go, not an ORM—it handles schema versioning and SQL migrations but lacks the object-relational mapping, CRUD operations, and query builder that this search requires.
Sequel is a relational database toolkit for Ruby that provides object-relational mapping, a fluent SQL query builder, and schema migration capabilities. It maps database tables to Ruby classes with support for associations, validations, lifecycle hooks, and eager loading, offering a comprehensive ORM layer for building data-centric applications. Sequel distinguishes itself through a plugin-based extension architecture that allows composable customization of models, databases, and datasets without relying on deep inheritance hierarchies. It includes a thread-safe connection pool with support f
Sequel is a Ruby ORM with built-in migration support, but this search is for a Go ORM — the language mismatch puts it in a neighboring category rather than directly matching the intent.
This project is a Go language driver for the SQLite database. It provides a relational database interface and a Cgo wrapper that connects Go applications to SQLite for persistent local data storage and query execution. The implementation serves as a provider for JSON document storage and local full-text search. It enables the creation, querying, and modification of JSON data and the implementation of searchable indexes for large text datasets directly within the database. The driver supports standard SQL query execution for both file-based and in-memory storage. It includes capabilities for
This is a Go SQLite database driver, not an ORM — it provides low-level SQL execution and Cgo bindings but lacks the object-relational mapping, built-in migration system, query builder, and model definitions that you are looking for in an ORM.
| Repository | Stars | Language | License | Last push |
|---|---|---|---|---|
| go-xorm/xorm | 6.6K | Go | BSD-3-Clause | |
| uptrace/bun | 4.9K | Go | BSD-2-Clause | |
| go-gorm/gorm |
| 39.8K |
| Go |
| MIT |
| go-pg/pg | 5.8K | Go | BSD-2-Clause |
| ent/ent | 17.1K | Go | Apache-2.0 |
| upper/db | 3.7K | Go | MIT |
| aarondl/sqlboiler | 7K | Go | NOASSERTION |
| golang-migrate/migrate | 18.1K | Go | other |
| pressly/goose | 10.2K | Go | other |
| jeremyevans/sequel | 5.1K | Ruby | other |