Documentation
¶
Index ¶
- Variables
- func Generate(model any) (string, []string, error)
- type Creator
- type Migrator
- type Repository
- func (r *Repository) CreateRepository() error
- func (r *Repository) Delete(migration string) error
- func (r *Repository) DeleteRepository() error
- func (r *Repository) GetLast() ([]migration.File, error)
- func (r *Repository) GetLastBatchNumber() (int, error)
- func (r *Repository) GetMigrations() ([]migration.File, error)
- func (r *Repository) GetMigrationsByBatch(batch int) ([]migration.File, error)
- func (r *Repository) GetMigrationsByStep(steps int) ([]migration.File, error)
- func (r *Repository) GetNextBatchNumber() (int, error)
- func (r *Repository) GetRan() ([]string, error)
- func (r *Repository) Log(file string, batch int) error
- func (r *Repository) RepositoryExists() bool
- type StubData
- type Stubs
- type TableGuesser
Constants ¶
This section is empty.
Variables ¶
View Source
var ChangePatterns = []string{
`_(to|from|in)_(\w+)_table$`,
`_(to|from|in)_(\w+)$`,
}
View Source
var CreatePatterns = []string{
`^create_(\w+)_table$`,
`^create_(\w+)$`,
}
Functions ¶
func Generate ¶
Generate creates migration schema lines from a model struct.
The model is read through the framework's own field annotations (database/internal/annotation.ParseAnnotation) and Go's type system, not through GORM's schema parser: the column name comes from `column:` or the snake_cased field name, the column type from the Go type with `type:` and `migration:` overriding it, and primary keys, indexes and the automatic timestamps from their annotations.
It returns the table name and the schema lines, in which the columns come first and the index and constraint definitions follow after an empty separator line.
Types ¶
type Creator ¶
type Creator struct {
}
func NewCreator ¶
func NewCreator() *Creator
func (*Creator) GetFileName ¶
GetFileName Get the full path to the migration.
type Migrator ¶
type Migrator struct {
// contains filtered or unexported fields
}
func NewMigrator ¶
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
func NewRepository ¶
func NewRepository(schema schema.Schema, table string) *Repository
func (*Repository) CreateRepository ¶
func (r *Repository) CreateRepository() error
func (*Repository) Delete ¶
func (r *Repository) Delete(migration string) error
func (*Repository) DeleteRepository ¶
func (r *Repository) DeleteRepository() error
func (*Repository) GetLastBatchNumber ¶
func (r *Repository) GetLastBatchNumber() (int, error)
func (*Repository) GetMigrations ¶
func (r *Repository) GetMigrations() ([]migration.File, error)
func (*Repository) GetMigrationsByBatch ¶
func (r *Repository) GetMigrationsByBatch(batch int) ([]migration.File, error)
func (*Repository) GetMigrationsByStep ¶
func (r *Repository) GetMigrationsByStep(steps int) ([]migration.File, error)
func (*Repository) GetNextBatchNumber ¶
func (r *Repository) GetNextBatchNumber() (int, error)
func (*Repository) GetRan ¶
func (r *Repository) GetRan() ([]string, error)
func (*Repository) RepositoryExists ¶
func (r *Repository) RepositoryExists() bool
type TableGuesser ¶
type TableGuesser struct {
}
Click to show internal directories.
Click to hide internal directories.