Laravel-inspired database migrations for Go
Get running in 60 seconds
Chain methods elegantly with a Laravel-inspired syntax that feels natural and readable.
PostgreSQL, MySQL, and SQLite support using standard database/sql package.
Full rollback functionality with batch tracking for safe schema changes.
Simple configuration with .env files - no complex connection strings needed.
Full foreign key support with cascading actions and relationship management.
Leverage Go's type system for compile-time safety and excellent IDE support.
No setup required! Automatically creates migration runner on first use.
Automatically formats migration names with create_ prefix and _table suffix.
Automatically handles MySQL reserved keywords like limit, order, and type.
Populate your database with test data using structs or maps with automatic snake_case conversion.
Clean, expressive syntax for defining your schema
package migrations
import "github.com/ichtrojan/olympian"
func init() {
olympian.RegisterMigration(olympian.Migration{
Name: "create_users_table",
Up: func() error {
return olympian.Table("users").Create(func() {
olympian.Uuid("id").Primary()
olympian.String("email").Unique()
olympian.String("password")
olympian.Boolean("verified").Default(false)
olympian.Timestamps()
})
},
Down: func() error {
return olympian.Table("users").Drop()
},
})
}
olympian.Table("posts").Create(func() {
olympian.Uuid("id").Primary()
olympian.String("user_id")
olympian.String("title")
olympian.Text("content")
olympian.Foreign("user_id").
References("id").
On("users").
OnDelete("cascade")
olympian.Timestamps()
})
olympian.Table("users").Modify(func() {
olympian.Text("bio").Nullable()
olympian.String("avatar").Nullable()
olympian.Integer("age").After("name")
})
Powerful command-line interface for managing migrations
Run all pending migrations
Create a new migration file with smart naming (automatically adds create_ and _table)
Rollback the last batch of migrations
Show migration status
Rich set of column types for any schema
UUID primary keys
VARCHAR(255)
Long text content
Integer numbers
True/false values
Date and time
JSON/JSONB data
Precise decimals
olympian.String("email").Nullable()
olympian.Uuid("id").Primary()
olympian.String("username").Unique()
olympian.Boolean("active").Default(true)
olympian.Integer("age").After("name")
olympian.Integer("id").AutoIncrement()
Populate your database with test or initial data
Field names are automatically converted to snake_case. time.Time is converted to timestamp format. Pass a slice for multiple records.
type User struct {
ID string
Name string
UserAge int // becomes user_age
CreatedAt time.Time // converted to timestamp
}
olympian.Seed("users", []User{
{ID: "1", Name: "John", UserAge: 25, CreatedAt: time.Now()},
{ID: "2", Name: "Jane", UserAge: 30, CreatedAt: time.Now()},
})
olympian.Seed("users",
map[string]interface{}{
"id": "uuid-1",
"name": "John Doe",
"email": "john@example.com",
},
)
package seeders
import "github.com/ichtrojan/olympian"
func init() {
olympian.RegisterSeeder(olympian.Seeder{
Name: "user",
Run: func() error {
return olympian.Seed("users",
map[string]interface{}{
"id": "uuid-here",
"name": "John Doe",
},
)
},
})
}
Olympian brings the elegance of Laravel's migration system to Go. If you've ever wished for a more expressive way to manage database schemas in Go, Olympian is your answer.