Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // WithGlobalUniqueID sets the universal ids options to the migration. // If this option is enabled, ent migration will allocate a 1<<32 range // for the ids of each entity (table). // Note that this option cannot be applied on tables that already exist. WithGlobalUniqueID = schema.WithGlobalUniqueID // WithDropColumn sets the drop column option to the migration. // If this option is enabled, ent migration will drop old columns // that were used for both fields and edges. This defaults to false. WithDropColumn = schema.WithDropColumn // WithDropIndex sets the drop index option to the migration. // If this option is enabled, ent migration will drop old indexes // that were defined in the schema. This defaults to false. // Note that unique constraints are defined using `UNIQUE INDEX`, // and therefore, it's recommended to enable this option to get more // flexibility in the schema changes. WithDropIndex = schema.WithDropIndex // WithForeignKeys enables creating foreign-key in schema DDL. This defaults to true. WithForeignKeys = schema.WithForeignKeys )
View Source
var ( // LeafColumns holds the columns for the "leaf" table. LeafColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt64, Increment: true, Comment: "primary key"}, {Name: "biz_tag", Type: field.TypeString, Unique: true, Comment: "for different biz"}, {Name: "max_id", Type: field.TypeInt64, Comment: "current max id", Default: 1000}, {Name: "step", Type: field.TypeInt64, Comment: "nums per batch", Default: 1000}, {Name: "desc", Type: field.TypeString, Size: 255}, {Name: "version", Type: field.TypeInt32, Comment: "version control", Default: 0}, {Name: "created_at", Type: field.TypeInt64}, {Name: "updated_at", Type: field.TypeInt64}, } // LeafTable holds the schema information for the "leaf" table. LeafTable = &schema.Table{ Name: "leaf", Columns: LeafColumns, PrimaryKey: []*schema.Column{LeafColumns[0]}, } // ShortURLColumns holds the columns for the "short_url" table. ShortURLColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt64, Increment: true, Comment: "primary key"}, {Name: "biz_id", Type: field.TypeInt64, Comment: "refer to leaf id"}, {Name: "origin", Type: field.TypeString, Comment: "current max id"}, {Name: "short", Type: field.TypeInt64, Unique: true, Comment: "short url"}, {Name: "visit", Type: field.TypeInt64, Default: 0}, {Name: "created_at", Type: field.TypeInt64}, {Name: "updated_at", Type: field.TypeInt64}, {Name: "expired_at", Type: field.TypeInt64, Default: 0}, } // ShortURLTable holds the schema information for the "short_url" table. ShortURLTable = &schema.Table{ Name: "short_url", Columns: ShortURLColumns, PrimaryKey: []*schema.Column{ShortURLColumns[0]}, Indexes: []*schema.Index{ { Name: "tshorturl_short_biz_id", Unique: true, Columns: []*schema.Column{ShortURLColumns[3], ShortURLColumns[1]}, }, }, } // Tables holds all the tables in the schema. Tables = []*schema.Table{ LeafTable, ShortURLTable, } )
Functions ¶
Types ¶
type Schema ¶
type Schema struct {
// contains filtered or unexported fields
}
Schema is the API for creating, migrating and dropping a schema.
Click to show internal directories.
Click to hide internal directories.