Documentation
¶
Index ¶
- func Backfill(ctx context.Context, conn db.DB, table *schema.Table, batchSize int, ...) error
- func DuplicationName(name string) string
- func IsDuplicatedName(name string) bool
- func IsNotNullConstraintName(name string) bool
- func NotNullConstraintName(columnName string) string
- func RenameDuplicatedColumn(ctx context.Context, conn db.DB, table *schema.Table, column *schema.Column) error
- func StripDuplicationPrefix(name string) string
- func TemporaryName(name string) string
- func TriggerFunctionName(tableName, columnName string) string
- func TriggerName(tableName, columnName string) string
- func ValidateIdentifierLength(name string) error
- type AlterColumnNoChangesError
- type BackfillNotPossibleError
- type CallbackFn
- type CheckConstraint
- type CheckConstraintError
- type Column
- type ColumnAlreadyExistsError
- type ColumnDoesNotExistError
- type ColumnIsNotNullableError
- type ColumnIsNullableError
- type ColumnMigrationMissingError
- type ColumnMigrationRedundantError
- type ColumnReferenceError
- type ColumnSQLWriter
- type ConstraintAlreadyExistsError
- type ConstraintDoesNotExistError
- type Duplicator
- type EmptyMigrationError
- type FieldRequiredError
- type ForeignKeyReference
- type ForeignKeyReferenceOnDelete
- type IndexAlreadyExistsError
- type IndexDoesNotExistError
- type InvalidIdentifierLengthError
- type InvalidMigrationError
- type InvalidOnDeleteSettingError
- type InvalidReplicaIdentityError
- type IsolatedOperation
- type Migration
- type MultiColumnConstraintsNotSupportedError
- type MultiColumnDownSQL
- type MultiColumnUpSQL
- type NoDownSQLAllowedError
- type NoUpSQLAllowedError
- type OpAddColumn
- func (o *OpAddColumn) Complete(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
- func (o *OpAddColumn) Rollback(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
- func (o *OpAddColumn) Start(ctx context.Context, conn db.DB, latestSchema string, tr SQLTransformer, ...) (*schema.Table, error)
- func (o *OpAddColumn) Validate(ctx context.Context, s *schema.Schema) error
- type OpAlterColumn
- func (o *OpAlterColumn) Complete(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
- func (o *OpAlterColumn) IsRenameOnly() bool
- func (o *OpAlterColumn) Rollback(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
- func (o *OpAlterColumn) Start(ctx context.Context, conn db.DB, latestSchema string, tr SQLTransformer, ...) (*schema.Table, error)
- func (o *OpAlterColumn) Validate(ctx context.Context, s *schema.Schema) error
- type OpChangeType
- func (o *OpChangeType) Complete(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
- func (o *OpChangeType) Rollback(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
- func (o *OpChangeType) Start(ctx context.Context, conn db.DB, latestSchema string, tr SQLTransformer, ...) (*schema.Table, error)
- func (o *OpChangeType) Validate(ctx context.Context, s *schema.Schema) error
- type OpCreateConstraint
- func (o *OpCreateConstraint) Complete(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
- func (o *OpCreateConstraint) Rollback(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
- func (o *OpCreateConstraint) Start(ctx context.Context, conn db.DB, latestSchema string, tr SQLTransformer, ...) (*schema.Table, error)
- func (o *OpCreateConstraint) Validate(ctx context.Context, s *schema.Schema) error
- type OpCreateConstraintReferences
- type OpCreateConstraintType
- type OpCreateIndex
- func (o *OpCreateIndex) Complete(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
- func (o *OpCreateIndex) Rollback(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
- func (o *OpCreateIndex) Start(ctx context.Context, conn db.DB, latestSchema string, tr SQLTransformer, ...) (*schema.Table, error)
- func (o *OpCreateIndex) Validate(ctx context.Context, s *schema.Schema) error
- type OpCreateIndexMethod
- type OpCreateTable
- func (o *OpCreateTable) Complete(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
- func (o *OpCreateTable) Rollback(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
- func (o *OpCreateTable) Start(ctx context.Context, conn db.DB, latestSchema string, tr SQLTransformer, ...) (*schema.Table, error)
- func (o *OpCreateTable) Validate(ctx context.Context, s *schema.Schema) error
- type OpDropColumn
- func (o *OpDropColumn) Complete(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
- func (o *OpDropColumn) Rollback(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
- func (o *OpDropColumn) Start(ctx context.Context, conn db.DB, latestSchema string, tr SQLTransformer, ...) (*schema.Table, error)
- func (o *OpDropColumn) Validate(ctx context.Context, s *schema.Schema) error
- type OpDropConstraint
- func (o *OpDropConstraint) Complete(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
- func (o *OpDropConstraint) Rollback(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
- func (o *OpDropConstraint) Start(ctx context.Context, conn db.DB, latestSchema string, tr SQLTransformer, ...) (*schema.Table, error)
- func (o *OpDropConstraint) Validate(ctx context.Context, s *schema.Schema) error
- type OpDropIndex
- func (o *OpDropIndex) Complete(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
- func (o *OpDropIndex) Rollback(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
- func (o *OpDropIndex) Start(ctx context.Context, conn db.DB, latestSchema string, tr SQLTransformer, ...) (*schema.Table, error)
- func (o *OpDropIndex) Validate(ctx context.Context, s *schema.Schema) error
- type OpDropMultiColumnConstraint
- func (o *OpDropMultiColumnConstraint) Complete(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
- func (o *OpDropMultiColumnConstraint) Rollback(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
- func (o *OpDropMultiColumnConstraint) Start(ctx context.Context, conn db.DB, latestSchema string, tr SQLTransformer, ...) (*schema.Table, error)
- func (o *OpDropMultiColumnConstraint) Validate(ctx context.Context, s *schema.Schema) error
- type OpDropNotNull
- func (o *OpDropNotNull) Complete(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
- func (o *OpDropNotNull) Rollback(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
- func (o *OpDropNotNull) Start(ctx context.Context, conn db.DB, latestSchema string, tr SQLTransformer, ...) (*schema.Table, error)
- func (o *OpDropNotNull) Validate(ctx context.Context, s *schema.Schema) error
- type OpDropTable
- func (o *OpDropTable) Complete(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
- func (o *OpDropTable) Rollback(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
- func (o *OpDropTable) Start(ctx context.Context, conn db.DB, latestSchema string, tr SQLTransformer, ...) (*schema.Table, error)
- func (o *OpDropTable) Validate(ctx context.Context, s *schema.Schema) error
- type OpName
- type OpRawSQL
- func (o *OpRawSQL) Complete(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
- func (o *OpRawSQL) IsIsolated() bool
- func (o *OpRawSQL) RequiresSchemaRefresh()
- func (o *OpRawSQL) Rollback(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
- func (o *OpRawSQL) Start(ctx context.Context, conn db.DB, latestSchema string, tr SQLTransformer, ...) (*schema.Table, error)
- func (o *OpRawSQL) Validate(ctx context.Context, s *schema.Schema) error
- type OpRenameConstraint
- func (o *OpRenameConstraint) Complete(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
- func (o *OpRenameConstraint) Rollback(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
- func (o *OpRenameConstraint) Start(ctx context.Context, conn db.DB, latestSchema string, tr SQLTransformer, ...) (*schema.Table, error)
- func (o *OpRenameConstraint) Validate(ctx context.Context, s *schema.Schema) error
- type OpRenameTable
- func (o *OpRenameTable) Complete(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
- func (o *OpRenameTable) Rollback(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
- func (o *OpRenameTable) Start(ctx context.Context, conn db.DB, latestSchema string, tr SQLTransformer, ...) (*schema.Table, error)
- func (o *OpRenameTable) Validate(ctx context.Context, s *schema.Schema) error
- type OpSetCheckConstraint
- func (o *OpSetCheckConstraint) Complete(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
- func (o *OpSetCheckConstraint) Rollback(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
- func (o *OpSetCheckConstraint) Start(ctx context.Context, conn db.DB, latestSchema string, tr SQLTransformer, ...) (*schema.Table, error)
- func (o *OpSetCheckConstraint) Validate(ctx context.Context, s *schema.Schema) error
- type OpSetComment
- func (o *OpSetComment) Complete(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
- func (o *OpSetComment) Rollback(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
- func (o *OpSetComment) Start(ctx context.Context, conn db.DB, latestSchema string, tr SQLTransformer, ...) (*schema.Table, error)
- func (o *OpSetComment) Validate(ctx context.Context, s *schema.Schema) error
- type OpSetDefault
- func (o *OpSetDefault) Complete(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
- func (o *OpSetDefault) Rollback(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
- func (o *OpSetDefault) Start(ctx context.Context, conn db.DB, latestSchema string, tr SQLTransformer, ...) (*schema.Table, error)
- func (o *OpSetDefault) Validate(ctx context.Context, s *schema.Schema) error
- type OpSetForeignKey
- func (o *OpSetForeignKey) Complete(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
- func (o *OpSetForeignKey) Rollback(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
- func (o *OpSetForeignKey) Start(ctx context.Context, conn db.DB, latestSchema string, tr SQLTransformer, ...) (*schema.Table, error)
- func (o *OpSetForeignKey) Validate(ctx context.Context, s *schema.Schema) error
- type OpSetNotNull
- func (o *OpSetNotNull) Complete(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
- func (o *OpSetNotNull) Rollback(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
- func (o *OpSetNotNull) Start(ctx context.Context, conn db.DB, latestSchema string, tr SQLTransformer, ...) (*schema.Table, error)
- func (o *OpSetNotNull) Validate(ctx context.Context, s *schema.Schema) error
- type OpSetReplicaIdentity
- func (o *OpSetReplicaIdentity) Complete(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
- func (o *OpSetReplicaIdentity) Rollback(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
- func (o *OpSetReplicaIdentity) Start(ctx context.Context, conn db.DB, latestSchema string, tr SQLTransformer, ...) (*schema.Table, error)
- func (o *OpSetReplicaIdentity) Validate(ctx context.Context, s *schema.Schema) error
- type OpSetUnique
- func (o *OpSetUnique) Complete(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
- func (o *OpSetUnique) Rollback(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
- func (o *OpSetUnique) Start(ctx context.Context, conn db.DB, latestSchema string, tr SQLTransformer, ...) (*schema.Table, error)
- func (o *OpSetUnique) Validate(ctx context.Context, s *schema.Schema) error
- type Operation
- type Operations
- type PgRollMigration
- type PgRollOperation
- type PgRollOperations
- type ReplicaIdentity
- type RequiresSchemaRefreshOperation
- type SQLTransformer
- type SQLTransformerFunc
- type TableAlreadyExistsError
- type TableDoesNotExistError
- type TriggerDirection
- type UniqueConstraint
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Backfill ¶ added in v0.6.0
func Backfill(ctx context.Context, conn db.DB, table *schema.Table, batchSize int, batchDelay time.Duration, cbs ...CallbackFn) error
Backfill updates all rows in the given table, in batches, using the following algorithm: 1. Get the primary key column for the table. 2. Get the first batch of rows from the table, ordered by the primary key. 3. Update each row in the batch, setting the value of the primary key column to itself. 4. Repeat steps 2 and 3 until no more rows are returned.
func DuplicationName ¶ added in v0.5.0
DuplicationName returns the name of a duplicated column.
func IsDuplicatedName ¶ added in v0.5.0
IsDuplicatedName returns true if the name is a duplicated column name.
func IsNotNullConstraintName ¶ added in v0.5.0
IsNotNullConstraintName returns true if the given name is a NOT NULL constraint name
func NotNullConstraintName ¶
NotNullConstraintName returns the name of the NOT NULL constraint for the given column
func RenameDuplicatedColumn ¶ added in v0.5.0
func RenameDuplicatedColumn(ctx context.Context, conn db.DB, table *schema.Table, column *schema.Column) error
RenameDuplicatedColumn * renames a duplicated column to its original name * renames any foreign keys on the duplicated column to their original name. * Validates and renames any temporary `CHECK` constraints on the duplicated column.
func StripDuplicationPrefix ¶ added in v0.5.0
StripDuplicationPrefix removes the duplication prefix from a column name.
func TemporaryName ¶
TemporaryName returns a temporary name for a given name.
func TriggerFunctionName ¶
TriggerFunctionName returns the name of the trigger function for a given table and column.
func TriggerName ¶
TriggerName returns the name of the trigger for a given table and column.
func ValidateIdentifierLength ¶ added in v0.8.0
ValidateIdentifierLength returns an error if the given name exceeds the maximum allowed length for a Postgres identifier.
Types ¶
type AlterColumnNoChangesError ¶ added in v0.6.0
func (AlterColumnNoChangesError) Error ¶ added in v0.6.0
func (e AlterColumnNoChangesError) Error() string
type BackfillNotPossibleError ¶ added in v0.6.0
type BackfillNotPossibleError struct {
Table string
}
func (BackfillNotPossibleError) Error ¶ added in v0.6.0
func (e BackfillNotPossibleError) Error() string
type CallbackFn ¶ added in v0.2.0
type CallbackFn func(int64)
type CheckConstraint ¶
type CheckConstraint struct {
// Constraint expression
Constraint string `json:"constraint"`
// Name of check constraint
Name string `json:"name"`
}
Check constraint definition
func (*CheckConstraint) Validate ¶
func (c *CheckConstraint) Validate() error
Validate checks that the CheckConstraint is valid
type CheckConstraintError ¶
func (CheckConstraintError) Error ¶
func (e CheckConstraintError) Error() string
func (CheckConstraintError) Unwrap ¶
func (e CheckConstraintError) Unwrap() error
type Column ¶
type Column struct {
// Check constraint for the column
Check *CheckConstraint `json:"check,omitempty"`
// Postgres comment for the column
Comment *string `json:"comment,omitempty"`
// Default value for the column
Default *string `json:"default,omitempty"`
// Name of the column
Name string `json:"name"`
// Indicates if the column is nullable
Nullable bool `json:"nullable,omitempty"`
// Indicates if the column is part of the primary key
Pk bool `json:"pk,omitempty"`
// Foreign key constraint for the column
References *ForeignKeyReference `json:"references,omitempty"`
// Postgres type of the column
Type string `json:"type"`
// Indicates if the column values must be unique
Unique bool `json:"unique,omitempty"`
}
Column definition
func (*Column) HasImplicitDefault ¶ added in v0.8.0
HasImplicitDefault returns true if the column has an implicit default value
func (*Column) IsNullable ¶ added in v0.5.0
IsNullable returns true if the column is nullable
func (*Column) IsPrimaryKey ¶ added in v0.5.0
IsPrimaryKey returns true if the column is part of the primary key
type ColumnAlreadyExistsError ¶
func (ColumnAlreadyExistsError) Error ¶
func (e ColumnAlreadyExistsError) Error() string
type ColumnDoesNotExistError ¶
func (ColumnDoesNotExistError) Error ¶
func (e ColumnDoesNotExistError) Error() string
type ColumnIsNotNullableError ¶
func (ColumnIsNotNullableError) Error ¶
func (e ColumnIsNotNullableError) Error() string
type ColumnIsNullableError ¶ added in v0.5.0
func (ColumnIsNullableError) Error ¶ added in v0.5.0
func (e ColumnIsNullableError) Error() string
type ColumnMigrationMissingError ¶ added in v0.8.0
func (ColumnMigrationMissingError) Error ¶ added in v0.8.0
func (e ColumnMigrationMissingError) Error() string
type ColumnMigrationRedundantError ¶ added in v0.8.0
func (ColumnMigrationRedundantError) Error ¶ added in v0.8.0
func (e ColumnMigrationRedundantError) Error() string
type ColumnReferenceError ¶
func (ColumnReferenceError) Error ¶
func (e ColumnReferenceError) Error() string
func (ColumnReferenceError) Unwrap ¶
func (e ColumnReferenceError) Unwrap() error
type ColumnSQLWriter ¶ added in v0.8.0
type ColumnSQLWriter struct {
WithPK bool
Transformer SQLTransformer
}
ColumnSQLWriter writes a column to SQL It can optionally include the primary key constraint When creating a table, the primary key constraint is not added to the column definition
type ConstraintAlreadyExistsError ¶ added in v0.6.0
func (ConstraintAlreadyExistsError) Error ¶ added in v0.6.0
func (e ConstraintAlreadyExistsError) Error() string
type ConstraintDoesNotExistError ¶ added in v0.5.0
func (ConstraintDoesNotExistError) Error ¶ added in v0.5.0
func (e ConstraintDoesNotExistError) Error() string
type Duplicator ¶ added in v0.5.0
type Duplicator struct {
// contains filtered or unexported fields
}
Duplicator duplicates a column in a table, including all constraints and comments.
func NewColumnDuplicator ¶ added in v0.5.0
NewColumnDuplicator creates a new Duplicator for a column.
func (*Duplicator) Duplicate ¶ added in v0.5.0
func (d *Duplicator) Duplicate(ctx context.Context) error
Duplicate duplicates a column in the table, including all constraints and comments.
func (*Duplicator) WithType ¶ added in v0.5.0
func (d *Duplicator) WithType(columnName, t string) *Duplicator
WithType sets the type of the new column.
func (*Duplicator) WithoutConstraint ¶ added in v0.5.0
func (d *Duplicator) WithoutConstraint(c string) *Duplicator
WithoutConstraint excludes a constraint from being duplicated.
func (*Duplicator) WithoutNotNull ¶ added in v0.5.0
func (d *Duplicator) WithoutNotNull(columnName string) *Duplicator
WithoutNotNull excludes the NOT NULL constraint from being duplicated.
type EmptyMigrationError ¶
type EmptyMigrationError struct{}
func (EmptyMigrationError) Error ¶
func (e EmptyMigrationError) Error() string
type FieldRequiredError ¶
type FieldRequiredError struct {
Name string
}
func (FieldRequiredError) Error ¶
func (e FieldRequiredError) Error() string
type ForeignKeyReference ¶
type ForeignKeyReference struct {
// Name of the referenced column
Column string `json:"column"`
// Name of the foreign key constraint
Name string `json:"name"`
// On delete behavior of the foreign key constraint
OnDelete ForeignKeyReferenceOnDelete `json:"on_delete,omitempty"`
// Name of the referenced table
Table string `json:"table"`
}
Foreign key reference definition
type ForeignKeyReferenceOnDelete ¶ added in v0.6.0
type ForeignKeyReferenceOnDelete string
const ForeignKeyReferenceOnDeleteCASCADE ForeignKeyReferenceOnDelete = "CASCADE"
const ForeignKeyReferenceOnDeleteNOACTION ForeignKeyReferenceOnDelete = "NO ACTION"
const ForeignKeyReferenceOnDeleteRESTRICT ForeignKeyReferenceOnDelete = "RESTRICT"
const ForeignKeyReferenceOnDeleteSETDEFAULT ForeignKeyReferenceOnDelete = "SET DEFAULT"
const ForeignKeyReferenceOnDeleteSETNULL ForeignKeyReferenceOnDelete = "SET NULL"
type IndexAlreadyExistsError ¶
type IndexAlreadyExistsError struct {
Name string
}
func (IndexAlreadyExistsError) Error ¶
func (e IndexAlreadyExistsError) Error() string
type IndexDoesNotExistError ¶
type IndexDoesNotExistError struct {
Name string
}
func (IndexDoesNotExistError) Error ¶
func (e IndexDoesNotExistError) Error() string
type InvalidIdentifierLengthError ¶ added in v0.8.0
type InvalidIdentifierLengthError struct {
Name string
}
func (InvalidIdentifierLengthError) Error ¶ added in v0.8.0
func (e InvalidIdentifierLengthError) Error() string
type InvalidMigrationError ¶
type InvalidMigrationError struct {
Reason string
}
func (InvalidMigrationError) Error ¶
func (e InvalidMigrationError) Error() string
type InvalidOnDeleteSettingError ¶ added in v0.6.0
func (InvalidOnDeleteSettingError) Error ¶ added in v0.6.0
func (e InvalidOnDeleteSettingError) Error() string
type InvalidReplicaIdentityError ¶ added in v0.4.0
func (InvalidReplicaIdentityError) Error ¶ added in v0.4.0
func (e InvalidReplicaIdentityError) Error() string
type IsolatedOperation ¶
type IsolatedOperation interface {
// IsIsolated defines where this operation is isolated when executed on start, cannot be executed
// with other operations.
IsIsolated() bool
}
IsolatedOperation is an operation that cannot be executed with other operations in the same migration.
type Migration ¶
type Migration struct {
Name string `json:"name"`
Operations Operations `json:"operations"`
}
func ReadMigration ¶ added in v0.3.0
ReadMigration reads a migration from an io.Reader, like a file.
func (*Migration) ContainsRawSQLOperation ¶ added in v0.7.0
ContainsRawSQLOperation returns true if the migration contains a raw SQL operation
type MultiColumnConstraintsNotSupportedError ¶ added in v0.8.0
func (MultiColumnConstraintsNotSupportedError) Error ¶ added in v0.8.0
func (e MultiColumnConstraintsNotSupportedError) Error() string
type MultiColumnDownSQL ¶ added in v0.8.0
Map of column names to down SQL expressions
type MultiColumnUpSQL ¶ added in v0.8.0
Map of column names to up SQL expressions
type NoDownSQLAllowedError ¶
type NoDownSQLAllowedError struct{}
func (NoDownSQLAllowedError) Error ¶
func (e NoDownSQLAllowedError) Error() string
type NoUpSQLAllowedError ¶
type NoUpSQLAllowedError struct{}
func (NoUpSQLAllowedError) Error ¶
func (e NoUpSQLAllowedError) Error() string
type OpAddColumn ¶
type OpAddColumn struct {
// Column to add
Column Column `json:"column"`
// Name of the table
Table string `json:"table"`
// SQL expression for up migration
Up string `json:"up,omitempty"`
}
Add column operation
func (*OpAddColumn) Complete ¶
func (o *OpAddColumn) Complete(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
func (*OpAddColumn) Rollback ¶
func (o *OpAddColumn) Rollback(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
func (*OpAddColumn) Start ¶
func (o *OpAddColumn) Start(ctx context.Context, conn db.DB, latestSchema string, tr SQLTransformer, s *schema.Schema, cbs ...CallbackFn) (*schema.Table, error)
type OpAlterColumn ¶
type OpAlterColumn struct {
// Add check constraint to the column
Check *CheckConstraint `json:"check,omitempty"`
// Name of the column
Column string `json:"column"`
// New comment on the column
Comment nullable.Nullable[string] `json:"comment,omitempty"`
// Default value of the column. Setting to null will drop the default if it was
// set previously.
Default nullable.Nullable[string] `json:"default,omitempty"`
// SQL expression for down migration
Down string `json:"down,omitempty"`
// New name of the column (for rename column operation)
Name *string `json:"name,omitempty"`
// Indicates if the column is nullable (for add/remove not null constraint
// operation)
Nullable *bool `json:"nullable,omitempty"`
// Add foreign key constraint to the column
References *ForeignKeyReference `json:"references,omitempty"`
// Name of the table
Table string `json:"table"`
// New type of the column (for change type operation)
Type *string `json:"type,omitempty"`
// Add unique constraint to the column
Unique *UniqueConstraint `json:"unique,omitempty"`
// SQL expression for up migration
Up string `json:"up,omitempty"`
}
Alter column operation
func (*OpAlterColumn) Complete ¶
func (o *OpAlterColumn) Complete(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
func (*OpAlterColumn) IsRenameOnly ¶ added in v0.7.0
func (o *OpAlterColumn) IsRenameOnly() bool
IsRenameOnly returns true if the operation is a rename column operation only.
func (*OpAlterColumn) Rollback ¶
func (o *OpAlterColumn) Rollback(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
func (*OpAlterColumn) Start ¶
func (o *OpAlterColumn) Start(ctx context.Context, conn db.DB, latestSchema string, tr SQLTransformer, s *schema.Schema, cbs ...CallbackFn) (*schema.Table, error)
type OpChangeType ¶
type OpChangeType struct {
Table string `json:"table"`
Column string `json:"column"`
Type string `json:"type"`
Up string `json:"up"`
Down string `json:"down"`
}
func (*OpChangeType) Complete ¶
func (o *OpChangeType) Complete(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
func (*OpChangeType) Rollback ¶
func (o *OpChangeType) Rollback(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
func (*OpChangeType) Start ¶
func (o *OpChangeType) Start(ctx context.Context, conn db.DB, latestSchema string, tr SQLTransformer, s *schema.Schema, cbs ...CallbackFn) (*schema.Table, error)
type OpCreateConstraint ¶ added in v0.8.0
type OpCreateConstraint struct {
// Check constraint expression
Check *string `json:"check,omitempty"`
// Columns to add constraint to
Columns []string `json:"columns,omitempty"`
// SQL expressions for down migrations
Down MultiColumnDownSQL `json:"down"`
// Name of the constraint
Name string `json:"name"`
// Reference to the foreign key
References *OpCreateConstraintReferences `json:"references,omitempty"`
// Name of the table
Table string `json:"table"`
// Type of the constraint
Type OpCreateConstraintType `json:"type"`
// SQL expressions for up migrations
Up MultiColumnUpSQL `json:"up"`
}
Add constraint to table operation
func (*OpCreateConstraint) Complete ¶ added in v0.8.0
func (o *OpCreateConstraint) Complete(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
func (*OpCreateConstraint) Rollback ¶ added in v0.8.0
func (o *OpCreateConstraint) Rollback(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
func (*OpCreateConstraint) Start ¶ added in v0.8.0
func (o *OpCreateConstraint) Start(ctx context.Context, conn db.DB, latestSchema string, tr SQLTransformer, s *schema.Schema, cbs ...CallbackFn) (*schema.Table, error)
type OpCreateConstraintReferences ¶ added in v0.8.0
type OpCreateConstraintReferences struct {
// Columns to reference
Columns []string `json:"columns"`
// On delete behavior of the foreign key constraint
OnDelete ForeignKeyReferenceOnDelete `json:"on_delete,omitempty"`
// Name of the table
Table string `json:"table"`
}
Reference to the foreign key
type OpCreateConstraintType ¶ added in v0.8.0
type OpCreateConstraintType string
const OpCreateConstraintTypeCheck OpCreateConstraintType = "check"
const OpCreateConstraintTypeForeignKey OpCreateConstraintType = "foreign_key"
const OpCreateConstraintTypeUnique OpCreateConstraintType = "unique"
type OpCreateIndex ¶
type OpCreateIndex struct {
// Names of columns on which to define the index
Columns []string `json:"columns"`
// Index method to use for the index: btree, hash, gist, spgist, gin, brin
Method *OpCreateIndexMethod `json:"method,omitempty"`
// Index name
Name string `json:"name"`
// Conditional expression for defining a partial index
Predicate *string `json:"predicate,omitempty"`
// Storage parameters for the index
StorageParameters *string `json:"storage_parameters,omitempty"`
// Name of table on which to define the index
Table string `json:"table"`
// Indicates if the index is unique
Unique *bool `json:"unique,omitempty"`
}
Create index operation
func (*OpCreateIndex) Complete ¶
func (o *OpCreateIndex) Complete(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
func (*OpCreateIndex) Rollback ¶
func (o *OpCreateIndex) Rollback(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
func (*OpCreateIndex) Start ¶
func (o *OpCreateIndex) Start(ctx context.Context, conn db.DB, latestSchema string, tr SQLTransformer, s *schema.Schema, cbs ...CallbackFn) (*schema.Table, error)
type OpCreateIndexMethod ¶ added in v0.8.0
type OpCreateIndexMethod string
const OpCreateIndexMethodBrin OpCreateIndexMethod = "brin"
const OpCreateIndexMethodBtree OpCreateIndexMethod = "btree"
const OpCreateIndexMethodGin OpCreateIndexMethod = "gin"
const OpCreateIndexMethodGist OpCreateIndexMethod = "gist"
const OpCreateIndexMethodHash OpCreateIndexMethod = "hash"
const OpCreateIndexMethodSpgist OpCreateIndexMethod = "spgist"
type OpCreateTable ¶
type OpCreateTable struct {
// Columns corresponds to the JSON schema field "columns".
Columns []Column `json:"columns"`
// Postgres comment for the table
Comment *string `json:"comment,omitempty"`
// Name of the table
Name string `json:"name"`
}
Create table operation
func (*OpCreateTable) Complete ¶
func (o *OpCreateTable) Complete(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
func (*OpCreateTable) Rollback ¶
func (o *OpCreateTable) Rollback(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
func (*OpCreateTable) Start ¶
func (o *OpCreateTable) Start(ctx context.Context, conn db.DB, latestSchema string, tr SQLTransformer, s *schema.Schema, cbs ...CallbackFn) (*schema.Table, error)
type OpDropColumn ¶
type OpDropColumn struct {
// Name of the column
Column string `json:"column"`
// SQL expression for down migration
Down string `json:"down,omitempty"`
// Name of the table
Table string `json:"table"`
}
Drop column operation
func (*OpDropColumn) Complete ¶
func (o *OpDropColumn) Complete(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
func (*OpDropColumn) Rollback ¶
func (o *OpDropColumn) Rollback(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
func (*OpDropColumn) Start ¶
func (o *OpDropColumn) Start(ctx context.Context, conn db.DB, latestSchema string, tr SQLTransformer, s *schema.Schema, cbs ...CallbackFn) (*schema.Table, error)
type OpDropConstraint ¶
type OpDropConstraint struct {
// SQL expression for down migration
Down string `json:"down"`
// Name of the constraint
Name string `json:"name"`
// Name of the table
Table string `json:"table"`
// SQL expression for up migration
Up string `json:"up"`
}
Drop constraint operation
func (*OpDropConstraint) Complete ¶
func (o *OpDropConstraint) Complete(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
func (*OpDropConstraint) Rollback ¶
func (o *OpDropConstraint) Rollback(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
func (*OpDropConstraint) Start ¶
func (o *OpDropConstraint) Start(ctx context.Context, conn db.DB, latestSchema string, tr SQLTransformer, s *schema.Schema, cbs ...CallbackFn) (*schema.Table, error)
type OpDropIndex ¶
type OpDropIndex struct {
// Index name
Name string `json:"name"`
}
Drop index operation
func (*OpDropIndex) Complete ¶
func (o *OpDropIndex) Complete(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
func (*OpDropIndex) Rollback ¶
func (o *OpDropIndex) Rollback(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
func (*OpDropIndex) Start ¶
func (o *OpDropIndex) Start(ctx context.Context, conn db.DB, latestSchema string, tr SQLTransformer, s *schema.Schema, cbs ...CallbackFn) (*schema.Table, error)
type OpDropMultiColumnConstraint ¶ added in v0.8.0
type OpDropMultiColumnConstraint struct {
// SQL expressions for down migrations
Down MultiColumnDownSQL `json:"down"`
// Name of the constraint
Name string `json:"name"`
// Name of the table
Table string `json:"table"`
// SQL expressions for up migrations
Up MultiColumnUpSQL `json:"up,omitempty"`
}
Drop multi-column constraint operation
func (*OpDropMultiColumnConstraint) Complete ¶ added in v0.8.0
func (o *OpDropMultiColumnConstraint) Complete(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
func (*OpDropMultiColumnConstraint) Rollback ¶ added in v0.8.0
func (o *OpDropMultiColumnConstraint) Rollback(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
func (*OpDropMultiColumnConstraint) Start ¶ added in v0.8.0
func (o *OpDropMultiColumnConstraint) Start(ctx context.Context, conn db.DB, latestSchema string, tr SQLTransformer, s *schema.Schema, cbs ...CallbackFn) (*schema.Table, error)
type OpDropNotNull ¶ added in v0.5.0
type OpDropNotNull struct {
Table string `json:"table"`
Column string `json:"column"`
Up string `json:"up"`
Down string `json:"down"`
}
OpDropNotNull is an operation that drops the NOT NULL constraint from a column
func (*OpDropNotNull) Complete ¶ added in v0.5.0
func (o *OpDropNotNull) Complete(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
func (*OpDropNotNull) Rollback ¶ added in v0.5.0
func (o *OpDropNotNull) Rollback(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
func (*OpDropNotNull) Start ¶ added in v0.5.0
func (o *OpDropNotNull) Start(ctx context.Context, conn db.DB, latestSchema string, tr SQLTransformer, s *schema.Schema, cbs ...CallbackFn) (*schema.Table, error)
type OpDropTable ¶
type OpDropTable struct {
// Name of the table
Name string `json:"name"`
}
Drop table operation
func (*OpDropTable) Complete ¶
func (o *OpDropTable) Complete(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
func (*OpDropTable) Rollback ¶
func (o *OpDropTable) Rollback(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
func (*OpDropTable) Start ¶
func (o *OpDropTable) Start(ctx context.Context, conn db.DB, latestSchema string, tr SQLTransformer, s *schema.Schema, cbs ...CallbackFn) (*schema.Table, error)
type OpName ¶
type OpName string
const ( OpNameCreateTable OpName = "create_table" OpNameRenameTable OpName = "rename_table" OpNameDropTable OpName = "drop_table" OpNameAddColumn OpName = "add_column" OpNameDropColumn OpName = "drop_column" OpNameAlterColumn OpName = "alter_column" OpNameCreateIndex OpName = "create_index" OpNameDropIndex OpName = "drop_index" OpNameRenameConstraint OpName = "rename_constraint" OpNameDropConstraint OpName = "drop_constraint" OpNameSetReplicaIdentity OpName = "set_replica_identity" OpNameDropMultiColumnConstraint OpName = "drop_multicolumn_constraint" OpRawSQLName OpName = "sql" OpCreateConstraintName OpName = "create_constraint" )
func OperationName ¶
OperationName returns the name of the operation.
type OpRawSQL ¶
type OpRawSQL struct {
// SQL expression for down migration
Down string `json:"down,omitempty"`
// SQL expression will run on complete step (rather than on start)
OnComplete bool `json:"onComplete,omitempty"`
// SQL expression for up migration
Up string `json:"up"`
}
Raw SQL operation
func (*OpRawSQL) IsIsolated ¶
IsIsolated returns true if the operation is isolated and should be run with other operations.
func (*OpRawSQL) RequiresSchemaRefresh ¶
func (o *OpRawSQL) RequiresSchemaRefresh()
type OpRenameConstraint ¶ added in v0.6.0
type OpRenameConstraint struct {
// Name of the constraint
From string `json:"from"`
// Name of the table
Table string `json:"table"`
// New name of the constraint
To string `json:"to"`
}
Rename constraint operation
func (*OpRenameConstraint) Complete ¶ added in v0.6.0
func (o *OpRenameConstraint) Complete(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
func (*OpRenameConstraint) Rollback ¶ added in v0.6.0
func (o *OpRenameConstraint) Rollback(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
func (*OpRenameConstraint) Start ¶ added in v0.6.0
func (o *OpRenameConstraint) Start(ctx context.Context, conn db.DB, latestSchema string, tr SQLTransformer, s *schema.Schema, cbs ...CallbackFn) (*schema.Table, error)
type OpRenameTable ¶
type OpRenameTable struct {
// Old name of the table
From string `json:"from"`
// New name of the table
To string `json:"to"`
}
Rename table operation
func (*OpRenameTable) Complete ¶
func (o *OpRenameTable) Complete(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
func (*OpRenameTable) Rollback ¶
func (o *OpRenameTable) Rollback(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
func (*OpRenameTable) Start ¶
func (o *OpRenameTable) Start(ctx context.Context, conn db.DB, latestSchema string, tr SQLTransformer, s *schema.Schema, cbs ...CallbackFn) (*schema.Table, error)
type OpSetCheckConstraint ¶
type OpSetCheckConstraint struct {
Table string `json:"table"`
Column string `json:"column"`
Check CheckConstraint `json:"check"`
Up string `json:"up"`
Down string `json:"down"`
}
func (*OpSetCheckConstraint) Complete ¶
func (o *OpSetCheckConstraint) Complete(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
func (*OpSetCheckConstraint) Rollback ¶
func (o *OpSetCheckConstraint) Rollback(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
func (*OpSetCheckConstraint) Start ¶
func (o *OpSetCheckConstraint) Start(ctx context.Context, conn db.DB, latestSchema string, tr SQLTransformer, s *schema.Schema, cbs ...CallbackFn) (*schema.Table, error)
type OpSetComment ¶ added in v0.6.0
type OpSetComment struct {
Table string `json:"table"`
Column string `json:"column"`
Comment *string `json:"comment"`
Up string `json:"up"`
Down string `json:"down"`
}
OpSetComment is a operation that sets a comment on a object.
func (*OpSetComment) Complete ¶ added in v0.6.0
func (o *OpSetComment) Complete(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
func (*OpSetComment) Rollback ¶ added in v0.6.0
func (o *OpSetComment) Rollback(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
func (*OpSetComment) Start ¶ added in v0.6.0
func (o *OpSetComment) Start(ctx context.Context, conn db.DB, latestSchema string, tr SQLTransformer, s *schema.Schema, cbs ...CallbackFn) (*schema.Table, error)
type OpSetDefault ¶ added in v0.6.0
type OpSetDefault struct {
Table string `json:"table"`
Column string `json:"column"`
Default *string `json:"default"`
Up string `json:"up"`
Down string `json:"down"`
}
func (*OpSetDefault) Complete ¶ added in v0.6.0
func (o *OpSetDefault) Complete(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
func (*OpSetDefault) Rollback ¶ added in v0.6.0
func (o *OpSetDefault) Rollback(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
func (*OpSetDefault) Start ¶ added in v0.6.0
func (o *OpSetDefault) Start(ctx context.Context, conn db.DB, latestSchema string, tr SQLTransformer, s *schema.Schema, cbs ...CallbackFn) (*schema.Table, error)
type OpSetForeignKey ¶
type OpSetForeignKey struct {
Table string `json:"table"`
Column string `json:"column"`
References ForeignKeyReference `json:"references"`
Up string `json:"up"`
Down string `json:"down"`
}
func (*OpSetForeignKey) Complete ¶
func (o *OpSetForeignKey) Complete(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
func (*OpSetForeignKey) Rollback ¶
func (o *OpSetForeignKey) Rollback(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
func (*OpSetForeignKey) Start ¶
func (o *OpSetForeignKey) Start(ctx context.Context, conn db.DB, latestSchema string, tr SQLTransformer, s *schema.Schema, cbs ...CallbackFn) (*schema.Table, error)
type OpSetNotNull ¶
type OpSetNotNull struct {
Table string `json:"table"`
Column string `json:"column"`
Up string `json:"up"`
Down string `json:"down"`
}
func (*OpSetNotNull) Complete ¶
func (o *OpSetNotNull) Complete(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
func (*OpSetNotNull) Rollback ¶
func (o *OpSetNotNull) Rollback(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
func (*OpSetNotNull) Start ¶
func (o *OpSetNotNull) Start(ctx context.Context, conn db.DB, latestSchema string, tr SQLTransformer, s *schema.Schema, cbs ...CallbackFn) (*schema.Table, error)
type OpSetReplicaIdentity ¶ added in v0.4.0
type OpSetReplicaIdentity struct {
// Replica identity to set
Identity ReplicaIdentity `json:"identity"`
// Name of the table
Table string `json:"table"`
}
Set replica identity operation
func (*OpSetReplicaIdentity) Complete ¶ added in v0.4.0
func (o *OpSetReplicaIdentity) Complete(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
func (*OpSetReplicaIdentity) Rollback ¶ added in v0.4.0
func (o *OpSetReplicaIdentity) Rollback(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
func (*OpSetReplicaIdentity) Start ¶ added in v0.4.0
func (o *OpSetReplicaIdentity) Start(ctx context.Context, conn db.DB, latestSchema string, tr SQLTransformer, s *schema.Schema, cbs ...CallbackFn) (*schema.Table, error)
type OpSetUnique ¶
type OpSetUnique struct {
Name string `json:"name"`
Table string `json:"table"`
Column string `json:"column"`
Up string `json:"up"`
Down string `json:"down"`
}
func (*OpSetUnique) Complete ¶
func (o *OpSetUnique) Complete(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
func (*OpSetUnique) Rollback ¶
func (o *OpSetUnique) Rollback(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
func (*OpSetUnique) Start ¶
func (o *OpSetUnique) Start(ctx context.Context, conn db.DB, latestSchema string, tr SQLTransformer, s *schema.Schema, cbs ...CallbackFn) (*schema.Table, error)
type Operation ¶
type Operation interface {
// Start will apply the required changes to enable supporting the new schema
// version in the database (through a view)
// update the given views to expose the new schema version
// Returns the table that requires backfilling, if any.
Start(ctx context.Context, conn db.DB, latestSchema string, tr SQLTransformer, s *schema.Schema, cbs ...CallbackFn) (*schema.Table, error)
// Complete will update the database schema to match the current version
// after calling Start.
// This method should be called once the previous version is no longer used.
Complete(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
// Rollback will revert the changes made by Start. It is not possible to
// rollback a completed migration.
Rollback(ctx context.Context, conn db.DB, tr SQLTransformer, s *schema.Schema) error
// Validate returns a descriptive error if the operation cannot be applied to the given schema.
Validate(ctx context.Context, s *schema.Schema) error
}
Operation is an operation that can be applied to a schema
type Operations ¶
type Operations []Operation
func (Operations) MarshalJSON ¶
func (v Operations) MarshalJSON() ([]byte, error)
MarshalJSON serializes the list of operations into a JSON array.
func (*Operations) UnmarshalJSON ¶
func (v *Operations) UnmarshalJSON(data []byte) error
UnmarshalJSON deserializes the list of operations from a JSON array.
type PgRollMigration ¶ added in v0.4.2
type PgRollMigration struct {
// Name of the migration
Name *string `json:"name,omitempty"`
// Operations corresponds to the JSON schema field "operations".
Operations PgRollOperations `json:"operations"`
}
PgRoll migration definition
type PgRollOperation ¶ added in v0.5.0
type PgRollOperation interface{}
type PgRollOperations ¶ added in v0.5.0
type PgRollOperations []interface{}
type ReplicaIdentity ¶ added in v0.4.0
type ReplicaIdentity struct {
// Name of the index to use as replica identity
Index string `json:"index"`
// Type of replica identity
Type string `json:"type"`
}
Replica identity definition
type RequiresSchemaRefreshOperation ¶
type RequiresSchemaRefreshOperation interface {
// RequiresSchemaRefresh defines if this operation requires the resulting schema to be refreshed when
// executed on start.
RequiresSchemaRefresh()
}
RequiresSchemaRefreshOperation is an operation that requires the resulting schema to be refreshed.
type SQLTransformer ¶ added in v0.6.0
type SQLTransformer interface {
// TransformSQL will transform the given SQL statement.
TransformSQL(sql string) (string, error)
}
SQLTransformer is an interface that can be used to transform SQL statements.
type SQLTransformerFunc ¶ added in v0.6.0
func (SQLTransformerFunc) TransformSQL ¶ added in v0.6.0
func (fn SQLTransformerFunc) TransformSQL(sql string) (string, error)
type TableAlreadyExistsError ¶
type TableAlreadyExistsError struct {
Name string
}
func (TableAlreadyExistsError) Error ¶
func (e TableAlreadyExistsError) Error() string
type TableDoesNotExistError ¶
type TableDoesNotExistError struct {
Name string
}
func (TableDoesNotExistError) Error ¶
func (e TableDoesNotExistError) Error() string
type TriggerDirection ¶
type TriggerDirection string
const ( TriggerDirectionUp TriggerDirection = "up" TriggerDirectionDown TriggerDirection = "down" )
type UniqueConstraint ¶
type UniqueConstraint struct {
// Name of unique constraint
Name string `json:"name"`
}
Unique constraint definition
func (*UniqueConstraint) Validate ¶
func (c *UniqueConstraint) Validate() error
Validate validates the UniqueConstraint
Source Files
¶
- backfill.go
- check.go
- column.go
- comment.go
- duplicate.go
- errors.go
- fk_reference.go
- migrations.go
- op_add_column.go
- op_alter_column.go
- op_change_type.go
- op_common.go
- op_create_constraint.go
- op_create_index.go
- op_create_table.go
- op_drop_column.go
- op_drop_constraint.go
- op_drop_index.go
- op_drop_multicolumn_constraint.go
- op_drop_not_null.go
- op_drop_table.go
- op_raw_sql.go
- op_rename_constraint.go
- op_rename_table.go
- op_set_check.go
- op_set_comment.go
- op_set_default.go
- op_set_fk.go
- op_set_notnull.go
- op_set_replica_identity.go
- op_set_unique.go
- rename.go
- trigger.go
- types.go
- unique.go