Documentation ¶
Index ¶
- type Adapter
- type Config
- type DownMigrations
- type Migration
- type Migrations
- type Migrator
- func (m *Migrator) CreateTable() error
- func (m *Migrator) Down() error
- func (m *Migrator) DownWithStep(step int) error
- func (m *Migrator) FindMigrations() error
- func (m *Migrator) Reset() error
- func (m *Migrator) RunMigration(mg *Migration) error
- func (m *Migrator) Status(out io.Writer) error
- func (m *Migrator) Up() error
- func (m *Migrator) UpWithVersion(version string) error
- type MySQLAdapter
- type PostgreSQLAdapter
- func (a *PostgreSQLAdapter) CreateDatabase() error
- func (a *PostgreSQLAdapter) CreateMigrationsTable(ctx context.Context) error
- func (a *PostgreSQLAdapter) DropDatabase() error
- func (a *PostgreSQLAdapter) Open() error
- func (a *PostgreSQLAdapter) QueryVersion(ctx context.Context, version string) (*sql.Rows, error)
- type SQLiteAdapter
- type UpMigrations
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Adapter ¶
type Adapter interface { Open() error Close() error CreateDatabase() error DropDatabase() error CreateMigrationsTable(ctx context.Context) error ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) QueryVersion(ctx context.Context, version string) (*sql.Rows, error) }
type Config ¶ added in v0.1.11
type Config struct { Adapter string // full connection url URL string // connection url without database URL2 string // database, for sqlite it is sqlite file path Database string Host string Port string Username string Password string Options url.Values }
func NewConfigFromURL ¶ added in v0.2.0
type DownMigrations ¶
type DownMigrations Migrations
func (DownMigrations) Len ¶
func (ms DownMigrations) Len() int
func (DownMigrations) Less ¶
func (ms DownMigrations) Less(i, j int) bool
func (DownMigrations) Swap ¶
func (ms DownMigrations) Swap(i, j int)
type Migration ¶
func ParseMigrationFilename ¶
type Migrations ¶
type Migrations []*Migration
type Migrator ¶
type Migrator struct { Adapter Adapter MigrationsPath string MigrationsTable string UpMigrations UpMigrations DownMigrations DownMigrations }
func NewMigrator ¶
func (*Migrator) CreateTable ¶
func (*Migrator) DownWithStep ¶
func (*Migrator) FindMigrations ¶
func (*Migrator) RunMigration ¶
func (*Migrator) UpWithVersion ¶
type MySQLAdapter ¶ added in v0.1.7
func NewMySQLAdapter ¶ added in v0.1.7
func NewMySQLAdapter(config *Config) *MySQLAdapter
func (*MySQLAdapter) CreateDatabase ¶ added in v0.1.7
func (a *MySQLAdapter) CreateDatabase() error
func (*MySQLAdapter) CreateMigrationsTable ¶ added in v0.1.7
func (a *MySQLAdapter) CreateMigrationsTable(ctx context.Context) error
create migrations table with atlas
func (*MySQLAdapter) DropDatabase ¶ added in v0.1.7
func (a *MySQLAdapter) DropDatabase() error
func (*MySQLAdapter) Open ¶ added in v0.1.7
func (a *MySQLAdapter) Open() error
func (*MySQLAdapter) QueryVersion ¶ added in v0.1.11
type PostgreSQLAdapter ¶
func NewPostgreSQLAdapter ¶
func NewPostgreSQLAdapter(config *Config) *PostgreSQLAdapter
func (*PostgreSQLAdapter) CreateDatabase ¶
func (a *PostgreSQLAdapter) CreateDatabase() error
func (*PostgreSQLAdapter) CreateMigrationsTable ¶
func (a *PostgreSQLAdapter) CreateMigrationsTable(ctx context.Context) error
create migrations table with atlas
func (*PostgreSQLAdapter) DropDatabase ¶
func (a *PostgreSQLAdapter) DropDatabase() error
func (*PostgreSQLAdapter) Open ¶
func (a *PostgreSQLAdapter) Open() error
func (*PostgreSQLAdapter) QueryVersion ¶ added in v0.1.11
type SQLiteAdapter ¶
func NewSQLiteAdapter ¶
func NewSQLiteAdapter(config *Config) *SQLiteAdapter
func (*SQLiteAdapter) CreateDatabase ¶
func (a *SQLiteAdapter) CreateDatabase() error
func (*SQLiteAdapter) CreateMigrationsTable ¶
func (a *SQLiteAdapter) CreateMigrationsTable(ctx context.Context) error
create migrations table with atlas
func (*SQLiteAdapter) DropDatabase ¶
func (a *SQLiteAdapter) DropDatabase() error
func (*SQLiteAdapter) Open ¶
func (a *SQLiteAdapter) Open() error
func (*SQLiteAdapter) QueryVersion ¶ added in v0.1.11
type UpMigrations ¶
type UpMigrations Migrations
func (UpMigrations) Len ¶
func (ms UpMigrations) Len() int
func (UpMigrations) Less ¶
func (ms UpMigrations) Less(i, j int) bool
func (UpMigrations) Swap ¶
func (ms UpMigrations) Swap(i, j int)
Click to show internal directories.
Click to hide internal directories.