Versions in this module Expand all Collapse all v1 v1.1.0 May 27, 2025 v1.0.9 May 22, 2025 Changes in this version + const APPVAR_MIGRATION_DIR + const AttrDBTypeKey + const AttrOnDeleteKey + const AttrOnUpdateKey + const AttrUseInDBKey + const DEFAULT_MIGRATION_DIR + const MIGRATION_FILE_SUFFIX + const MetaAllowMigrateKey + func CanMigrate(obj attrs.Definer) bool + func EqualDefaultValue(a, b any) bool + func GetFieldType(driver driver.Driver, f attrs.Field) string + func NewAppConfig() *migratorAppConfig + func RegisterColumnKind(driver driver.Driver, typ []reflect.Kind, fn func(f attrs.Field) string) + func RegisterColumnType(driver driver.Driver, typ interface{}, fn func(f attrs.Field) string) + func RegisterSchemaEditor(driver driver.Driver, fn func() (SchemaEditor, error)) + type Action int + const CASCADE + const RESTRICT + const SET_NULL + func (a Action) String() string + type ActionType int + const ActionAddField + const ActionAddIndex + const ActionAlterField + const ActionCreateTable + const ActionDropIndex + const ActionDropTable + const ActionRemoveField + const ActionRenameIndex + const ActionRenameTable + func (a *ActionType) UnmarshalJSON(data []byte) error + func (a ActionType) MarshalJSON() ([]byte, error) + func (a ActionType) String() string + type CanModelMigrate interface + CanMigrate func() bool + type CanSQL interface + SQL func(T) (string, []any) + type CantMigrate struct + func (c *CantMigrate) CanMigrate() bool + type Changed struct + New T + Old T + type Column struct + Auto bool + Column string + Default interface{} + Field attrs.Field + MaxLength int64 + MaxValue float64 + MinLength int64 + MinValue float64 + Name string + Nullable bool + Primary bool + Rel *MigrationRelation + ReverseAlias string + Table Table + Unique bool + UseInDB bool + func (c *Column) Equals(other *Column) bool + type Dependency struct + AppName string + ModelName string + Name string + func (d *Dependency) MarshalJSON() ([]byte, error) + func (d *Dependency) UnmarshalJSON(data []byte) error + type Index struct + Columns []string + Comment string + Name string + Type string + Unique bool + type MigrationAction struct + ActionType ActionType + Field *Changed[*Column] + Index *Changed[*Index] + Table *Changed[*ModelTable] + type MigrationEngine struct + MigrationLog MigrationLog + Migrations map[string]map[string][]*MigrationFile + Path string + SchemaEditor SchemaEditor + func NewMigrationEngine(path string, schemaEditor SchemaEditor, apps ...string) *MigrationEngine + func (e *MigrationEngine) NewMigration(appName, modelName string, newTable *ModelTable, ...) (*MigrationFile, error) + func (e *MigrationEngine) ReadMigrations() ([]*MigrationFile, error) + func (e *MigrationEngine) WriteMigration(migration *MigrationFile) error + func (m *MigrationEngine) GetLastMigration(appName, modelName string) *MigrationFile + func (m *MigrationEngine) Log(action ActionType, file *MigrationFile, table *Changed[*ModelTable], ...) + func (m *MigrationEngine) MakeMigrations() error + func (m *MigrationEngine) Migrate() error + func (m *MigrationEngine) NeedsToMigrate() ([]*contenttypes.BaseContentType[attrs.Definer], error) + type MigrationEngineConsoleLog struct + func (e *MigrationEngineConsoleLog) Log(action ActionType, file *MigrationFile, table *Changed[*ModelTable], ...) + type MigrationFile struct + Actions []MigrationAction + AppName string + ContentType *contenttypes.BaseContentType[attrs.Definer] + Dependencies []Dependency + ModelName string + Name string + Order int + Table *ModelTable + func (m *MigrationFile) FileName() string + type MigrationLog interface + Log func(action ActionType, file *MigrationFile, table *Changed[*ModelTable], ...) + type MigrationRelation struct + OnDelete Action + OnUpdate Action + TargetField attrs.FieldDefinition + TargetModel *contenttypes.BaseContentType[attrs.Definer] + Through *MigrationRelationThrough + Type attrs.RelationType + func (m *MigrationRelation) Field() attrs.FieldDefinition + func (m *MigrationRelation) MarshalJSON() ([]byte, error) + func (m *MigrationRelation) Model() attrs.Definer + func (m *MigrationRelation) UnmarshalJSON(data []byte) error + type MigrationRelationThrough struct + Model *contenttypes.BaseContentType[attrs.Definer] + SourceField string + TargetField string + type ModelTable struct + Desc string + Fields *orderedmap.OrderedMap[string, Column] + Index []Index + Object attrs.Definer + Table string + func NewModelTable(object attrs.Definer) *ModelTable + func (t *ModelTable) Columns() []*Column + func (t *ModelTable) Comment() string + func (t *ModelTable) Diff(other *ModelTable) (added, removed []Column, diffs []Changed[Column]) + func (t *ModelTable) Indexes() []Index + func (t *ModelTable) MarshalJSON() ([]byte, error) + func (t *ModelTable) Model() attrs.Definer + func (t *ModelTable) ModelName() string + func (t *ModelTable) TableName() string + func (t *ModelTable) UnmarshalJSON(data []byte) error + type SchemaEditor interface + AddField func(table Table, col Column) error + AddIndex func(table Table, index Index) error + AlterField func(table Table, old Column, newCol Column) error + CreateTable func(table Table) error + DropIndex func(table Table, index Index) error + DropTable func(table Table) error + Execute func(ctx context.Context, query string, args ...any) (sql.Result, error) + HasMigration func(appName string, modelName string, migrationName string) (bool, error) + RemoveField func(table Table, col Column) error + RemoveMigration func(appName string, modelName string, migrationName string) error + RenameIndex func(table Table, oldName string, newName string) error + RenameTable func(table Table, newName string) error + Setup func() error + StoreMigration func(appName string, modelName string, migrationName string) error + func GetSchemaEditor(driver driver.Driver) (SchemaEditor, error) + type Table interface + Columns func() []*Column + Comment func() string + Indexes func() []Index + Model func() attrs.Definer + TableName func() string