Documentation ¶
Index ¶
- Variables
- func Create(ctx context.Context, s *Schema, tables []*schema.Table, ...) error
- func Diff(ctx context.Context, url string, opts ...schema.MigrateOption) error
- func NamedDiff(ctx context.Context, url, name string, opts ...schema.MigrateOption) error
- type Schema
- func (s *Schema) Create(ctx context.Context, opts ...schema.MigrateOption) error
- func (s *Schema) Diff(ctx context.Context, opts ...schema.MigrateOption) error
- func (s *Schema) NamedDiff(ctx context.Context, name string, opts ...schema.MigrateOption) error
- func (s *Schema) WriteTo(ctx context.Context, w io.Writer, opts ...schema.MigrateOption) error
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 ( // ActDecisionDefColumns holds the columns for the "act_decision_def" table. ActDecisionDefColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, SchemaType: map[string]string{"mysql": "bigint"}}, {Name: "created_by", Type: field.TypeInt}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_by", Type: field.TypeInt, Nullable: true}, {Name: "updated_at", Type: field.TypeTime, Nullable: true}, {Name: "tenant_id", Type: field.TypeInt, SchemaType: map[string]string{"mysql": "int"}}, {Name: "deployment_id", Type: field.TypeInt}, {Name: "app_id", Type: field.TypeInt}, {Name: "category", Type: field.TypeString, Nullable: true}, {Name: "name", Type: field.TypeString, Nullable: true}, {Name: "key", Type: field.TypeString}, {Name: "req_def_key", Type: field.TypeString}, {Name: "version", Type: field.TypeInt32}, {Name: "revision", Type: field.TypeInt32, Nullable: true}, {Name: "version_tag", Type: field.TypeString, Nullable: true}, {Name: "req_def_id", Type: field.TypeInt, SchemaType: map[string]string{"mysql": "bigint"}}, } // ActDecisionDefTable holds the schema information for the "act_decision_def" table. ActDecisionDefTable = &schema.Table{ Name: "act_decision_def", Columns: ActDecisionDefColumns, PrimaryKey: []*schema.Column{ActDecisionDefColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "act_decision_def_act_decision_req_def_decision_defs", Columns: []*schema.Column{ActDecisionDefColumns[15]}, RefColumns: []*schema.Column{ActDecisionReqDefColumns[0]}, OnDelete: schema.NoAction, }, }, } // ActDecisionReqDefColumns holds the columns for the "act_decision_req_def" table. ActDecisionReqDefColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, SchemaType: map[string]string{"mysql": "bigint"}}, {Name: "created_by", Type: field.TypeInt}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_by", Type: field.TypeInt, Nullable: true}, {Name: "updated_at", Type: field.TypeTime, Nullable: true}, {Name: "tenant_id", Type: field.TypeInt, SchemaType: map[string]string{"mysql": "int"}}, {Name: "app_id", Type: field.TypeInt}, {Name: "category", Type: field.TypeString, Nullable: true}, {Name: "name", Type: field.TypeString, Nullable: true}, {Name: "key", Type: field.TypeString}, {Name: "version", Type: field.TypeInt32}, {Name: "revision", Type: field.TypeInt32, Nullable: true}, {Name: "resource_key", Type: field.TypeString, Nullable: true}, {Name: "resource_id", Type: field.TypeInt, Nullable: true}, {Name: "deployment_id", Type: field.TypeInt, SchemaType: map[string]string{"mysql": "bigint"}}, } // ActDecisionReqDefTable holds the schema information for the "act_decision_req_def" table. ActDecisionReqDefTable = &schema.Table{ Name: "act_decision_req_def", Columns: ActDecisionReqDefColumns, PrimaryKey: []*schema.Column{ActDecisionReqDefColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "act_decision_req_def_act_deployment_decision_reqs", Columns: []*schema.Column{ActDecisionReqDefColumns[14]}, RefColumns: []*schema.Column{ActDeploymentColumns[0]}, OnDelete: schema.NoAction, }, }, } // ActDeploymentColumns holds the columns for the "act_deployment" table. ActDeploymentColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, SchemaType: map[string]string{"mysql": "bigint"}}, {Name: "created_by", Type: field.TypeInt}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_by", Type: field.TypeInt, Nullable: true}, {Name: "updated_at", Type: field.TypeTime, Nullable: true}, {Name: "tenant_id", Type: field.TypeInt, SchemaType: map[string]string{"mysql": "int"}}, {Name: "app_id", Type: field.TypeInt}, {Name: "name", Type: field.TypeString, Nullable: true}, {Name: "source", Type: field.TypeString, Nullable: true}, {Name: "deploy_time", Type: field.TypeTime}, } // ActDeploymentTable holds the schema information for the "act_deployment" table. ActDeploymentTable = &schema.Table{ Name: "act_deployment", Columns: ActDeploymentColumns, PrimaryKey: []*schema.Column{ActDeploymentColumns[0]}, } // ActIdentityLinkColumns holds the columns for the "act_identity_link" table. ActIdentityLinkColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, SchemaType: map[string]string{"mysql": "bigint"}}, {Name: "tenant_id", Type: field.TypeInt, SchemaType: map[string]string{"mysql": "int"}}, {Name: "proc_def_id", Type: field.TypeInt}, {Name: "group_id", Type: field.TypeInt, Nullable: true}, {Name: "user_id", Type: field.TypeInt, Nullable: true}, {Name: "assigner_id", Type: field.TypeInt, Nullable: true}, {Name: "link_type", Type: field.TypeEnum, Enums: []string{"assignee", "candidate", "participant", "manager", "notifier"}}, {Name: "operation_type", Type: field.TypeEnum, Enums: []string{"init", "claim", "delete", "pass", "reject"}}, {Name: "comments", Type: field.TypeString, Nullable: true}, {Name: "task_id", Type: field.TypeInt, SchemaType: map[string]string{"mysql": "bigint"}}, } // ActIdentityLinkTable holds the schema information for the "act_identity_link" table. ActIdentityLinkTable = &schema.Table{ Name: "act_identity_link", Columns: ActIdentityLinkColumns, PrimaryKey: []*schema.Column{ActIdentityLinkColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "act_identity_link_act_task_task_identities", Columns: []*schema.Column{ActIdentityLinkColumns[9]}, RefColumns: []*schema.Column{ActTaskColumns[0]}, OnDelete: schema.NoAction, }, }, } // OrgAppColumns holds the columns for the "org_app" table. OrgAppColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true, SchemaType: map[string]string{"mysql": "int"}}, {Name: "org_id", Type: field.TypeInt}, {Name: "app_id", Type: field.TypeInt}, } // OrgAppTable holds the schema information for the "org_app" table. OrgAppTable = &schema.Table{ Name: "org_app", Columns: OrgAppColumns, PrimaryKey: []*schema.Column{OrgAppColumns[0]}, } // OrgRoleColumns holds the columns for the "org_role" table. OrgRoleColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true, SchemaType: map[string]string{"mysql": "int"}}, {Name: "org_id", Type: field.TypeInt, Nullable: true}, {Name: "kind", Type: field.TypeEnum, Enums: []string{"group", "role"}}, {Name: "name", Type: field.TypeString}, } // OrgRoleTable holds the schema information for the "org_role" table. OrgRoleTable = &schema.Table{ Name: "org_role", Columns: OrgRoleColumns, PrimaryKey: []*schema.Column{OrgRoleColumns[0]}, } // OrgRoleUserColumns holds the columns for the "org_role_user" table. OrgRoleUserColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true, SchemaType: map[string]string{"mysql": "int"}}, {Name: "user_id", Type: field.TypeInt}, {Name: "org_id", Type: field.TypeInt}, {Name: "org_role_id", Type: field.TypeInt, SchemaType: map[string]string{"mysql": "int"}}, {Name: "org_user_id", Type: field.TypeInt, SchemaType: map[string]string{"mysql": "int"}}, } // OrgRoleUserTable holds the schema information for the "org_role_user" table. OrgRoleUserTable = &schema.Table{ Name: "org_role_user", Columns: OrgRoleUserColumns, PrimaryKey: []*schema.Column{OrgRoleUserColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "org_role_user_org_role_org_role", Columns: []*schema.Column{OrgRoleUserColumns[3]}, RefColumns: []*schema.Column{OrgRoleColumns[0]}, OnDelete: schema.NoAction, }, { Symbol: "org_role_user_org_user_org_user", Columns: []*schema.Column{OrgRoleUserColumns[4]}, RefColumns: []*schema.Column{OrgUserColumns[0]}, OnDelete: schema.NoAction, }, }, Indexes: []*schema.Index{ { Name: "orgroleuser_org_role_id_org_user_id", Unique: true, Columns: []*schema.Column{OrgRoleUserColumns[3], OrgRoleUserColumns[4]}, }, }, } // OrgUserColumns holds the columns for the "org_user" table. OrgUserColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true, SchemaType: map[string]string{"mysql": "int"}}, {Name: "org_id", Type: field.TypeInt}, {Name: "user_id", Type: field.TypeInt}, {Name: "joined_at", Type: field.TypeTime}, {Name: "display_name", Type: field.TypeString}, } // OrgUserTable holds the schema information for the "org_user" table. OrgUserTable = &schema.Table{ Name: "org_user", Columns: OrgUserColumns, PrimaryKey: []*schema.Column{OrgUserColumns[0]}, } // ActProcDefColumns holds the columns for the "act_proc_def" table. ActProcDefColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, SchemaType: map[string]string{"mysql": "bigint"}}, {Name: "created_by", Type: field.TypeInt}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_by", Type: field.TypeInt, Nullable: true}, {Name: "updated_at", Type: field.TypeTime, Nullable: true}, {Name: "tenant_id", Type: field.TypeInt, SchemaType: map[string]string{"mysql": "int"}}, {Name: "app_id", Type: field.TypeInt}, {Name: "category", Type: field.TypeString, Nullable: true}, {Name: "name", Type: field.TypeString, Nullable: true}, {Name: "key", Type: field.TypeString}, {Name: "version", Type: field.TypeInt32, Nullable: true}, {Name: "revision", Type: field.TypeInt32, Nullable: true}, {Name: "version_tag", Type: field.TypeString, Nullable: true}, {Name: "resource_key", Type: field.TypeString, Nullable: true}, {Name: "resource_id", Type: field.TypeInt, Nullable: true}, {Name: "status", Type: field.TypeEnum, Enums: []string{"active", "inactive", "processing"}, Default: "active"}, {Name: "deployment_id", Type: field.TypeInt, SchemaType: map[string]string{"mysql": "bigint"}}, } // ActProcDefTable holds the schema information for the "act_proc_def" table. ActProcDefTable = &schema.Table{ Name: "act_proc_def", Columns: ActProcDefColumns, PrimaryKey: []*schema.Column{ActProcDefColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "act_proc_def_act_deployment_proc_defs", Columns: []*schema.Column{ActProcDefColumns[16]}, RefColumns: []*schema.Column{ActDeploymentColumns[0]}, OnDelete: schema.NoAction, }, }, } // ActProcInstColumns holds the columns for the "act_proc_inst" table. ActProcInstColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, SchemaType: map[string]string{"mysql": "bigint"}}, {Name: "created_by", Type: field.TypeInt}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_by", Type: field.TypeInt, Nullable: true}, {Name: "updated_at", Type: field.TypeTime, Nullable: true}, {Name: "tenant_id", Type: field.TypeInt, SchemaType: map[string]string{"mysql": "int"}}, {Name: "app_id", Type: field.TypeInt}, {Name: "business_key", Type: field.TypeString}, {Name: "start_time", Type: field.TypeTime}, {Name: "end_time", Type: field.TypeTime, Nullable: true}, {Name: "duration", Type: field.TypeInt, Nullable: true}, {Name: "start_user_id", Type: field.TypeInt}, {Name: "supper_instance_id", Type: field.TypeInt, Nullable: true}, {Name: "root_instance_id", Type: field.TypeInt, Nullable: true}, {Name: "deleted_time", Type: field.TypeTime, Nullable: true}, {Name: "deleted_reason", Type: field.TypeString, Nullable: true}, {Name: "status", Type: field.TypeEnum, Enums: []string{"ready", "active", "completed", "failed", "terminated", "suspended", "deleted"}}, {Name: "proc_def_id", Type: field.TypeInt, SchemaType: map[string]string{"mysql": "bigint"}}, } // ActProcInstTable holds the schema information for the "act_proc_inst" table. ActProcInstTable = &schema.Table{ Name: "act_proc_inst", Columns: ActProcInstColumns, PrimaryKey: []*schema.Column{ActProcInstColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "act_proc_inst_act_proc_def_proc_instances", Columns: []*schema.Column{ActProcInstColumns[17]}, RefColumns: []*schema.Column{ActProcDefColumns[0]}, OnDelete: schema.NoAction, }, }, } // ActTaskColumns holds the columns for the "act_task" table. ActTaskColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, SchemaType: map[string]string{"mysql": "bigint"}}, {Name: "tenant_id", Type: field.TypeInt, SchemaType: map[string]string{"mysql": "int"}}, {Name: "proc_def_id", Type: field.TypeInt}, {Name: "execution_id", Type: field.TypeString}, {Name: "run_id", Type: field.TypeString, Nullable: true}, {Name: "task_def_key", Type: field.TypeString}, {Name: "parent_id", Type: field.TypeInt, Nullable: true, Default: 0}, {Name: "comments", Type: field.TypeString, Nullable: true}, {Name: "assignee", Type: field.TypeString, Nullable: true}, {Name: "member_count", Type: field.TypeInt32}, {Name: "unfinished_count", Type: field.TypeInt32}, {Name: "agree_count", Type: field.TypeInt32, Default: 0}, {Name: "kind", Type: field.TypeEnum, Enums: []string{"AND", "OR"}, Default: "OR"}, {Name: "sequential", Type: field.TypeBool, Default: false}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "status", Type: field.TypeEnum, Enums: []string{"created", "running", "finished", "canceled"}, Default: "created"}, {Name: "proc_inst_id", Type: field.TypeInt, SchemaType: map[string]string{"mysql": "bigint"}}, } // ActTaskTable holds the schema information for the "act_task" table. ActTaskTable = &schema.Table{ Name: "act_task", Columns: ActTaskColumns, PrimaryKey: []*schema.Column{ActTaskColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "act_task_act_proc_inst_tasks", Columns: []*schema.Column{ActTaskColumns[17]}, RefColumns: []*schema.Column{ActProcInstColumns[0]}, OnDelete: schema.NoAction, }, }, } // Tables holds all the tables in the schema. Tables = []*schema.Table{ ActDecisionDefTable, ActDecisionReqDefTable, ActDeploymentTable, ActIdentityLinkTable, OrgAppTable, OrgRoleTable, OrgRoleUserTable, OrgUserTable, ActProcDefTable, ActProcInstTable, ActTaskTable, } )
Functions ¶
func Create ¶
func Create(ctx context.Context, s *Schema, tables []*schema.Table, opts ...schema.MigrateOption) error
Create creates all table resources using the given schema driver.
Types ¶
type Schema ¶
type Schema struct {
// contains filtered or unexported fields
}
Schema is the API for creating, migrating and dropping a schema.
func (*Schema) Diff ¶
Diff creates a migration file containing the statements to resolve the diff between the Ent schema and the connected database.
func (*Schema) NamedDiff ¶
NamedDiff creates a named migration file containing the statements to resolve the diff between the Ent schema and the connected database.
Click to show internal directories.
Click to hide internal directories.