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 ( // AirlinesColumns holds the columns for the "airlines" table. AirlinesColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "name", Type: field.TypeString}, {Name: "alias", Type: field.TypeString}, {Name: "country", Type: field.TypeString}, {Name: "active", Type: field.TypeBool}, } // AirlinesTable holds the schema information for the "airlines" table. AirlinesTable = &schema.Table{ Name: "airlines", Columns: AirlinesColumns, PrimaryKey: []*schema.Column{AirlinesColumns[0]}, } // AirportsColumns holds the columns for the "airports" table. AirportsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "name", Type: field.TypeString, Nullable: true}, {Name: "city", Type: field.TypeString, Nullable: true}, {Name: "country", Type: field.TypeString, Nullable: true}, {Name: "iata", Type: field.TypeString, Nullable: true}, {Name: "icao", Type: field.TypeString, Nullable: true}, {Name: "latitude", Type: field.TypeFloat64, Nullable: true}, {Name: "longitude", Type: field.TypeFloat64, Nullable: true}, {Name: "altitude", Type: field.TypeInt, Nullable: true}, {Name: "timezone", Type: field.TypeString, Nullable: true}, {Name: "dst", Type: field.TypeString, Nullable: true}, {Name: "timezone_name", Type: field.TypeString, Nullable: true}, {Name: "type", Type: field.TypeString, Nullable: true}, {Name: "source", Type: field.TypeString, Nullable: true}, } // AirportsTable holds the schema information for the "airports" table. AirportsTable = &schema.Table{ Name: "airports", Columns: AirportsColumns, PrimaryKey: []*schema.Column{AirportsColumns[0]}, } // PlanesColumns holds the columns for the "planes" table. PlanesColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "name", Type: field.TypeString}, {Name: "tail_number", Type: field.TypeString}, } // PlanesTable holds the schema information for the "planes" table. PlanesTable = &schema.Table{ Name: "planes", Columns: PlanesColumns, PrimaryKey: []*schema.Column{PlanesColumns[0]}, } // RoutesColumns holds the columns for the "routes" table. RoutesColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "airline_id", Type: field.TypeInt}, {Name: "source_airport_id", Type: field.TypeInt}, {Name: "destination_airport_id", Type: field.TypeInt}, {Name: "plane_id", Type: field.TypeInt}, {Name: "number_of_stops", Type: field.TypeInt}, } // RoutesTable holds the schema information for the "routes" table. RoutesTable = &schema.Table{ Name: "routes", Columns: RoutesColumns, PrimaryKey: []*schema.Column{RoutesColumns[0]}, } // Tables holds all the tables in the schema. Tables = []*schema.Table{ AirlinesTable, AirportsTable, PlanesTable, RoutesTable, } )
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.