fizz: github.com/gobuffalo/fizz Index | Files | Directories

package fizz

import "github.com/gobuffalo/fizz"

Package fizz is a common DSL for writing SQL migrations

Index

Package Files

bubbler.go columns.go fizz.go foreign_keys.go index.go raw_sql.go tables.go translator.go version.go

Constants

const Version = "v1.9.2"

Version gives the current fizz version.

Variables

var CREATED_COL = Column{Name: "created_at", ColType: "timestamp", Options: Options{}}
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: Options{}}
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.

func AFile Uses

func AFile(f io.Reader, t Translator) (string, error)

AFile reads in a fizz migration from an io.Reader and translates its contents to SQL.

func AString Uses

func AString(s string, t Translator) (string, error)

AString reads a fizz string, and translates its contents to SQL.

type BubbleType Uses

type BubbleType int

type Bubbler Uses

type Bubbler struct {
    Translator
    // contains filtered or unexported fields
}

func NewBubbler Uses

func NewBubbler(t Translator) *Bubbler

func (*Bubbler) Bubble Uses

func (b *Bubbler) Bubble(s string) (string, error)

func (*Bubbler) String Uses

func (b *Bubbler) String() string

type Column Uses

type Column struct {
    Name    string
    ColType string
    Primary bool
    Options map[string]interface{}
}

func (Column) String Uses

func (c Column) String() string

type ForeignKey Uses

type ForeignKey struct {
    Name       string
    Column     string
    References ForeignKeyRef
    Options    Options
}

func (ForeignKey) String Uses

func (f ForeignKey) String() string

type ForeignKeyRef Uses

type ForeignKeyRef struct {
    Table   string
    Columns []string
}

type Index Uses

type Index struct {
    Name    string
    Columns []string
    Unique  bool
    Options Options
}

Index is the index definition for fizz.

func (Index) String Uses

func (i Index) String() string

type Options Uses

type Options map[string]interface{}

Options is a generic map of options.

type Table Uses

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 NewTable Uses

func NewTable(name string, opts map[string]interface{}) Table

NewTable creates a new Table.

func (*Table) Column Uses

func (t *Table) Column(name string, colType string, options Options) error

Column adds a column to the table definition.

func (*Table) ColumnNames Uses

func (t *Table) ColumnNames() []string

ColumnNames returns the names of the Table's columns.

func (*Table) DisableTimestamps Uses

func (t *Table) DisableTimestamps()

func (Table) Fizz Uses

func (t Table) Fizz() string

Fizz returns the fizz DDL to create the table.

func (*Table) ForeignKey Uses

func (t *Table) ForeignKey(column string, refs interface{}, options Options) error

ForeignKey adds a new foreign key to the table definition.

func (*Table) HasColumns Uses

func (t *Table) HasColumns(args ...string) bool

HasColumns checks if the Table has all the given columns.

func (*Table) Index Uses

func (t *Table) Index(columns interface{}, options Options) error

Index adds a new index to the table definition.

func (*Table) PrimaryKey Uses

func (t *Table) PrimaryKey(pk ...string) error

PrimaryKey adds a primary key to the table. It's useful to define a composite primary key.

func (*Table) PrimaryKeys Uses

func (t *Table) PrimaryKeys() []string

PrimaryKeys gets the list of registered primary key fields.

func (Table) String Uses

func (t Table) String() string

func (*Table) Timestamp Uses

func (t *Table) Timestamp(name string) error

Timestamp is a shortcut to add a timestamp column with default options.

func (*Table) Timestamps Uses

func (t *Table) Timestamps() error

Timestamps adds created_at and updated_at columns to the Table definition.

func (Table) UnFizz Uses

func (t Table) UnFizz() string

UnFizz returns the fizz DDL to remove the table.

type Translator Uses

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.

Directories

PathSynopsis
packrdYou can use the "packr2 clean" command to clean up this, and any other packr generated files.
translators

Package fizz imports 12 packages (graph) and is imported by 5 packages. Updated 2019-06-30. Refresh now. Tools for package owners.