Documentation ¶
Overview ¶
Package migrate provides simple and flexible ScyllaDB and Apache Cassandra® migrations. Migrations can be read from a flat directory containing cql files. There is no imposed naming schema, migration name is file name and the migrations are processed in lexicographical order. Caller provides a gocql.Session, the session must use a desired keyspace as migrate would try to create migrations table.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrMigratorTableMissing = errors.New("the migrator table object cannot be nil")
ErrMigratorTableMissing is returned if the migrator table object is nil.
var ErrNoCQLStatement = errors.New("no CQL statement found")
ErrNoCQLStatement is returned when trying to execute a non cql statement i.e. "This is not cql"
var ErrNoMigrationsFound = errors.New("no migrations were found")
ErrNoMigrationsFound is returned if the directory provided doesn't contain any migrations.
var ErrNoSessionProvided = errors.New("no session provided to the Cassandra migrator")
ErrNoSessionProvided is returned when trying to create a Cassandra migrator without a session.
Functions ¶
func SetMigratorTable ¶
func SetMigratorTable(mt MigratorTable)
SetMigratorTable sets the default migrator table instance to use when calling List or Migrate.
Types ¶
type Migrator ¶
type Migrator struct {
// contains filtered or unexported fields
}
Migrator provides the migration facility.
func NewMigratorWithFileSystem ¶
func NewMigratorWithFileSystem(fs http.FileSystem, mt MigratorTable) (*Migrator, error)
NewMigratorWithFileSystem returns a migrator reading the migrations from an http.FileSystem.
type MigratorTable ¶
type MigratorTable interface { List(ctx context.Context) ([]*Info, error) Execute(ctx context.Context, stmt string, info Info) error }
MigratorTable interface operates on the gocqlx_migrate table. Tests can substitute a mock implementation.
func NewCassandraSessionMigrator ¶
func NewCassandraSessionMigrator(session *gocql.Session) (MigratorTable, error)
NewCassandraSessionMigrator creates a migrator that persists into and reads from a Cassandra database.