Documentation ¶
Index ¶
- type Migrator
- func (m *Migrator) AddColumnQuery(t schema.Table, c schema.Column) string
- func (m *Migrator) AddReferenceQuery(reference schema.Reference) string
- func (m *Migrator) AddUniqueIndexQuery(table schema.Table, indexName string, colNames []string) string
- func (m *Migrator) CreateMigration(dst []*schema.Table, verbose bool) (string, string)
- func (m *Migrator) CreateTableQuery(t *schema.Table) string
- func (m *Migrator) DescribeTable(tableName string) []*schema.Column
- func (m *Migrator) DropColumnQuery(t schema.Table, c schema.Column) string
- func (m *Migrator) DropReferenceQuery(reference schema.Reference) string
- func (m *Migrator) DropTableQuery(t *schema.Table) string
- func (m *Migrator) DropUniqueIndexQuery(table schema.Table, indexName string, colNames []string) string
- func (m *Migrator) GetReferences(tableName string) []schema.Reference
- func (m *Migrator) GetTables() []*schema.Table
- func (m *Migrator) MigrateAndSave(dryRun bool, saveDirectory string, targetModels ...interface{})
- func (m *Migrator) ModifyColumnQuery(t schema.Table, c schema.Column) string
- func (m *Migrator) ParseTablesFromStructs(dst ...interface{}) []*schema.Table
- func (m *Migrator) RenameColumnQuery(t schema.Table, newCol schema.Column, oldColumn schema.Column) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Migrator ¶
type Migrator struct { DB *sql.DB SchemaName string Relations []schema.Reference CurrentVersion int }
func NewMigrator ¶
Returns a new migrator instance that is connected to the database by given dsn
func (*Migrator) AddColumnQuery ¶
func (*Migrator) AddReferenceQuery ¶
func (*Migrator) AddUniqueIndexQuery ¶
func (*Migrator) CreateMigration ¶
Compares the current state of the database schema with the given 'dst' schema. Creates and returns the migration script that will bring database to the desired state
func (*Migrator) DescribeTable ¶
func (*Migrator) DropColumnQuery ¶
func (*Migrator) DropReferenceQuery ¶
func (*Migrator) DropUniqueIndexQuery ¶
func (*Migrator) GetReferences ¶
func (*Migrator) MigrateAndSave ¶
Creates and saves migration script based on the given target models and current state of the database. If dryRun flag is true Migrator prints the migration script and exits
func (*Migrator) ModifyColumnQuery ¶
func (*Migrator) ParseTablesFromStructs ¶
Parses given structs into `schema.Table` struct. Given structs must be in order so that referenced table comes before the foreignKey table
Click to show internal directories.
Click to hide internal directories.