adapter

package
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 7, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

type Adapter interface {
	Open() 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)
	GetAdapter() string
	GetDBName() string
}

func NewAdapter

func NewAdapter(config *schema.Config) (Adapter, error)

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

type Migration struct {
	Path      string
	Version   string
	Name      string
	Direction string
}

func ParseMigrationFilename

func ParseMigrationFilename(filename string) (*Migration, error)

type Migrations

type Migrations []*Migration

type Migrator

type Migrator struct {
	Adapter         Adapter
	MigrationsPath  string
	MigrationsTable string
	UpMigrations    UpMigrations
	DownMigrations  DownMigrations
}

func NewMigrator

func NewMigrator(adapter Adapter) (*Migrator, error)

func (*Migrator) CreateTable

func (m *Migrator) CreateTable() error

func (*Migrator) Down

func (m *Migrator) Down() error

func (*Migrator) DownWithStep

func (m *Migrator) DownWithStep(step int) error

func (*Migrator) FindMigrations

func (m *Migrator) FindMigrations() error

func (*Migrator) Reset

func (m *Migrator) Reset() error

func (*Migrator) RunMigration

func (m *Migrator) RunMigration(mg *Migration) error

func (*Migrator) Status

func (m *Migrator) Status(out io.Writer) error

TODO: add ctx

func (*Migrator) Up

func (m *Migrator) Up() error

func (*Migrator) UpWithVersion

func (m *Migrator) UpWithVersion(version string) error

type MysqlAdapter

type MysqlAdapter struct {
	*sql.DB
	Config *schema.Config
}

func NewMysqlAdapter

func NewMysqlAdapter(config *schema.Config) *MysqlAdapter

func (*MysqlAdapter) CreateDatabase

func (a *MysqlAdapter) CreateDatabase() error

func (*MysqlAdapter) CreateMigrationsTable

func (a *MysqlAdapter) CreateMigrationsTable(ctx context.Context) error

create migrations table with atlas

func (*MysqlAdapter) DropDatabase

func (a *MysqlAdapter) DropDatabase() error

func (*MysqlAdapter) GetAdapter

func (a *MysqlAdapter) GetAdapter() string

func (*MysqlAdapter) GetDBName

func (a *MysqlAdapter) GetDBName() string

func (*MysqlAdapter) Open

func (a *MysqlAdapter) Open() error

type PostgreSQLAdapter

type PostgreSQLAdapter struct {
	*sql.DB
	Config *schema.Config
}

func NewPostgreSQLAdapter

func NewPostgreSQLAdapter(config *schema.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) GetAdapter

func (a *PostgreSQLAdapter) GetAdapter() string

func (*PostgreSQLAdapter) GetDBName

func (a *PostgreSQLAdapter) GetDBName() string

func (*PostgreSQLAdapter) Open

func (a *PostgreSQLAdapter) Open() error

type SQLiteAdapter

type SQLiteAdapter struct {
	*sql.DB
	Config *schema.Config
}

func NewSQLiteAdapter

func NewSQLiteAdapter(config *schema.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) GetAdapter

func (a *SQLiteAdapter) GetAdapter() string

func (*SQLiteAdapter) GetDBName

func (a *SQLiteAdapter) GetDBName() string

func (*SQLiteAdapter) Open

func (a *SQLiteAdapter) Open() error

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)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL