Documentation
¶
Overview ¶
Package fizz is a common DSL for writing SQL migrations
Index ¶
- Constants
- Variables
- func AFile(f io.Reader, t Translator) (string, error)
- func AString(s string, t Translator) (string, error)
- type BubbleType
- type Bubbler
- type Column
- type ForeignKey
- type ForeignKeyRef
- type Index
- type Options
- type Table
- func (t *Table) Column(name string, colType string, options Options) error
- func (t *Table) ColumnNames() []string
- func (t *Table) DisableTimestamps()
- func (t Table) Fizz() string
- func (t *Table) ForeignKey(column string, refs interface{}, options Options) error
- func (t *Table) HasColumns(args ...string) bool
- func (t *Table) Index(columns interface{}, options Options) error
- func (t *Table) PrimaryKey(pk ...string) error
- func (t *Table) PrimaryKeys() []string
- func (t Table) String() string
- func (t *Table) Timestamp(name string) error
- func (t *Table) Timestamps() error
- func (t Table) UnFizz() string
- type Translator
Constants ¶
const Version = "v1.14.3"
Version gives the current fizz version.
Variables ¶
var CREATED_COL = Column{Name: "created_at", ColType: "timestamp", Options: nil}
var INT_ID_COL = Column{ Name: "id", Primary: true, ColType: "integer", Options: Options{}, }
Deprecated: Fizz won't force you to have an ID field now.
var UPDATED_COL = Column{Name: "updated_at", ColType: "timestamp", Options: nil}
var UUID_ID_COL = Column{ Name: "id", Primary: true, ColType: "uuid", Options: Options{}, }
Deprecated: Fizz won't force you to have an ID field now.
Functions ¶
Types ¶
type BubbleType ¶
type BubbleType int
type Bubbler ¶
type Bubbler struct { Translator // contains filtered or unexported fields }
func NewBubbler ¶
func NewBubbler(t Translator) *Bubbler
type ForeignKey ¶
type ForeignKey struct { Name string Column string References ForeignKeyRef Options Options }
func (ForeignKey) String ¶ added in v1.6.0
func (f ForeignKey) String() string
type ForeignKeyRef ¶
type Table ¶
type Table struct { Name string `db:"name"` Columns []Column Indexes []Index ForeignKeys []ForeignKey Options map[string]interface{} // contains filtered or unexported fields }
Table is the table definition for fizz.
func (*Table) ColumnNames ¶
ColumnNames returns the names of the Table's columns.
func (*Table) DisableTimestamps ¶
func (t *Table) DisableTimestamps()
func (*Table) ForeignKey ¶
ForeignKey adds a new foreign key to the table definition.
func (*Table) HasColumns ¶
HasColumns checks if the Table has all the given columns.
func (*Table) PrimaryKey ¶ added in v1.7.0
PrimaryKey adds a primary key to the table. It's useful to define a composite primary key.
func (*Table) PrimaryKeys ¶ added in v1.7.0
PrimaryKeys gets the list of registered primary key fields.
func (*Table) Timestamps ¶
Timestamps adds created_at and updated_at columns to the Table definition.
type Translator ¶
type Translator interface { CreateTable(Table) (string, error) DropTable(Table) (string, error) RenameTable([]Table) (string, error) AddColumn(Table) (string, error) ChangeColumn(Table) (string, error) DropColumn(Table) (string, error) RenameColumn(Table) (string, error) AddIndex(Table) (string, error) DropIndex(Table) (string, error) RenameIndex(Table) (string, error) AddForeignKey(Table) (string, error) DropForeignKey(Table) (string, error) }
Translator describes the common interface to define a fizz to SQL translator.