gomimi

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AlterColumnBuilder

type AlterColumnBuilder interface {
	AlterType(typeName string) AlterColumnBuilder
	AlterDefault(expression string) AlterColumnBuilder
	DropDefault() AlterColumnBuilder
	SetNullable() AlterColumnBuilder
	DropNullable() AlterColumnBuilder
	SetAutoIncrement() AlterColumnBuilder
	DropAutoIncrement() AlterColumnBuilder
}

type Builder

type Builder interface {
	Begin()
	Rollback()
	Commit() string
	CreateTable(name string, columns []ColumnDefinition, constraints []ConstraintDefinition) TableBuilder
	AlterTable(name string) TableBuilder
	DropTable(name string) Builder
	TruncateTable(name string) Builder
}

func NewBuilderPostgreSQL

func NewBuilderPostgreSQL() Builder

type ColumnBuilder

type ColumnBuilder interface {
	WithName(name string) ColumnBuilder
	WithType(typeName string) ColumnBuilder
	WithDefault(expression string) ColumnBuilder
	IsNullable(enableNullable bool) ColumnBuilder
	IsPrimaryKey(enablePrimaryKey bool) ColumnBuilder
	IsUnique(enableUnique bool) ColumnBuilder
	IsForeignKey(enableForeign bool, referenceTableName string, referenceColumnNames ...string) ColumnBuilder
	IsCheck(expression string) ColumnBuilder
	IsAutoIncrement(enableAutoIncrement bool) ColumnBuilder
	Build() ColumnDefinition
}

type ColumnDefinition

type ColumnDefinition struct {
	Name                 string
	Type                 string
	Default              string
	Nullable             bool
	PrimaryKey           bool
	Unique               bool
	Reference            bool
	ReferenceTableName   string
	ReferenceColumnNames []string
	CheckExpression      string
	AutoIncrement        bool
}

type ConstraintBuilder

type ConstraintBuilder interface {
	WithName(name string) ConstraintBuilder
	WithColumns(columnNames ...string) ConstraintBuilder
	IsPrimaryKey(enablePrimary bool) ConstraintBuilder
	IsUnique(enableUnique bool) ConstraintBuilder
	IsForeignKey(enableForeign bool, referenceTableName string, referenceColumnNames ...string) ConstraintBuilder
	IsCheck(expression string) ConstraintBuilder
	Build() ConstraintDefinition
}

type ConstraintDefinition

type ConstraintDefinition struct {
	Name                 string
	ColumnNames          []string
	Type                 ConstraintDefinitionType
	DefaultExpression    string
	ReferenceTableName   string
	ReferenceColumnNames []string
	CheckExpression      string
}

type ConstraintDefinitionType

type ConstraintDefinitionType uint8
const (
	ConstraintPrimaryKey ConstraintDefinitionType = iota
	ConstraintUnique
	ConstraintForeignKey
	ConstraintCheck
)

type IndexBuilder

type IndexBuilder interface {
	WithName(name string) IndexBuilder
	WithColumns(columnNames ...string) IndexBuilder
	IsUnique(enableUnique bool) IndexBuilder
	On(partialCondition string) IndexBuilder
	Build() IndexDefinition
}

type IndexDefinition

type IndexDefinition struct {
	Name         string
	ColumnNames  []string
	Unique       bool
	OnExpression string
}

type Migration

type Migration interface {
	Up(builder Builder) error
	Down(builder Builder) error
}

type Runner

type Runner struct {
	// contains filtered or unexported fields
}

func NewRunner

func NewRunner(builder Builder) Runner

func (Runner) Run

func (runner Runner) Run(migrations ...Migration)

type TableBuilder

type TableBuilder interface {
	Rename(newTableName string) TableBuilder
	AddColumn(column ColumnDefinition) TableBuilder
	AddConstraint(constraint ConstraintDefinition) TableBuilder
	AddIndex(index IndexDefinition) TableBuilder
	AlterColumn(columnName string, callback func(alterColumnBuilder AlterColumnBuilder)) TableBuilder
	DropColumn(columnName string) TableBuilder
	DropConstraint(constraintName string) TableBuilder
	DropIndex(indexName string) TableBuilder
	RenameColumn(oldColumnName string, newColumnName string) TableBuilder
	RenameConstraint(oldConstraintName string, newConstraintName string) TableBuilder
	RenameIndex(oldIndexName string, newIndexName string) TableBuilder
}

Jump to

Keyboard shortcuts

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