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 ( // TableColumnsColumns holds the columns for the "table_columns" table. TableColumnsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "created_at", Type: field.TypeTime, Nullable: true}, {Name: "updated_at", Type: field.TypeTime, Nullable: true}, {Name: "nanoid", Type: field.TypeString, Unique: true, Nullable: true}, {Name: "name", Type: field.TypeString}, {Name: "description", Type: field.TypeString, Nullable: true}, {Name: "type", Type: field.TypeEnum, Enums: []string{"string", "number", "integer", "boolean", "array"}}, {Name: "fill_mode", Type: field.TypeEnum, Enums: []string{"ai", "pick"}}, {Name: "source", Type: field.TypeJSON, Nullable: true}, {Name: "context_length", Type: field.TypeInt, Default: 0}, {Name: "table_id", Type: field.TypeInt}, } // TableColumnsTable holds the schema information for the "table_columns" table. TableColumnsTable = &schema.Table{ Name: "table_columns", Columns: TableColumnsColumns, PrimaryKey: []*schema.Column{TableColumnsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "table_columns_table_meta_columns", Columns: []*schema.Column{TableColumnsColumns[10]}, RefColumns: []*schema.Column{TableMetaColumns[0]}, OnDelete: schema.Cascade, }, }, Indexes: []*schema.Index{ { Name: "tablecolumn_name_table_id", Unique: true, Columns: []*schema.Column{TableColumnsColumns[4], TableColumnsColumns[10]}, }, }, } // TableMetaColumns holds the columns for the "table_meta" table. TableMetaColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "created_at", Type: field.TypeTime, Nullable: true}, {Name: "updated_at", Type: field.TypeTime, Nullable: true}, {Name: "nanoid", Type: field.TypeString, Unique: true, Nullable: true}, {Name: "name", Type: field.TypeString, Unique: true}, {Name: "description", Type: field.TypeString, Default: ""}, {Name: "model", Type: field.TypeString, Default: ""}, } // TableMetaTable holds the schema information for the "table_meta" table. TableMetaTable = &schema.Table{ Name: "table_meta", Columns: TableMetaColumns, PrimaryKey: []*schema.Column{TableMetaColumns[0]}, } // TableRowsColumns holds the columns for the "table_rows" table. TableRowsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "created_at", Type: field.TypeTime, Nullable: true}, {Name: "updated_at", Type: field.TypeTime, Nullable: true}, {Name: "nanoid", Type: field.TypeString, Unique: true, Nullable: true}, {Name: "cells", Type: field.TypeJSON, Nullable: true}, {Name: "table_meta_rows", Type: field.TypeInt}, } // TableRowsTable holds the schema information for the "table_rows" table. TableRowsTable = &schema.Table{ Name: "table_rows", Columns: TableRowsColumns, PrimaryKey: []*schema.Column{TableRowsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "table_rows_table_meta_rows", Columns: []*schema.Column{TableRowsColumns[5]}, RefColumns: []*schema.Column{TableMetaColumns[0]}, OnDelete: schema.Cascade, }, }, } // Tables holds all the tables in the schema. Tables = []*schema.Table{ TableColumnsTable, TableMetaTable, TableRowsTable, } )
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.