Documentation
¶
Index ¶
- func Down(steps int) error
- func Register(migration *Migration)
- func Up() error
- type Column
- type Migration
- type MigrationRegistry
- type MigrationStatus
- type Migrator
- func (m *Migrator) CreateTable(name string, fn func(*TableBuilder)) error
- func (m *Migrator) Down(steps int) error
- func (m *Migrator) DropTable(name string) error
- func (m *Migrator) Fresh() error
- func (m *Migrator) Raw(sql string) error
- func (m *Migrator) SetMigrationsPath(path string)
- func (m *Migrator) Status() ([]MigrationStatus, error)
- func (m *Migrator) Up() error
- type TableBuilder
- func (t *TableBuilder) Boolean(name string) *TableBuilder
- func (t *TableBuilder) Default(value interface{}) *TableBuilder
- func (t *TableBuilder) ID() *TableBuilder
- func (t *TableBuilder) Integer(name string) *TableBuilder
- func (t *TableBuilder) Nullable() *TableBuilder
- func (t *TableBuilder) String(name string, length ...int) *TableBuilder
- func (t *TableBuilder) Timestamps() *TableBuilder
- func (t *TableBuilder) ToSQL() string
- func (t *TableBuilder) Unique() *TableBuilder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Column ¶
type Column struct {
Name string
Type string
Length int
Nullable bool
Default interface{}
Unique bool
PrimaryKey bool
AutoIncrement bool
}
Column represents a table column definition
type Migration ¶
type Migration struct {
Version string
Description string
Up func(*Migrator) error
Down func(*Migrator) error
}
Migration represents a database schema change
type MigrationRegistry ¶
type MigrationRegistry struct {
// contains filtered or unexported fields
}
MigrationRegistry is a global registry for all migrations
func (*MigrationRegistry) All ¶
func (r *MigrationRegistry) All() []Migration
All returns all registered migrations sorted by version
type MigrationStatus ¶
type MigrationStatus struct {
Version string
State string // "Applied", "Pending", "Failed"
Batch int
ExecutedAt *string
}
MigrationStatus represents the status of a single migration
func Status ¶
func Status() ([]MigrationStatus, error)
Status returns migration status using the default ORM connection
type Migrator ¶
type Migrator struct {
// contains filtered or unexported fields
}
Migrator handles migration execution for a specific database connection
func NewMigrator ¶
NewMigrator creates a new Migrator instance
func (*Migrator) CreateTable ¶
func (m *Migrator) CreateTable(name string, fn func(*TableBuilder)) error
CreateTable creates a new database table using the fluent TableBuilder API
func (*Migrator) SetMigrationsPath ¶
SetMigrationsPath sets the path to migration files
func (*Migrator) Status ¶
func (m *Migrator) Status() ([]MigrationStatus, error)
Status returns the status of all migrations
type TableBuilder ¶
type TableBuilder struct {
// contains filtered or unexported fields
}
TableBuilder provides a fluent API for defining database tables
func (*TableBuilder) Boolean ¶
func (t *TableBuilder) Boolean(name string) *TableBuilder
Boolean adds a BOOLEAN column
func (*TableBuilder) Default ¶
func (t *TableBuilder) Default(value interface{}) *TableBuilder
Default sets a default value for the previous column
func (*TableBuilder) ID ¶
func (t *TableBuilder) ID() *TableBuilder
ID adds an auto-increment primary key column named 'id'
func (*TableBuilder) Integer ¶
func (t *TableBuilder) Integer(name string) *TableBuilder
Integer adds an INTEGER column
func (*TableBuilder) Nullable ¶
func (t *TableBuilder) Nullable() *TableBuilder
Nullable allows NULL values for the previous column
func (*TableBuilder) String ¶
func (t *TableBuilder) String(name string, length ...int) *TableBuilder
String adds a VARCHAR column
func (*TableBuilder) Timestamps ¶
func (t *TableBuilder) Timestamps() *TableBuilder
Timestamps adds created_at and updated_at columns
func (*TableBuilder) ToSQL ¶
func (t *TableBuilder) ToSQL() string
ToSQL generates driver-specific CREATE TABLE SQL
func (*TableBuilder) Unique ¶
func (t *TableBuilder) Unique() *TableBuilder
Unique marks the previous column as unique