Documentation
¶
Index ¶
- Variables
- type Migration
- type MigrationStatus
- type State
- func (s *State) Close() error
- func (s *State) Complete(ctx context.Context, schema, name string) error
- func (s *State) GetActiveMigration(ctx context.Context, schema string) (*migrations.Migration, error)
- func (s *State) Init(ctx context.Context) error
- func (s *State) IsActiveMigrationPeriod(ctx context.Context, schema string) (bool, error)
- func (s *State) IsInitialized(ctx context.Context) (bool, error)
- func (s *State) LatestVersion(ctx context.Context, schema string) (*string, error)
- func (s *State) PgConn() *sql.DB
- func (s *State) PreviousVersion(ctx context.Context, schema string, includeInferred bool) (*string, error)
- func (s *State) ReadSchema(ctx context.Context, schemaName string) (*schema.Schema, error)
- func (s *State) Rollback(ctx context.Context, schema, name string) error
- func (s *State) Schema() string
- func (s *State) SchemaAfterMigration(ctx context.Context, schemaName, version string) (*schema.Schema, error)
- func (s *State) SchemaHistory(ctx context.Context, schema string) ([]Migration, error)
- func (s *State) Start(ctx context.Context, schemaname string, migration *migrations.Migration) (*schema.Schema, error)
- func (s *State) Status(ctx context.Context, schema string) (*Status, error)
- type Status
Constants ¶
This section is empty.
Variables ¶
var ErrNoActiveMigration = errors.New("no active migration")
Functions ¶
This section is empty.
Types ¶
type Migration ¶ added in v0.8.0
type Migration struct {
Migration migrations.Migration
CreatedAt time.Time
}
Migration represents a single migration in the migration history of a schema
func (*Migration) WriteToFile ¶ added in v0.8.0
WriteToFile writes the migration to a file in `targetDir`, prefixing the filename with `prefix`.
type MigrationStatus ¶ added in v0.4.1
type MigrationStatus string
const ( NoneMigrationStatus MigrationStatus = "No migrations" InProgressMigrationStatus MigrationStatus = "In progress" CompleteMigrationStatus MigrationStatus = "Complete" )
type State ¶
type State struct {
// contains filtered or unexported fields
}
func (*State) GetActiveMigration ¶
func (s *State) GetActiveMigration(ctx context.Context, schema string) (*migrations.Migration, error)
GetActiveMigration returns the name & raw content of the active migration (if any), errors out otherwise
func (*State) IsActiveMigrationPeriod ¶
IsActiveMigrationPeriod returns true if there is an active migration
func (*State) IsInitialized ¶ added in v0.11.0
func (*State) LatestVersion ¶
LatestVersion returns the name of the latest version schema, or nil if there is none. No active version occurs after initialization, but before the first migration is started.
func (*State) PreviousVersion ¶
func (s *State) PreviousVersion(ctx context.Context, schema string, includeInferred bool) (*string, error)
PreviousVersion returns the name of the previous version schema
func (*State) ReadSchema ¶
ReadSchema reads the schema for the specified schema name
func (*State) Rollback ¶
Rollback removes a migration from the state (we consider it rolled back, as if it never started)
func (*State) SchemaAfterMigration ¶ added in v0.9.0
func (s *State) SchemaAfterMigration(ctx context.Context, schemaName, version string) (*schema.Schema, error)
SchemaAfterMigration reads the schema after the migration `version` was applied to `schemaName`
func (*State) SchemaHistory ¶ added in v0.8.0
SchemaHistory returns all migrations applied to a schema in ascending timestamp order
func (*State) Start ¶
func (s *State) Start(ctx context.Context, schemaname string, migration *migrations.Migration) (*schema.Schema, error)
Start creates a new migration, storing its name and raw content this will effectively activate a new migration period, so `IsActiveMigrationPeriod` will return true until the migration is completed This method will return the current schema (before the migration is applied)
type Status ¶ added in v0.4.1
type Status struct {
// The schema name.
Schema string `json:"schema"`
// The name of the latest version schema.
Version string `json:"version"`
// The status of the most recent migration.
Status MigrationStatus `json:"status"`
}
Status describes the current migration status of a database schema.