Documentation ¶
Index ¶
- type Blueprint
- type Builder
- func (builder *Builder) AlterTable(name string, callback func(table Blueprint)) error
- func (builder *Builder) Builder() *Builder
- func (builder *Builder) CreateTable(name string, callback func(table Blueprint)) error
- func (builder *Builder) DB() *sqlx.DB
- func (builder *Builder) DropTable(name string) error
- func (builder *Builder) DropTableIfExists(name string) error
- func (builder *Builder) GetConnection() (*dbal.Connection, error)
- func (builder *Builder) GetDB() (*sqlx.DB, error)
- func (builder *Builder) GetTable(name string) (Blueprint, error)
- func (builder *Builder) GetTables() ([]string, error)
- func (builder *Builder) GetVersion() (*dbal.Version, error)
- func (builder *Builder) HasTable(name string) (bool, error)
- func (builder *Builder) MustAlterTable(name string, callback func(table Blueprint))
- func (builder *Builder) MustCreateTable(name string, callback func(table Blueprint))
- func (builder *Builder) MustDropTable(name string)
- func (builder *Builder) MustDropTableIfExists(name string)
- func (builder *Builder) MustGetConnection() *dbal.Connection
- func (builder *Builder) MustGetDB() *sqlx.DB
- func (builder *Builder) MustGetTable(name string) Blueprint
- func (builder *Builder) MustGetTables() []string
- func (builder *Builder) MustGetVersion() *dbal.Version
- func (builder *Builder) MustHasTable(name string) bool
- func (builder *Builder) MustRenameTable(old string, new string) Blueprint
- func (builder *Builder) RenameTable(old string, new string) error
- func (builder *Builder) SetOption(option *dbal.Option)
- type Column
- func (column *Column) AutoIncrement() *Column
- func (column *Column) HasIndex(name string) bool
- func (column *Column) Index() *Column
- func (column *Column) NotNull() *Column
- func (column *Column) Null() *Column
- func (column *Column) Primary() *Column
- func (column *Column) SetComment(comment string) *Column
- func (column *Column) SetDateTimePrecision(precision int) *Column
- func (column *Column) SetDefault(v interface{}) *Column
- func (column *Column) SetDefaultRaw(v string) *Column
- func (column *Column) SetLength(length int) *Column
- func (column *Column) SetPrecision(precision int) *Column
- func (column *Column) SetScale(scale int) *Column
- func (column *Column) SetType(typ string) *Column
- func (column *Column) Unique() *Column
- func (column *Column) Unsigned() *Column
- type Connection
- type Index
- type Primary
- type Schema
- type Table
- func (table *Table) AddFulltext(key string, columnNames ...string) *Table
- func (table *Table) AddIndex(key string, columnNames ...string) *Table
- func (table *Table) AddPrimary(columnNames ...string)
- func (table *Table) AddUnique(key string, columnNames ...string) *Table
- func (table *Table) BigIncrements(name string) *Column
- func (table *Table) BigInteger(name string) *Column
- func (table *Table) Binary(name string, args ...int) *Column
- func (table *Table) Boolean(name string) *Column
- func (table *Table) Char(name string, args ...int) *Column
- func (table *Table) Date(name string) *Column
- func (table *Table) DateTime(name string, args ...int) *Column
- func (table *Table) DateTimeTz(name string, args ...int) *Column
- func (table *Table) Decimal(name string, args ...int) *Column
- func (table *Table) Double(name string, args ...int) *Column
- func (table *Table) DropColumn(name ...string)
- func (table *Table) DropIndex(key ...string)
- func (table *Table) DropPrimary()
- func (table *Table) DropSoftDeletes()
- func (table *Table) DropSoftDeletesTz()
- func (table *Table) DropTimestamps()
- func (table *Table) DropTimestampsTz()
- func (table *Table) Enum(name string, option []string) *Column
- func (table *Table) Float(name string, args ...int) *Column
- func (table *Table) ForeignID(name string) *Column
- func (table *Table) Get() *Table
- func (table *Table) GetColumn(name string) *Column
- func (table *Table) GetColumns() map[string]*Column
- func (table *Table) GetFullName() string
- func (table *Table) GetIndex(name string) *Index
- func (table *Table) GetIndexes() map[string]*Index
- func (table *Table) GetName() string
- func (table *Table) GetPrefix() string
- func (table *Table) GetPrimary() *Primary
- func (table *Table) HasColumn(name ...string) bool
- func (table *Table) HasIndex(name ...string) bool
- func (table *Table) ID(name string) *Column
- func (table *Table) IPAddress(name string) *Column
- func (table *Table) Increments(name string) *Column
- func (table *Table) Integer(name string) *Column
- func (table *Table) JSON(name string) *Column
- func (table *Table) JSONB(name string) *Column
- func (table *Table) LongText(name string) *Column
- func (table *Table) MACAddress(name string) *Column
- func (table *Table) MediumText(name string) *Column
- func (table *Table) RenameColumn(old string, new string) *Column
- func (table *Table) RenameIndex(old string, new string) *Index
- func (table *Table) SmallIncrements(name string) *Column
- func (table *Table) SmallInteger(name string) *Column
- func (table *Table) SoftDeletes(args ...int) *Column
- func (table *Table) SoftDeletesTz(args ...int) *Column
- func (table *Table) String(name string, args ...int) *Column
- func (table *Table) Text(name string) *Column
- func (table *Table) Time(name string, args ...int) *Column
- func (table *Table) TimeTz(name string, args ...int) *Column
- func (table *Table) Timestamp(name string, args ...int) *Column
- func (table *Table) TimestampTz(name string, args ...int) *Column
- func (table *Table) Timestamps(args ...int) map[string]*Column
- func (table *Table) TimestampsTz(args ...int) map[string]*Column
- func (table *Table) TinyIncrements(name string) *Column
- func (table *Table) TinyInteger(name string) *Column
- func (table *Table) UUID(name string) *Column
- func (table *Table) UnsignedBigInteger(name string) *Column
- func (table *Table) UnsignedDecimal(name string, args ...int) *Column
- func (table *Table) UnsignedDouble(name string, args ...int) *Column
- func (table *Table) UnsignedFloat(name string, args ...int) *Column
- func (table *Table) UnsignedInteger(name string) *Column
- func (table *Table) UnsignedSmallInteger(name string) *Column
- func (table *Table) UnsignedTinyInteger(name string) *Column
- func (table *Table) Year(name string) *Column
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Blueprint ¶
type Blueprint interface { // defined in table.go Get() *Table GetName() string GetPrefix() string GetFullName() string GetColumns() map[string]*Column GetIndexes() map[string]*Index // defined in column.go GetColumn(name string) *Column HasColumn(name ...string) bool RenameColumn(old string, new string) *Column DropColumn(name ...string) // defined in primry.go GetPrimary() *Primary AddPrimary(columnName ...string) DropPrimary() // defined in index.go GetIndex(name string) *Index HasIndex(name ...string) bool AddIndex(name string, columnNames ...string) *Table AddUnique(name string, columnNames ...string) *Table AddFulltext(name string, columnNames ...string) *Table RenameIndex(old string, new string) *Index DropIndex(name ...string) // defined in blueprint.go // Character types String(name string, args ...int) *Column Char(name string, args ...int) *Column Text(name string) *Column MediumText(name string) *Column LongText(name string) *Column // Binary types Binary(name string, args ...int) *Column // Date time types Date(name string) *Column DateTime(name string, args ...int) *Column DateTimeTz(name string, args ...int) *Column Time(name string, args ...int) *Column TimeTz(name string, args ...int) *Column Timestamp(name string, args ...int) *Column TimestampTz(name string, args ...int) *Column // Numberic types // @todo: MediumInteger TinyInteger(name string) *Column UnsignedTinyInteger(name string) *Column TinyIncrements(name string) *Column SmallInteger(name string) *Column UnsignedSmallInteger(name string) *Column SmallIncrements(name string) *Column Integer(name string) *Column UnsignedInteger(name string) *Column Increments(name string) *Column BigInteger(name string) *Column UnsignedBigInteger(name string) *Column BigIncrements(name string) *Column ID(name string) *Column ForeignID(name string) *Column Decimal(name string, args ...int) *Column UnsignedDecimal(name string, args ...int) *Column Float(name string, args ...int) *Column UnsignedFloat(name string, args ...int) *Column Double(name string, args ...int) *Column UnsignedDouble(name string, args ...int) *Column // boolean, enum types Boolean(name string) *Column Enum(name string, option []string) *Column // json, jsonb types JSON(name string) *Column JSONB(name string) *Column // uuid, ipAddress, macAddress, year etc. // @todo: geometry, geometryCollection, point, multiPoint, polygon, multiPolygon UUID(name string) *Column IPAddress(name string) *Column MACAddress(name string) *Column Year(name string) *Column // timestamps, timestampsTz,DropTimestamps, DropTimestampsTz, softDeletes, softDeletesTz, DropSoftDeletes, DropSoftDeletesTz Timestamps(args ...int) map[string]*Column TimestampsTz(args ...int) map[string]*Column DropTimestamps() DropTimestampsTz() SoftDeletes(args ...int) *Column SoftDeletesTz(args ...int) *Column DropSoftDeletes() DropSoftDeletesTz() }
Blueprint the table operating interface
type Builder ¶
Builder the table schema builder struct
func (*Builder) AlterTable ¶ added in v0.0.3
AlterTable alter a table on the schema.
func (*Builder) CreateTable ¶ added in v0.0.3
CreateTable create a new table on the schema.
func (*Builder) DropTableIfExists ¶ added in v0.0.3
DropTableIfExists Indicate that the table should be dropped if it exists.
func (*Builder) GetConnection ¶ added in v0.0.3
func (builder *Builder) GetConnection() (*dbal.Connection, error)
GetConnection Get the database connection instance.
func (*Builder) GetVersion ¶ added in v0.0.3
GetVersion get the version of the connection database
func (*Builder) MustAlterTable ¶ added in v0.0.3
MustAlterTable alter a table on the schema.
func (*Builder) MustCreateTable ¶ added in v0.0.3
MustCreateTable create a new table on the schema.
func (*Builder) MustDropTable ¶ added in v0.0.3
MustDropTable Indicate that the table should be dropped.
func (*Builder) MustDropTableIfExists ¶ added in v0.0.3
MustDropTableIfExists Indicate that the table should be dropped if it exists.
func (*Builder) MustGetConnection ¶ added in v0.0.3
func (builder *Builder) MustGetConnection() *dbal.Connection
MustGetConnection Get the database connection instance.
func (*Builder) MustGetTable ¶ added in v0.0.3
MustGetTable a table on the schema.
func (*Builder) MustGetTables ¶ added in v0.0.3
MustGetTables Get all of the table names for the schema.
func (*Builder) MustGetVersion ¶ added in v0.0.3
MustGetVersion get the version of the connection database
func (*Builder) MustHasTable ¶ added in v0.0.3
MustHasTable determine if the given table exists.
func (*Builder) MustRenameTable ¶ added in v0.0.3
MustRenameTable rename a table on the schema.
func (*Builder) RenameTable ¶ added in v0.0.3
RenameTable rename a table on the schema.
type Column ¶
Column the table column struct
func (*Column) AutoIncrement ¶
AutoIncrement set the numeric column AutoIncrement attribute is true
func (*Column) SetComment ¶ added in v0.0.3
SetComment set the column comment to the given value
func (*Column) SetDateTimePrecision ¶ added in v0.0.3
SetDateTimePrecision set the column precision to the given value
func (*Column) SetDefault ¶ added in v0.5.1
SetDefault set the column default attribute to the given type name
func (*Column) SetDefaultRaw ¶ added in v0.5.1
SetDefaultRaw set the column default raw attribute to the given type name
func (*Column) SetLength ¶ added in v0.0.3
SetLength set the column Length attribute to the given length
func (*Column) SetPrecision ¶ added in v0.0.3
SetPrecision set the column precision to the given value
type Connection ¶
type Connection struct { Write *sqlx.DB WriteConfig *dbal.Config Option *dbal.Option Version *dbal.Version }
Connection the database connection for schema operating
type Schema ¶
type Schema interface { SetOption(option *dbal.Option) Builder() *Builder GetConnection() (*dbal.Connection, error) GetDB() (*sqlx.DB, error) GetVersion() (*dbal.Version, error) GetTables() ([]string, error) GetTable(name string) (Blueprint, error) CreateTable(name string, createFunc func(table Blueprint)) error DropTable(name string) error AlterTable(name string, alterFunc func(table Blueprint)) error HasTable(name string) (bool, error) RenameTable(old string, new string) error DropTableIfExists(name string) error MustGetConnection() *dbal.Connection MustGetDB() *sqlx.DB MustGetVersion() *dbal.Version MustGetTables() []string MustGetTable(name string) Blueprint MustCreateTable(name string, createFunc func(table Blueprint)) MustDropTable(name string) MustAlterTable(name string, alterFunc func(table Blueprint)) MustHasTable(name string) bool MustRenameTable(old string, new string) Blueprint MustDropTableIfExists(name string) DB() *sqlx.DB // alias MustGetDB }
Schema The schema interface
func Use ¶
func Use(conn *Connection) Schema
Use create a new schema interface using the given connection
type Table ¶
type Table struct { *dbal.Table *Builder *Primary ColumnMap map[string]*Column IndexMap map[string]*Index Name string Prefix string }
Table the table struct
func (*Table) AddFulltext ¶ added in v0.5.1
AddFulltext Indicate that the given fulltext index should be created.(donthing here)
func (*Table) AddPrimary ¶ added in v0.0.3
AddPrimary Indicate that the given column should be a primary index.
func (*Table) AddUnique ¶ added in v0.0.3
AddUnique Indicate that the given unique index should be created.
func (*Table) BigIncrements ¶
BigIncrements Create a new auto-incrementing big integer (8-byte) column on the table.
func (*Table) BigInteger ¶
BigInteger Create a new auto-incrementing big integer (8-byte) column on the table.
func (*Table) DateTimeTz ¶ added in v0.0.3
DateTimeTz Create a new date-time column (with time zone) on the table.
func (*Table) DropColumn ¶
DropColumn Indicate that the given columns should be dropped.
func (*Table) DropPrimary ¶
func (table *Table) DropPrimary()
DropPrimary Indicate that dropping the primary index
func (*Table) DropSoftDeletes ¶ added in v0.0.3
func (table *Table) DropSoftDeletes()
DropSoftDeletes drop the "deleted_at" timestamp columns.
func (*Table) DropSoftDeletesTz ¶ added in v0.0.3
func (table *Table) DropSoftDeletesTz()
DropSoftDeletesTz drop the "deleted_at" timestamp columns.
func (*Table) DropTimestamps ¶ added in v0.0.3
func (table *Table) DropTimestamps()
DropTimestamps drop the "created_at", "updated_at" timestamp columns.
func (*Table) DropTimestampsTz ¶ added in v0.0.3
func (table *Table) DropTimestampsTz()
DropTimestampsTz drop the "created_at", "updated_at" timestamp columns.
func (*Table) ForeignID ¶ added in v0.0.3
ForeignID Alias UnsignedBigInteger. Create a new unsigned big integer (8-byte) column on the table.
func (*Table) GetColumn ¶
GetColumn get the column instance of the table, if the column does not exist return nil.
func (*Table) GetColumns ¶
GetColumns Get the columns map of the table
func (*Table) GetFullName ¶ added in v0.0.3
GetFullName get the table name with prefix
func (*Table) GetIndex ¶
GetIndex get the index instance for the given name,if the index does not exist return nil.
func (*Table) GetIndexes ¶
GetIndexes Get the indexes map of the table
func (*Table) GetPrimary ¶ added in v0.0.3
GetPrimary get the table primary key instance
func (*Table) ID ¶
ID Alias BigIncrements. Create a new auto-incrementing big integer (8-byte) column on the table.
func (*Table) IPAddress ¶ added in v0.0.3
IPAddress Create a new IP address ( integer 4-byte ) column on the table.
func (*Table) Increments ¶ added in v0.0.3
Increments Create a new auto-incrementing big integer (2-byte) column on the table.
func (*Table) MACAddress ¶ added in v0.0.3
MACAddress Create a new MAC address column on the table.
func (*Table) MediumText ¶ added in v0.0.3
MediumText Create a new medium text column on the table.
func (*Table) RenameColumn ¶
RenameColumn Indicate that the given column should be renamed.
func (*Table) RenameIndex ¶
RenameIndex Indicate that the given indexes should be renamed.
func (*Table) SmallIncrements ¶ added in v0.0.3
SmallIncrements Create a new auto-incrementing small integer (2-byte) column on the table.
func (*Table) SmallInteger ¶ added in v0.0.3
SmallInteger Create a new small integer (2-byte) column on the table.
func (*Table) SoftDeletes ¶ added in v0.0.3
SoftDeletes Add a "deleted_at" timestamp for the table.
func (*Table) SoftDeletesTz ¶ added in v0.0.3
SoftDeletesTz Add a "deleted_at" timestampTz for the table.
func (*Table) TimeTz ¶ added in v0.0.3
TimeTz Create a new time column (with time zone) on the table.
func (*Table) TimestampTz ¶ added in v0.0.3
TimestampTz Create a new timestamp (with time zone) column on the table.
func (*Table) Timestamps ¶ added in v0.0.3
Timestamps Add nullable creation and update timestamps to the table.
func (*Table) TimestampsTz ¶ added in v0.0.3
TimestampsTz Add creation and update timestampTz columns to the table.
func (*Table) TinyIncrements ¶ added in v0.0.3
TinyIncrements Create a new auto-incrementing tiny integer (1-byte) column on the table.
func (*Table) TinyInteger ¶ added in v0.0.3
TinyInteger Create a new tiny integer (1-byte) column on the table.
func (*Table) UnsignedBigInteger ¶
UnsignedBigInteger Create a new unsigned big integer (8-byte) column on the table.
func (*Table) UnsignedDecimal ¶ added in v0.0.3
UnsignedDecimal Create a new unsigned decimal (16-byte) column on the table.
func (*Table) UnsignedDouble ¶ added in v0.0.3
UnsignedDouble Create a new unsigned double (8-byte) column on the table.
func (*Table) UnsignedFloat ¶ added in v0.0.3
UnsignedFloat Create a new unsigned float (4-byte) column on the table.
func (*Table) UnsignedInteger ¶ added in v0.0.3
UnsignedInteger Create a new auto-incrementing integer (4-byte) column on the table.
func (*Table) UnsignedSmallInteger ¶ added in v0.0.3
UnsignedSmallInteger Create a new unsigned small integer (2-byte) column on the table.
func (*Table) UnsignedTinyInteger ¶ added in v0.0.3
UnsignedTinyInteger Create a new auto-incrementing tiny integer (1-byte) column on the table.