Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Blueprint ¶
type Blueprint interface {
// BigIncrements Create a new auto-incrementing big integer (8-byte) column on the table.
BigIncrements(column string) driver.ColumnDefinition
// BigInteger Create a new big integer (8-byte) column on the table.
BigInteger(column string) driver.ColumnDefinition
// Boolean Create a new boolean column on the table.
Boolean(column string) driver.ColumnDefinition
// Build Execute the blueprint to build / modify the table.
Build(query orm.Query, grammar driver.Grammar) error
// Char Create a new char column on the table.
Char(column string, length ...int) driver.ColumnDefinition
// Column Create a new custom type column on the table.
Column(column string, ttype string) driver.ColumnDefinition
// Comment Add a comment to the table. (MySQL / PostgreSQL)
Comment(value string)
// Create Indicate that the table needs to be created.
Create()
// Date Create a new date column on the table.
Date(column string) driver.ColumnDefinition
// DateTime Create a new date-time column on the table.
DateTime(column string, precision ...int) driver.ColumnDefinition
// DateTimeTz Create a new date-time column (with time zone) on the table.
DateTimeTz(column string, precision ...int) driver.ColumnDefinition
// Decimal Create a new decimal column on the table.
Decimal(column string) driver.ColumnDefinition
// Double Create a new double column on the table.
Double(column string) driver.ColumnDefinition
// Drop Indicate that the table should be dropped.
Drop()
// DropColumn Indicate that the given columns should be dropped.
DropColumn(column ...string)
// DropForeign Indicate that the given foreign key should be dropped.
DropForeign(column ...string)
// DropForeignByName Indicate that the given foreign key should be dropped.
DropForeignByName(name string)
// DropFullText Indicate that the given fulltext index should be dropped.
DropFullText(column ...string)
// DropFullTextByName Indicate that the given fulltext index should be dropped.
DropFullTextByName(name string)
// DropIfExists Indicate that the table should be dropped if it exists.
DropIfExists()
// DropIndex Indicate that the given index should be dropped.
DropIndex(column ...string)
// DropIndexByName Indicate that the given index should be dropped.
DropIndexByName(name string)
// DropPrimary Indicate that the given primary key should be dropped.
DropPrimary(column ...string)
// DropSoftDeletes Indicate that the soft delete column should be dropped.
DropSoftDeletes(column ...string)
// DropSoftDeletesTz Indicate that the soft delete column should be dropped.
DropSoftDeletesTz(column ...string)
// DropTimestamps Indicate that the timestamp columns should be dropped.
DropTimestamps()
// DropTimestampsTz Indicate that the timestamp columns should be dropped.
DropTimestampsTz()
// DropUnique Indicate that the given unique key should be dropped.
DropUnique(column ...string)
// DropUniqueByName Indicate that the given unique key should be dropped.
DropUniqueByName(name string)
// Enum Create a new enum column on the table.
Enum(column string, array []any) driver.ColumnDefinition
// Float Create a new float column on the table.
Float(column string, precision ...int) driver.ColumnDefinition
// Foreign Specify a foreign key for the table.
Foreign(column ...string) ForeignKeyDefinition
// FullText Specify a fulltext for the table.
FullText(column ...string) IndexDefinition
// GetAddedColumns Get the added columns.
GetAddedColumns() []driver.ColumnDefinition
// GetCommands Get the commands.
GetCommands() []*driver.Command
// GetTableName Get the table name with prefix.
GetTableName() string
// HasCommand Determine if the blueprint has a specific command.
HasCommand(command string) bool
// ID Create a new auto-incrementing big integer (8-byte) column on the table.
ID(column ...string) driver.ColumnDefinition
// Increments Create a new auto-incrementing integer (4-byte) column on the table.
Increments(column string) driver.ColumnDefinition
// Index Specify an index for the table.
Index(column ...string) IndexDefinition
// Integer Create a new integer (4-byte) column on the table.
Integer(column string) driver.ColumnDefinition
// IntegerIncrements Create a new auto-incrementing integer (4-byte) column on the table.
IntegerIncrements(column string) driver.ColumnDefinition
// Json Create a new json column on the table.
Json(column string) driver.ColumnDefinition
// Jsonb Create a new jsonb column on the table.
Jsonb(column string) driver.ColumnDefinition
// LongText Create a new long text column on the table.
LongText(column string) driver.ColumnDefinition
// MediumIncrements Create a new auto-incrementing medium integer (3-byte) column on the table.
MediumIncrements(column string) driver.ColumnDefinition
// MediumInteger Create a new medium integer (3-byte) column on the table.
MediumInteger(column string) driver.ColumnDefinition
// MediumText Create a new medium text column on the table.
MediumText(column string) driver.ColumnDefinition
// Morphs Create morph columns for polymorphic relationships.
Morphs(name string, indexName ...string)
// NullableMorphs Create nullable morph columns for polymorphic relationships.
NullableMorphs(name string, indexName ...string)
// NumericMorphs Create numeric morph columns for polymorphic relationships.
NumericMorphs(name string, indexName ...string)
// Primary Specify the primary key(s) for the table.
Primary(column ...string)
// Rename the table to a given name.
Rename(to string)
// RenameColumn Indicate that the given columns should be renamed.
RenameColumn(from, to string)
// RenameIndex Indicate that the given indexes should be renamed.
RenameIndex(from, to string)
// SetTable Set the table that the blueprint operates on.
SetTable(name string)
// SmallIncrements Create a new auto-incrementing small integer (2-byte) column on the table.
SmallIncrements(column string) driver.ColumnDefinition
// SmallInteger Create a new small integer (2-byte) column on the table.
SmallInteger(column string) driver.ColumnDefinition
// SoftDeletes Add a "deleted at" timestamp for the table.
SoftDeletes(column ...string) driver.ColumnDefinition
// SoftDeletesTz Add a "deleted at" timestampTz for the table.
SoftDeletesTz(column ...string) driver.ColumnDefinition
// String Create a new string column on the table.
String(column string, length ...int) driver.ColumnDefinition
// Text Create a new text column on the table.
Text(column string) driver.ColumnDefinition
// Time Create a new time column on the table.
Time(column string, precision ...int) driver.ColumnDefinition
// TimeTz Create a new time column (with time zone) on the table.
TimeTz(column string, precision ...int) driver.ColumnDefinition
// Timestamp Create a new time column on the table.
Timestamp(column string, precision ...int) driver.ColumnDefinition
// Timestamps Add nullable creation and update timestamps to the table.
Timestamps(precision ...int)
// TimestampsTz Add creation and update timestampTz columns to the table.
TimestampsTz(precision ...int)
// TimestampTz Create a new time column (with time zone) on the table.
TimestampTz(column string, precision ...int) driver.ColumnDefinition
// TinyIncrements Create a new auto-incrementing tiny integer (1-byte) column on the table.
TinyIncrements(column string) driver.ColumnDefinition
// TinyInteger Create a new tiny integer (1-byte) column on the table.
TinyInteger(column string) driver.ColumnDefinition
// TinyText Create a new tiny text column on the table.
TinyText(column string) driver.ColumnDefinition
// ToSql Get the raw SQL statements for the blueprint.
ToSql(grammar driver.Grammar) ([]string, error)
// Unique Specify a unique index for the table.
Unique(column ...string) IndexDefinition
// UnsignedBigInteger Create a new unsigned big integer (8-byte) column on the table.
UnsignedBigInteger(column string) driver.ColumnDefinition
// UnsignedInteger Create a new unsigned integer (4-byte) column on the table.
UnsignedInteger(column string) driver.ColumnDefinition
// UnsignedMediumInteger Create a new unsigned medium integer (3-byte) column on the table.
UnsignedMediumInteger(column string) driver.ColumnDefinition
// UnsignedSmallInteger Create a new unsigned small integer (2-byte) column on the table.
UnsignedSmallInteger(column string) driver.ColumnDefinition
// UnsignedTinyInteger Create a new unsigned tiny integer (1-byte) column on the table.
UnsignedTinyInteger(column string) driver.ColumnDefinition
// Uuid Create a new UUID column on the table.
Uuid(column string) driver.ColumnDefinition
// UuidMorphs Create UUID morph columns for polymorphic relationships.
UuidMorphs(name string, indexName ...string)
// Ulid Create a new ULID column on the table.
Ulid(column string, length ...int) driver.ColumnDefinition
// UlidMorphs Create ULID morph columns for polymorphic relationships.
UlidMorphs(name string, indexName ...string)
}
type Connection ¶
type Connection interface {
// Connection Get the connection for the migration.
Connection() string
}
type Extension ¶ added in v1.15.12
type Extension struct {
GoTypes []GoType
}
Extension represents an extension for the schema
type ForeignKeyDefinition ¶
type ForeignKeyDefinition interface {
CascadeOnDelete() ForeignKeyDefinition
CascadeOnUpdate() ForeignKeyDefinition
On(table string) ForeignKeyDefinition
Name(name string) ForeignKeyDefinition
NoActionOnDelete() ForeignKeyDefinition
NoActionOnUpdate() ForeignKeyDefinition
NullOnDelete() ForeignKeyDefinition
References(columns ...string) ForeignKeyDefinition
RestrictOnDelete() ForeignKeyDefinition
RestrictOnUpdate() ForeignKeyDefinition
}
type GoType ¶ added in v1.15.12
GoType represents a database column type to Go type mapping This is kept for backward compatibility
type IndexConfig ¶
type IndexDefinition ¶
type IndexDefinition interface {
Algorithm(algorithm string) IndexDefinition
Deferrable() IndexDefinition
InitiallyImmediate() IndexDefinition
Language(name string) IndexDefinition
Name(name string) IndexDefinition
}
type Schema ¶
type Schema interface {
// Connection Get the connection for the schema.
Connection(name string) Schema
// Create a new table on the schema.
Create(table string, callback func(table Blueprint)) error
// Drop a table from the schema.
Drop(table string) error
// DropAllTables Drop all tables from the schema.
DropAllTables() error
// DropAllTypes Drop all types from the schema.
DropAllTypes() error
// DropAllViews Drop all views from the schema.
DropAllViews() error
// DropColumns Drop columns from a table on the schema.
DropColumns(table string, columns []string) error
// DropIfExists Drop a table from the schema if exists.
DropIfExists(table string) error
// Extend the schema with given extend parameter.
Extend(extend Extension) Schema
// GetColumnListing Get the column listing for a given table.
GetColumnListing(table string) []string
// GetColumns Get the columns for a given table.
GetColumns(table string) ([]driver.Column, error)
// GetConnection Get the connection of the schema.
GetConnection() string
// GetForeignKeys Get the foreign keys for a given table.
GetForeignKeys(table string) ([]driver.ForeignKey, error)
// GetIndexListing Get the names of the indexes for a given table.
GetIndexListing(table string) []string
// GetIndexes Get the indexes for a given table.
GetIndexes(table string) ([]driver.Index, error)
// GetTableListing Get the table listing for the database.
GetTableListing() []string
// GetTables Get the tables that belong to the database.
GetTables() ([]driver.Table, error)
// GetTypes Get the types that belong to the database.
GetTypes() ([]driver.Type, error)
// GetViews Get the views that belong to the database.
GetViews() ([]driver.View, error)
// GoTypes returns the mapping of schema types to Go types.
GoTypes() []GoType
// HasColumn Determine if the given table has a given column.
HasColumn(table, column string) bool
// HasColumns Determine if the given table has given columns.
HasColumns(table string, columns []string) bool
// HasIndex Determine if the given table has a given index.
HasIndex(table, index string) bool
// HasTable Determine if the given table exists.
HasTable(name string) bool
// HasType Determine if the given type exists.
HasType(name string) bool
// HasView Determine if the given view exists.
HasView(name string) bool
// Migrations Get the migrations.
Migrations() []Migration
// Orm Get the orm instance.
Orm() orm.Orm
// Prune reclaims space or optimizes underlying storage.
Prune() error
// Register migrations.
Register([]Migration)
// Rename a table on the schema.
Rename(from, to string) error
// SetConnection Set the connection of the schema.
SetConnection(name string)
// Sql Execute a sql directly.
Sql(sql string) error
// Table Modify a table on the schema.
Table(table string, callback func(table Blueprint)) error
}
Click to show internal directories.
Click to hide internal directories.