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 // WithFixture sets the foreign-key renaming option to the migration when upgrading // ent from v0.1.0 (issue-#285). Defaults to true. WithFixture = schema.WithFixture )
View Source
var ( // CitiesColumns holds the columns for the "cities" table. CitiesColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "x", Type: field.TypeInt}, {Name: "y", Type: field.TypeInt}, {Name: "name", Type: field.TypeString, Default: "New city"}, {Name: "points", Type: field.TypeInt, Default: 3}, {Name: "wood_production", Type: field.TypeInt, Default: 300}, {Name: "stone_production", Type: field.TypeInt}, {Name: "iron_production", Type: field.TypeInt}, {Name: "food_production", Type: field.TypeInt}, {Name: "wood_stored", Type: field.TypeInt, Default: 300}, {Name: "stone_stored", Type: field.TypeInt}, {Name: "iron_stored", Type: field.TypeInt}, {Name: "food_stored", Type: field.TypeInt}, {Name: "wood_limit", Type: field.TypeInt, Default: 300}, {Name: "stone_limit", Type: field.TypeInt}, {Name: "iron_limit", Type: field.TypeInt}, {Name: "food_limit", Type: field.TypeInt}, {Name: "queue_time", Type: field.TypeTime}, {Name: "construction_speed", Type: field.TypeInt, Default: 1}, {Name: "user_cities", Type: field.TypeInt, Nullable: true}, } // CitiesTable holds the schema information for the "cities" table. CitiesTable = &schema.Table{ Name: "cities", Columns: CitiesColumns, PrimaryKey: []*schema.Column{CitiesColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "cities_users_cities", Columns: []*schema.Column{CitiesColumns[19]}, RefColumns: []*schema.Column{UsersColumns[0]}, OnDelete: schema.SetNull, }, }, Indexes: []*schema.Index{ { Name: "city_x_y", Unique: true, Columns: []*schema.Column{CitiesColumns[1], CitiesColumns[2]}, }, }, } // ConstructionsColumns holds the columns for the "constructions" table. ConstructionsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "x", Type: field.TypeInt}, {Name: "y", Type: field.TypeInt}, {Name: "raw_production", Type: field.TypeInt}, {Name: "type", Type: field.TypeInt}, {Name: "level", Type: field.TypeInt}, {Name: "modifier", Type: field.TypeFloat64, Default: 1}, {Name: "need_refresh", Type: field.TypeBool, Default: true}, {Name: "city_constructions", Type: field.TypeInt, Nullable: true}, } // ConstructionsTable holds the schema information for the "constructions" table. ConstructionsTable = &schema.Table{ Name: "constructions", Columns: ConstructionsColumns, PrimaryKey: []*schema.Column{ConstructionsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "constructions_cities_constructions", Columns: []*schema.Column{ConstructionsColumns[8]}, RefColumns: []*schema.Column{CitiesColumns[0]}, OnDelete: schema.SetNull, }, }, Indexes: []*schema.Index{ { Name: "construction_x_y_city_constructions", Unique: true, Columns: []*schema.Column{ConstructionsColumns[1], ConstructionsColumns[2], ConstructionsColumns[8]}, }, }, } // QueuesColumns holds the columns for the "queues" table. QueuesColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "completion", Type: field.TypeTime}, {Name: "action", Type: field.TypeInt}, {Name: "order", Type: field.TypeInt}, {Name: "city_queue", Type: field.TypeInt, Nullable: true}, {Name: "construction_queue", Type: field.TypeInt, Nullable: true}, } // QueuesTable holds the schema information for the "queues" table. QueuesTable = &schema.Table{ Name: "queues", Columns: QueuesColumns, PrimaryKey: []*schema.Column{QueuesColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "queues_cities_queue", Columns: []*schema.Column{QueuesColumns[4]}, RefColumns: []*schema.Column{CitiesColumns[0]}, OnDelete: schema.SetNull, }, { Symbol: "queues_constructions_queue", Columns: []*schema.Column{QueuesColumns[5]}, RefColumns: []*schema.Column{ConstructionsColumns[0]}, OnDelete: schema.SetNull, }, }, Indexes: []*schema.Index{ { Name: "queue_order_city_queue", Unique: true, Columns: []*schema.Column{QueuesColumns[3], QueuesColumns[4]}, }, }, } // UsersColumns holds the columns for the "users" table. UsersColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "name", Type: field.TypeString, Unique: true}, {Name: "email", Type: field.TypeString, Unique: true}, {Name: "password_hash", Type: field.TypeString}, {Name: "gold", Type: field.TypeInt}, {Name: "diamonds", Type: field.TypeInt}, {Name: "darkwood", Type: field.TypeInt}, {Name: "runestone", Type: field.TypeInt}, {Name: "veritium", Type: field.TypeInt}, {Name: "trueseed", Type: field.TypeInt}, {Name: "rank", Type: field.TypeInt}, {Name: "alliance_rank", Type: field.TypeInt}, } // UsersTable holds the schema information for the "users" table. UsersTable = &schema.Table{ Name: "users", Columns: UsersColumns, PrimaryKey: []*schema.Column{UsersColumns[0]}, ForeignKeys: []*schema.ForeignKey{}, } // Tables holds all the tables in the schema. Tables = []*schema.Table{ CitiesTable, ConstructionsTable, QueuesTable, UsersTable, } )
Functions ¶
This section is empty.
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.