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 false. WithFixture = schema.WithFixture // WithForeignKeys enables creating foreign-key in schema DDL. This defaults to true. WithForeignKeys = schema.WithForeignKeys )
View Source
var ( // AddressPlacesColumns holds the columns for the "address_places" table. AddressPlacesColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt32, Increment: true}, {Name: "number", Type: field.TypeInt32}, {Name: "orientation_number", Type: field.TypeInt32, Nullable: true}, {Name: "orientation_number_letter", Type: field.TypeString, Nullable: true}, {Name: "zip", Type: field.TypeInt32}, } // AddressPlacesTable holds the schema information for the "address_places" table. AddressPlacesTable = &schema.Table{ Name: "address_places", Columns: AddressPlacesColumns, PrimaryKey: []*schema.Column{AddressPlacesColumns[0]}, } // CitiesColumns holds the columns for the "cities" table. CitiesColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt32, Increment: true}, {Name: "name", Type: field.TypeString}, } // CitiesTable holds the schema information for the "cities" table. CitiesTable = &schema.Table{ Name: "cities", Columns: CitiesColumns, PrimaryKey: []*schema.Column{CitiesColumns[0]}, } // StreetsColumns holds the columns for the "streets" table. StreetsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt32, Increment: true}, {Name: "name", Type: field.TypeString}, } // StreetsTable holds the schema information for the "streets" table. StreetsTable = &schema.Table{ Name: "streets", Columns: StreetsColumns, PrimaryKey: []*schema.Column{StreetsColumns[0]}, } // AddressPlaceStreetsColumns holds the columns for the "address_place_streets" table. AddressPlaceStreetsColumns = []*schema.Column{ {Name: "address_place_id", Type: field.TypeInt32}, {Name: "street_id", Type: field.TypeInt32}, } // AddressPlaceStreetsTable holds the schema information for the "address_place_streets" table. AddressPlaceStreetsTable = &schema.Table{ Name: "address_place_streets", Columns: AddressPlaceStreetsColumns, PrimaryKey: []*schema.Column{AddressPlaceStreetsColumns[0], AddressPlaceStreetsColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "address_place_streets_address_place_id", Columns: []*schema.Column{AddressPlaceStreetsColumns[0]}, RefColumns: []*schema.Column{AddressPlacesColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "address_place_streets_street_id", Columns: []*schema.Column{AddressPlaceStreetsColumns[1]}, RefColumns: []*schema.Column{StreetsColumns[0]}, OnDelete: schema.Cascade, }, }, } // StreetCitiesColumns holds the columns for the "street_cities" table. StreetCitiesColumns = []*schema.Column{ {Name: "street_id", Type: field.TypeInt32}, {Name: "city_id", Type: field.TypeInt32}, } // StreetCitiesTable holds the schema information for the "street_cities" table. StreetCitiesTable = &schema.Table{ Name: "street_cities", Columns: StreetCitiesColumns, PrimaryKey: []*schema.Column{StreetCitiesColumns[0], StreetCitiesColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "street_cities_street_id", Columns: []*schema.Column{StreetCitiesColumns[0]}, RefColumns: []*schema.Column{StreetsColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "street_cities_city_id", Columns: []*schema.Column{StreetCitiesColumns[1]}, RefColumns: []*schema.Column{CitiesColumns[0]}, OnDelete: schema.Cascade, }, }, } // Tables holds all the tables in the schema. Tables = []*schema.Table{ AddressPlacesTable, CitiesTable, StreetsTable, AddressPlaceStreetsTable, StreetCitiesTable, } )
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.