Documentation
¶
Index ¶
- type AlterationType
- type Catalog
- func (c *Catalog) AddEnum(schemaName string, enum *Enum) error
- func (c *Catalog) AddTable(schemaName string, table *Table) error
- func (c *Catalog) AlterTable(schemaName, tableName string, alteration TableAlteration) error
- func (c *Catalog) CreateSchema(name string) (*Schema, error)
- func (c *Catalog) DropTable(schemaName, tableName string) error
- func (c *Catalog) GetSchema(name string) (*Schema, error)
- func (c *Catalog) GetTable(schemaName, tableName string) (*Table, error)
- func (c *Catalog) ListTables(schemaName string) ([]*Table, error)
- func (c *Catalog) RenameTable(schemaName, oldName, newName string) error
- type Column
- func (c *Column) Clone() *Column
- func (c *Column) SetArray() *Column
- func (c *Column) SetAutoIncrement() *Column
- func (c *Column) SetCreatedBy(migrationFile string) *Column
- func (c *Column) SetDefault(defaultValue string) *Column
- func (c *Column) SetForeignKey(referencedTable, referencedColumn string) *Column
- func (c *Column) SetLength(length int32) *Column
- func (c *Column) SetModifiedBy(migrationFile string) *Column
- func (c *Column) SetNotNull() *Column
- func (c *Column) SetPrecisionScale(precision, scale int32) *Column
- func (c *Column) SetPrimaryKey() *Column
- func (c *Column) SetUnique() *Column
- func (c *Column) ValidatePrimaryKeyDatatype(databaseType, migrationFile string) error
- type Enum
- type ForeignKey
- type Index
- type Schema
- type Table
- func (t *Table) AddColumn(column *Column) error
- func (t *Table) AddIndex(index *Index) error
- func (t *Table) Clone() *Table
- func (t *Table) DropColumn(name string) error
- func (t *Table) DropIndex(name string) error
- func (t *Table) GetColumn(name string) (*Column, error)
- func (t *Table) GetPrimaryKeyColumns() []*Column
- func (t *Table) ModifyColumn(name string, newColumn *Column) error
- func (t *Table) RenameColumn(oldName, newName string) error
- func (t *Table) SetCreatedBy(migrationFile string) *Table
- type TableAlteration
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AlterationType ¶
type AlterationType int
AlterationType represents alteration type.
const ( // AddColumn is a constant value for add column. AddColumn AlterationType = iota // DropColumn is a constant value for drop column. DropColumn // ModifyColumn is a constant value for modify column. ModifyColumn // RenameColumn is a constant value for rename column. RenameColumn // AddIndex is a constant value for add index. AddIndex // DropIndex is a constant value for drop index. DropIndex )
type Catalog ¶
type Catalog struct {
DefaultSchema string
Schemas map[string]*Schema
// contains filtered or unexported fields
}
Catalog represents catalog.
func (*Catalog) AlterTable ¶
func (c *Catalog) AlterTable( schemaName, tableName string, alteration TableAlteration, ) error
AlterTable performs the alter table operation.
func (*Catalog) CreateSchema ¶
CreateSchema performs the create schema operation.
func (*Catalog) ListTables ¶
ListTables performs the list tables operation.
func (*Catalog) RenameTable ¶
RenameTable performs the rename table operation.
type Column ¶
type Column struct {
Name string
DataType string
IsNullable bool
IsArray bool
Length *int32
Precision *int32
Scale *int32
DefaultVal *string
CreatedBy string // migration file that added this column
ModifiedBy string // migration file that last modified this column
IsPrimaryKey bool
IsUnique bool
IsAutoIncrement bool
ForeignKey *ForeignKey // nil if not a foreign key
}
Column represents column.
func (*Column) SetAutoIncrement ¶ added in v1.0.0
SetAutoIncrement sets auto increment.
func (*Column) SetCreatedBy ¶
SetCreatedBy sets created by.
func (*Column) SetDefault ¶
SetDefault sets default.
func (*Column) SetForeignKey ¶ added in v1.0.0
SetForeignKey sets foreign key.
func (*Column) SetModifiedBy ¶
SetModifiedBy sets modified by.
func (*Column) SetPrecisionScale ¶
SetPrecisionScale sets precision scale.
func (*Column) SetPrimaryKey ¶
SetPrimaryKey sets primary key.
func (*Column) ValidatePrimaryKeyDatatype ¶
ValidatePrimaryKeyDatatype performs the validate primary key datatype operation.
type ForeignKey ¶ added in v1.0.0
ForeignKey represents foreign key.
type Table ¶
type Table struct {
Schema string
Name string
Columns []*Column
Indexes []*Index
CreatedBy string // migration file that created this table
}
Table represents table.
func (*Table) DropColumn ¶
DropColumn performs the drop column operation.
func (*Table) GetPrimaryKeyColumns ¶
GetPrimaryKeyColumns returns primary key columns.
func (*Table) ModifyColumn ¶
ModifyColumn performs the modify column operation.
func (*Table) RenameColumn ¶
RenameColumn performs the rename column operation.
func (*Table) SetCreatedBy ¶
SetCreatedBy sets created by.
type TableAlteration ¶
type TableAlteration struct {
Type AlterationType
Column *Column
OldName string
NewName string
IndexName string
IndexDef *Index
}
TableAlteration represents table alteration.