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 ( // ComponentsColumns holds the columns for the "components" table. ComponentsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "sn", Type: field.TypeString, Unique: true, Size: 50}, {Name: "name", Type: field.TypeString, Size: 20}, {Name: "desc", Type: field.TypeString, Size: 20}, {Name: "center", Type: field.TypeBool, Default: true}, {Name: "version", Type: field.TypeString, Default: "2.2.4"}, {Name: "raw", Type: field.TypeString, Size: 2147483647}, {Name: "raw_length", Type: field.TypeUint64, Default: 0}, {Name: "score", Type: field.TypeInt, Default: 0}, {Name: "verify_time", Type: field.TypeTime, Nullable: true}, {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, {Name: "owner_id", Type: field.TypeInt, Nullable: true}, } // ComponentsTable holds the schema information for the "components" table. ComponentsTable = &schema.Table{ Name: "components", Columns: ComponentsColumns, PrimaryKey: []*schema.Column{ComponentsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "components_user_Components", Columns: []*schema.Column{ComponentsColumns[12]}, RefColumns: []*schema.Column{UserColumns[0]}, OnDelete: schema.SetNull, }, }, Indexes: []*schema.Index{ { Name: "component_name", Unique: false, Columns: []*schema.Column{ComponentsColumns[2]}, }, { Name: "component_version", Unique: false, Columns: []*schema.Column{ComponentsColumns[5]}, }, { Name: "component_create_time", Unique: false, Columns: []*schema.Column{ComponentsColumns[10]}, }, { Name: "component_update_time", Unique: false, Columns: []*schema.Column{ComponentsColumns[11]}, }, { Name: "component_sn", Unique: true, Columns: []*schema.Column{ComponentsColumns[1]}, }, }, } // ComponentTagColumns holds the columns for the "component_tag" table. ComponentTagColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "en", Type: field.TypeString, Unique: true, Size: 20}, {Name: "zh", Type: field.TypeString, Unique: true, Size: 20}, {Name: "create_time", Type: field.TypeTime}, } // ComponentTagTable holds the schema information for the "component_tag" table. ComponentTagTable = &schema.Table{ Name: "component_tag", Columns: ComponentTagColumns, PrimaryKey: []*schema.Column{ComponentTagColumns[0]}, Indexes: []*schema.Index{ { Name: "componenttag_en", Unique: false, Columns: []*schema.Column{ComponentTagColumns[1]}, }, { Name: "componenttag_zh", Unique: false, Columns: []*schema.Column{ComponentTagColumns[2]}, }, { Name: "componenttag_create_time", Unique: false, Columns: []*schema.Column{ComponentTagColumns[3]}, }, }, } // GroupColumns holds the columns for the "group" table. GroupColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "sn", Type: field.TypeString, Unique: true, Size: 50}, {Name: "groupname", Type: field.TypeString, Unique: true, Size: 20}, {Name: "avatar_url", Type: field.TypeString, Nullable: true, Size: 200}, {Name: "address", Type: field.TypeString, Nullable: true}, {Name: "homepage", Type: field.TypeString, Nullable: true, Size: 100}, {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, {Name: "delete_time", Type: field.TypeTime, Nullable: true}, } // GroupTable holds the schema information for the "group" table. GroupTable = &schema.Table{ Name: "group", Columns: GroupColumns, PrimaryKey: []*schema.Column{GroupColumns[0]}, Indexes: []*schema.Index{ { Name: "group_create_time", Unique: false, Columns: []*schema.Column{GroupColumns[6]}, }, { Name: "group_update_time", Unique: false, Columns: []*schema.Column{GroupColumns[7]}, }, { Name: "group_sn", Unique: true, Columns: []*schema.Column{GroupColumns[1]}, }, { Name: "group_groupname", Unique: true, Columns: []*schema.Column{GroupColumns[2]}, }, }, } // ModelVersionColumns holds the columns for the "model_version" table. ModelVersionColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "version", Type: field.TypeString, Unique: true, Size: 100}, {Name: "update_time", Type: field.TypeTime}, } // ModelVersionTable holds the schema information for the "model_version" table. ModelVersionTable = &schema.Table{ Name: "model_version", Columns: ModelVersionColumns, PrimaryKey: []*schema.Column{ModelVersionColumns[0]}, } // SystemSettingColumns holds the columns for the "system_setting" table. SystemSettingColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "space", Type: field.TypeEnum, Nullable: true, Enums: []string{"general", "www"}}, {Name: "key", Type: field.TypeString, Unique: true, Size: 100}, {Name: "value", Type: field.TypeString, Nullable: true, Size: 2147483647, Default: ""}, {Name: "typeof", Type: field.TypeString, Size: 10, Default: "string"}, {Name: "update_time", Type: field.TypeTime}, } // SystemSettingTable holds the schema information for the "system_setting" table. SystemSettingTable = &schema.Table{ Name: "system_setting", Columns: SystemSettingColumns, PrimaryKey: []*schema.Column{SystemSettingColumns[0]}, Indexes: []*schema.Index{ { Name: "systemsetting_space", Unique: false, Columns: []*schema.Column{SystemSettingColumns[1]}, }, }, } // UserColumns holds the columns for the "user" table. UserColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "sn", Type: field.TypeString, Unique: true, Size: 50}, {Name: "nickname", Type: field.TypeString, Nullable: true, Size: 20}, {Name: "username", Type: field.TypeString, Unique: true, Size: 20}, {Name: "gender", Type: field.TypeEnum, Enums: []string{"unknown", "male", "female"}, Default: "unknown"}, {Name: "phone", Type: field.TypeString, Nullable: true, Size: 11}, {Name: "avatar_url", Type: field.TypeString, Nullable: true, Size: 200}, {Name: "homepage", Type: field.TypeString, Nullable: true, Size: 100}, {Name: "bio", Type: field.TypeString, Nullable: true, Size: 200}, {Name: "password", Type: field.TypeString, Nullable: true, Size: 100}, {Name: "status", Type: field.TypeEnum, Nullable: true, Enums: []string{"BLACKLIST"}}, {Name: "last_pwd_auth", Type: field.TypeTime, Nullable: true}, {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, {Name: "delete_time", Type: field.TypeTime, Nullable: true}, } // UserTable holds the schema information for the "user" table. UserTable = &schema.Table{ Name: "user", Columns: UserColumns, PrimaryKey: []*schema.Column{UserColumns[0]}, Indexes: []*schema.Index{ { Name: "user_create_time", Unique: false, Columns: []*schema.Column{UserColumns[12]}, }, { Name: "user_update_time", Unique: false, Columns: []*schema.Column{UserColumns[13]}, }, { Name: "user_sn", Unique: true, Columns: []*schema.Column{UserColumns[1]}, }, { Name: "user_nickname", Unique: true, Columns: []*schema.Column{UserColumns[2]}, }, }, } // UserEmailColumns holds the columns for the "user_email" table. UserEmailColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "email", Type: field.TypeString, Size: 30}, {Name: "verify_ticket", Type: field.TypeString, Unique: true, Size: 50}, {Name: "verify_time", Type: field.TypeTime, Nullable: true}, {Name: "is_primary", Type: field.TypeBool, Default: false}, {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, {Name: "owner_id", Type: field.TypeInt, Nullable: true}, } // UserEmailTable holds the schema information for the "user_email" table. UserEmailTable = &schema.Table{ Name: "user_email", Columns: UserEmailColumns, PrimaryKey: []*schema.Column{UserEmailColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "user_email_user_UserEmails", Columns: []*schema.Column{UserEmailColumns[7]}, RefColumns: []*schema.Column{UserColumns[0]}, OnDelete: schema.SetNull, }, }, Indexes: []*schema.Index{ { Name: "useremail_owner_id", Unique: false, Columns: []*schema.Column{UserEmailColumns[7]}, }, { Name: "useremail_is_primary", Unique: false, Columns: []*schema.Column{UserEmailColumns[4]}, }, { Name: "useremail_create_time", Unique: false, Columns: []*schema.Column{UserEmailColumns[5]}, }, { Name: "useremail_update_time", Unique: false, Columns: []*schema.Column{UserEmailColumns[6]}, }, { Name: "useremail_email", Unique: true, Columns: []*schema.Column{UserEmailColumns[1]}, }, }, } // UserSecurityLogColumns holds the columns for the "user_security_log" table. UserSecurityLogColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "action", Type: field.TypeEnum, Enums: []string{"UNKNOWN", "SIGN_IN", "SIGN_OUT", "PWD_AUTH", "SIGN_UP_EMAIL", "SIGN_IN___PWD", "SIGN_IN___PHONE", "SIGN_IN___EMAIL", "2ND_AUTH___PWD", "2ND_AUTH___PHONE", "2ND_AUTH___EMAIL"}, Default: "UNKNOWN"}, {Name: "ip", Type: field.TypeString, Nullable: true, Size: 128}, {Name: "request_id", Type: field.TypeString, Nullable: true, Size: 100}, {Name: "server_version", Type: field.TypeString, Nullable: true, Size: 50}, {Name: "description", Type: field.TypeString, Nullable: true, Size: 200}, {Name: "remark", Type: field.TypeString, Nullable: true, Size: 200}, {Name: "create_time", Type: field.TypeTime}, {Name: "owner_id", Type: field.TypeInt, Nullable: true}, } // UserSecurityLogTable holds the schema information for the "user_security_log" table. UserSecurityLogTable = &schema.Table{ Name: "user_security_log", Columns: UserSecurityLogColumns, PrimaryKey: []*schema.Column{UserSecurityLogColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "user_security_log_user_UserSecurityLogs", Columns: []*schema.Column{UserSecurityLogColumns[8]}, RefColumns: []*schema.Column{UserColumns[0]}, OnDelete: schema.SetNull, }, }, } // UserSettingColumns holds the columns for the "user_setting" table. UserSettingColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "key", Type: field.TypeString, Unique: true, Size: 100}, {Name: "value", Type: field.TypeString, Size: 2147483647}, {Name: "typeof", Type: field.TypeEnum, Enums: []string{"STRING", "NUMBER", "BOOLEAN", "ARRAY", "JSON"}, Default: "STRING"}, {Name: "owner_id", Type: field.TypeInt, Nullable: true}, } // UserSettingTable holds the schema information for the "user_setting" table. UserSettingTable = &schema.Table{ Name: "user_setting", Columns: UserSettingColumns, PrimaryKey: []*schema.Column{UserSettingColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "user_setting_user_UserSettings", Columns: []*schema.Column{UserSettingColumns[4]}, RefColumns: []*schema.Column{UserColumns[0]}, OnDelete: schema.SetNull, }, }, } // ComponentComponentTagsColumns holds the columns for the "component_component_tags" table. ComponentComponentTagsColumns = []*schema.Column{ {Name: "component_id", Type: field.TypeInt}, {Name: "component_tag_id", Type: field.TypeInt}, } // ComponentComponentTagsTable holds the schema information for the "component_component_tags" table. ComponentComponentTagsTable = &schema.Table{ Name: "component_component_tags", Columns: ComponentComponentTagsColumns, PrimaryKey: []*schema.Column{ComponentComponentTagsColumns[0], ComponentComponentTagsColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "component_component_tags_component_id", Columns: []*schema.Column{ComponentComponentTagsColumns[0]}, RefColumns: []*schema.Column{ComponentsColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "component_component_tags_component_tag_id", Columns: []*schema.Column{ComponentComponentTagsColumns[1]}, RefColumns: []*schema.Column{ComponentTagColumns[0]}, OnDelete: schema.Cascade, }, }, } // Tables holds all the tables in the schema. Tables = []*schema.Table{ ComponentsTable, ComponentTagTable, GroupTable, ModelVersionTable, SystemSettingTable, UserTable, UserEmailTable, UserSecurityLogTable, UserSettingTable, ComponentComponentTagsTable, } )
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.