Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ColumnSchema ¶
type ColumnSchema struct {
Name string
Type string
Nullable bool
Default interface{}
PrimaryKey bool
Unique bool
}
ColumnSchema representa uma coluna no banco
type Detector ¶
type Detector struct {
// contains filtered or unexported fields
}
Detector detecta mudanças nos models
func (*Detector) DetectChanges ¶
func (d *Detector) DetectChanges() ([]SchemaChange, error)
DetectChanges escaneia os models e detecta mudanças
func (*Detector) GenerateMigrationFile ¶
func (d *Detector) GenerateMigrationFile(changes []SchemaChange, name string) (string, error)
GenerateMigrationFile gera arquivo de migration
type IndexSchema ¶
IndexSchema representa um índice no banco
type MigrationInfo ¶
MigrationInfo contém informações sobre uma migration
type MigrationStatus ¶
type MigrationStatus struct {
Applied []MigrationInfo
Pending []MigrationInfo
}
MigrationStatus representa o status das migrations
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runner executa migrations
func (*Runner) GetStatus ¶
func (r *Runner) GetStatus() (*MigrationStatus, error)
GetStatus retorna o status das migrations
func (*Runner) MigrateDown ¶
MigrateDown reverte migrations
func (*Runner) MigrateDownTo ¶
MigrateDownTo reverte até uma versão específica
type SQLGenerator ¶
type SQLGenerator struct{}
SQLGenerator gera SQL para migrations
func NewSQLGenerator ¶
func NewSQLGenerator() *SQLGenerator
NewSQLGenerator cria um novo gerador de SQL
func (*SQLGenerator) Generate ¶
func (g *SQLGenerator) Generate(changes []SchemaChange, driver string) (up string, down string)
Generate gera SQL UP e DOWN para as mudanças
func (*SQLGenerator) GenerateFullTableDDL ¶
func (g *SQLGenerator) GenerateFullTableDDL(metadata *parser.ModelMetadata, driver string) string
GenerateFullTableDDL gera DDL completo para uma tabela baseado no model
type SchemaChange ¶
type SchemaChange struct {
Type string // CREATE_TABLE, ADD_COLUMN, DROP_COLUMN, ALTER_COLUMN, etc
ModelName string
TableName string
Field string
Description string
OldValue interface{}
NewValue interface{}
}
SchemaChange representa uma mudança no schema
type TableSchema ¶
type TableSchema struct {
Name string
Columns []*ColumnSchema
Indexes []*IndexSchema
}
TableSchema representa o schema de uma tabela no banco