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 ( // SchemaAsColumns holds the columns for the "schema_as" table. SchemaAsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "int64", Type: field.TypeInt64}, {Name: "string_bindto_foobar", Type: field.TypeString}, {Name: "string_optional_nullable", Type: field.TypeString, Nullable: true}, {Name: "optional_nullable_bool", Type: field.TypeBool, Nullable: true}, {Name: "jsontype_strings", Type: field.TypeJSON}, {Name: "jsontype_strings_optional", Type: field.TypeJSON, Nullable: true}, {Name: "jsontype_ints", Type: field.TypeJSON}, {Name: "jsontype_ints_optional", Type: field.TypeJSON, Nullable: true}, {Name: "required_enum", Type: field.TypeEnum, Enums: []string{"a", "b"}}, {Name: "optional_nullable_enum", Type: field.TypeEnum, Nullable: true, Enums: []string{"c", "d"}}, {Name: "bytes", Type: field.TypeBytes}, {Name: "schemaa_edge_schemab_unique_required", Type: field.TypeInt64}, {Name: "schemaa_edge_schemab_unique_required_bindto_bs", Type: field.TypeInt64}, {Name: "schemaa_edge_schemab_unique_optional", Type: field.TypeInt64, Nullable: true}, } // SchemaAsTable holds the schema information for the "schema_as" table. SchemaAsTable = &schema.Table{ Name: "schema_as", Columns: SchemaAsColumns, PrimaryKey: []*schema.Column{SchemaAsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "schema_as_schema_bs_edge_schemab_unique_required", Columns: []*schema.Column{SchemaAsColumns[12]}, RefColumns: []*schema.Column{SchemaBsColumns[0]}, OnDelete: schema.NoAction, }, { Symbol: "schema_as_schema_bs_edge_schemab_unique_required_bindto_bs", Columns: []*schema.Column{SchemaAsColumns[13]}, RefColumns: []*schema.Column{SchemaBsColumns[0]}, OnDelete: schema.NoAction, }, { Symbol: "schema_as_schema_bs_edge_schemab_unique_optional", Columns: []*schema.Column{SchemaAsColumns[14]}, RefColumns: []*schema.Column{SchemaBsColumns[0]}, OnDelete: schema.SetNull, }, }, } // SchemaBsColumns holds the columns for the "schema_bs" table. SchemaBsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt64, Increment: true}, {Name: "schemaa_edge_schemab", Type: field.TypeInt, Nullable: true}, } // SchemaBsTable holds the schema information for the "schema_bs" table. SchemaBsTable = &schema.Table{ Name: "schema_bs", Columns: SchemaBsColumns, PrimaryKey: []*schema.Column{SchemaBsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "schema_bs_schema_as_edge_schemab", Columns: []*schema.Column{SchemaBsColumns[1]}, RefColumns: []*schema.Column{SchemaAsColumns[0]}, OnDelete: schema.SetNull, }, }, } // SchemaaEdgeSchemaaRecursiveColumns holds the columns for the "schemaa_edge_schemaa_recursive" table. SchemaaEdgeSchemaaRecursiveColumns = []*schema.Column{ {Name: "schemaa_id", Type: field.TypeInt}, {Name: "edge_schemaa_recursive_id", Type: field.TypeInt}, } // SchemaaEdgeSchemaaRecursiveTable holds the schema information for the "schemaa_edge_schemaa_recursive" table. SchemaaEdgeSchemaaRecursiveTable = &schema.Table{ Name: "schemaa_edge_schemaa_recursive", Columns: SchemaaEdgeSchemaaRecursiveColumns, PrimaryKey: []*schema.Column{SchemaaEdgeSchemaaRecursiveColumns[0], SchemaaEdgeSchemaaRecursiveColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "schemaa_edge_schemaa_recursive_schemaa_id", Columns: []*schema.Column{SchemaaEdgeSchemaaRecursiveColumns[0]}, RefColumns: []*schema.Column{SchemaAsColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "schemaa_edge_schemaa_recursive_edge_schemaa_recursive_id", Columns: []*schema.Column{SchemaaEdgeSchemaaRecursiveColumns[1]}, RefColumns: []*schema.Column{SchemaAsColumns[0]}, OnDelete: schema.Cascade, }, }, } // Tables holds all the tables in the schema. Tables = []*schema.Table{ SchemaAsTable, SchemaBsTable, SchemaaEdgeSchemaaRecursiveTable, } )
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.