Documentation ¶
Index ¶
- Constants
- Variables
- type Logger
- type Mariadb
- type Migratable
- type Migration
- type Migrator
- func (m *Migrator) ApplyMigration(migration *Migration, mType migrationType) error
- func (m *Migrator) CreateMigrationsTable() error
- func (m *Migrator) Migrate() error
- func (m *Migrator) MigrationTableExists() (bool, error)
- func (m *Migrator) Migrations(status int) []*Migration
- func (m *Migrator) Rollback() error
- func (m *Migrator) RollbackAll() error
- func (m *Migrator) RollbackN(n int) error
- type Mysql
- type Postgres
- func (p Postgres) CreateMigrationTableSql() string
- func (p Postgres) GetMigrationCommands(sql string) []string
- func (p Postgres) GetMigrationSql() string
- func (p Postgres) MigrationLogDeleteSql() string
- func (p Postgres) MigrationLogInsertSql() string
- func (p Postgres) SelectMigrationTableSql() string
- type SqlServer
- func (s SqlServer) CreateMigrationTableSql() string
- func (s SqlServer) GetMigrationCommands(sql string) []string
- func (s SqlServer) GetMigrationSql() string
- func (s SqlServer) MigrationLogDeleteSql() string
- func (s SqlServer) MigrationLogInsertSql() string
- func (s SqlServer) SelectMigrationTableSql() string
- type Sqlite3
Constants ¶
View Source
const ( Inactive = iota Active )
Migration statuses.
Variables ¶
View Source
var ( InvalidMigrationFile = errors.New("Invalid migration file") InvalidMigrationPair = errors.New("Invalid pair of migration files") InvalidMigrationsPath = errors.New("Invalid migrations path") InvalidMigrationType = errors.New("Invalid migration type") NoActiveMigrations = errors.New("No active migrations to rollback") )
Functions ¶
This section is empty.
Types ¶
type Migratable ¶
type Migrator ¶
func NewMigrator ¶
Returns a new migrator.
func NewMigratorWithLogger ¶
func NewMigratorWithLogger(db *sql.DB, adapter Migratable, migrationsPath string, logger Logger) (*Migrator, error)
Returns a new migrator with the specified logger.
func (*Migrator) ApplyMigration ¶
Applies a single migration.
func (*Migrator) CreateMigrationsTable ¶
Creates the migrations table if it doesn't exist.
func (*Migrator) MigrationTableExists ¶
Returns true if the migration table already exists.
func (*Migrator) Migrations ¶
Returns a sorted list of migration ids for a given status. -1 returns all migrations.
type Mysql ¶
type Mysql struct{}
func (Mysql) CreateMigrationTableSql ¶
func (Mysql) GetMigrationCommands ¶
func (Mysql) GetMigrationSql ¶
func (Mysql) MigrationLogDeleteSql ¶
func (Mysql) MigrationLogInsertSql ¶
func (Mysql) SelectMigrationTableSql ¶
type Postgres ¶
type Postgres struct{}
func (Postgres) CreateMigrationTableSql ¶
func (Postgres) GetMigrationCommands ¶
func (Postgres) GetMigrationSql ¶
func (Postgres) MigrationLogDeleteSql ¶
func (Postgres) MigrationLogInsertSql ¶
func (Postgres) SelectMigrationTableSql ¶
type SqlServer ¶
type SqlServer struct{}
func (SqlServer) CreateMigrationTableSql ¶
func (SqlServer) GetMigrationCommands ¶
func (SqlServer) GetMigrationSql ¶
func (SqlServer) MigrationLogDeleteSql ¶
func (SqlServer) MigrationLogInsertSql ¶
func (SqlServer) SelectMigrationTableSql ¶
type Sqlite3 ¶
type Sqlite3 struct{}
func (Sqlite3) CreateMigrationTableSql ¶
func (Sqlite3) GetMigrationCommands ¶
func (Sqlite3) GetMigrationSql ¶
func (Sqlite3) MigrationLogDeleteSql ¶
func (Sqlite3) MigrationLogInsertSql ¶
func (Sqlite3) SelectMigrationTableSql ¶
Click to show internal directories.
Click to hide internal directories.