Documentation
¶
Index ¶
- type BaseSchema
- type Schema
- type Table
- func (t *Table) After(_ string) *Table
- func (t *Table) BigIncrements(name string) *Table
- func (t *Table) BigInteger(name string) *Table
- func (t *Table) Binary(name string) *Table
- func (t *Table) Boolean(name string) *Table
- func (t *Table) Check(_ string) *Table
- func (t *Table) Comment(text string) *Table
- func (t *Table) CompositeIndex(cols []string) *Table
- func (t *Table) Date(name string) *Table
- func (t *Table) DateTime(name string) *Table
- func (t *Table) Decimal(name string, precision, scale int) *Table
- func (t *Table) Default(val string) *Table
- func (t *Table) Enum(name string, _ []string) *Table
- func (t *Table) First() *Table
- func (t *Table) Float(name string, precision, scale int) *Table
- func (t *Table) ForeignId(column, references string) *Table
- func (t *Table) Generated(_ string, _ string) *Table
- func (t *Table) ID() *Table
- func (t *Table) Increments(name string) *Table
- func (t *Table) Index(column string) *Table
- func (t *Table) Integer(name string) *Table
- func (t *Table) JSON(name string) *Table
- func (t *Table) JSONB(name string) *Table
- func (t *Table) LegacyTimestamp(name string) *Table
- func (t *Table) LongText(name string) *Table
- func (t *Table) NotNull() *Table
- func (t *Table) Nullable() *Table
- func (t *Table) Primary() *Table
- func (t *Table) SmallInteger(name string) *Table
- func (t *Table) SoftDeletes() *Table
- func (t *Table) String(name string, size int) *Table
- func (t *Table) Text(name string) *Table
- func (t *Table) Time(name string) *Table
- func (t *Table) Timestamp(name string) *Table
- func (t *Table) Timestamps() *Table
- func (t *Table) UUID(name string) *Table
- func (t *Table) UUIDPrimary() *Table
- func (t *Table) Unique() *Table
- func (t *Table) UniqueComposite(cols []string) *Table
- func (t *Table) Unsigned() *Table
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseSchema ¶
type BaseSchema struct{}
BaseSchema is the base for AdonisJS Lucid-style migrations. Embed it in your migration struct and implement TableName, Up, and Down.
type CreateUsers struct {
schema.BaseSchema
}
func (m *CreateUsers) TableName() string { return "users" }
func (m *CreateUsers) Up(db *lucid.DB) error {
return schema.New(db).CreateTable("users", func(t *schema.Table) {
t.Increments("id")
t.Timestamps()
})
}
func (m *CreateUsers) Down(db *lucid.DB) error {
return schema.New(db).DropTable("users")
}
type Schema ¶
type Schema struct {
// contains filtered or unexported fields
}
Schema holds the database connection for migrations.
func (*Schema) AlterTable ¶
AlterTable alters an existing table (add column). Use in migrations for schema changes.
func (*Schema) CreateTable ¶
CreateTable creates a table with the given name. The callback receives a Table builder to define columns.
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table builds column definitions for CreateTable.
func (*Table) BigIncrements ¶
BigIncrements adds a bigint auto-increment primary key.
func (*Table) BigInteger ¶
BigInteger adds a bigint column.
func (*Table) CompositeIndex ¶
CompositeIndex registers a non-unique index for multiple columns.
func (*Table) Enum ¶
Enum adds an enum-like column. Backed by VARCHAR; values are not enforced at DB level.
func (*Table) Increments ¶
Increments adds an auto-increment primary key (id).
func (*Table) Index ¶
Index registers a non-unique index for the given column. If column is empty, the last defined column is used.
func (*Table) LegacyTimestamp ¶
LegacyTimestamp adds a legacy TIMESTAMP column. Use this only when you explicitly need the database's TIMESTAMP semantics.
func (*Table) SmallInteger ¶
SmallInteger adds a smallint column.
func (*Table) SoftDeletes ¶
SoftDeletes adds deleted_at column (nullable) for GORM soft delete.
func (*Table) Timestamps ¶
Timestamps adds created_at and updated_at columns.
func (*Table) UUIDPrimary ¶
UUIDPrimary adds a UUID primary key named "id".
func (*Table) UniqueComposite ¶
UniqueComposite registers a unique index for multiple columns.