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 ( // MemberGroupColumns holds the columns for the "member_group" table. MemberGroupColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "sn", Type: field.TypeString, Unique: true, Size: 50}, {Name: "name", Type: field.TypeString, Size: 40}, {Name: "description", Type: field.TypeString, Size: 2147483647}, {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, {Name: "delete_time", Type: field.TypeTime, Nullable: true}, } // MemberGroupTable holds the schema information for the "member_group" table. MemberGroupTable = &schema.Table{ Name: "member_group", Columns: MemberGroupColumns, PrimaryKey: []*schema.Column{MemberGroupColumns[0]}, Indexes: []*schema.Index{ { Name: "group_name", Unique: false, Columns: []*schema.Column{MemberGroupColumns[2]}, }, { Name: "group_description", Unique: false, Columns: []*schema.Column{MemberGroupColumns[3]}, }, { Name: "group_create_time", Unique: false, Columns: []*schema.Column{MemberGroupColumns[4]}, }, { Name: "group_update_time", Unique: false, Columns: []*schema.Column{MemberGroupColumns[5]}, }, { Name: "group_delete_time", Unique: false, Columns: []*schema.Column{MemberGroupColumns[6]}, }, { Name: "group_sn", Unique: true, Columns: []*schema.Column{MemberGroupColumns[1]}, }, }, } // MemberColumns holds the columns for the "member" table. MemberColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "sn", Type: field.TypeString, Unique: true, Size: 50}, {Name: "nickname", Type: field.TypeString, Unique: true, Size: 20}, {Name: "phone", Type: field.TypeString, Nullable: true, Size: 11}, {Name: "password", Type: field.TypeString, Nullable: true, Size: 100}, {Name: "status", Type: field.TypeEnum, Nullable: true, Enums: []string{"BLACKLIST"}}, {Name: "signature", Type: field.TypeString}, {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}, {Name: "group_id", Type: field.TypeInt, Nullable: true}, } // MemberTable holds the schema information for the "member" table. MemberTable = &schema.Table{ Name: "member", Columns: MemberColumns, PrimaryKey: []*schema.Column{MemberColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "member_member_group_group_members", Columns: []*schema.Column{MemberColumns[11]}, RefColumns: []*schema.Column{MemberGroupColumns[0]}, OnDelete: schema.SetNull, }, }, Indexes: []*schema.Index{ { Name: "member_group_id", Unique: false, Columns: []*schema.Column{MemberColumns[11]}, }, { Name: "member_create_time", Unique: false, Columns: []*schema.Column{MemberColumns[8]}, }, { Name: "member_update_time", Unique: false, Columns: []*schema.Column{MemberColumns[9]}, }, { Name: "member_sn", Unique: true, Columns: []*schema.Column{MemberColumns[1]}, }, { Name: "member_nickname", Unique: true, Columns: []*schema.Column{MemberColumns[2]}, }, }, } // MemberEmailColumns holds the columns for the "member_email" table. MemberEmailColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "email", Type: field.TypeString, Size: 40}, {Name: "verify", Type: field.TypeBool, Default: false}, {Name: "verify_ticket", Type: field.TypeString, Nullable: true, Size: 40}, {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}, } // MemberEmailTable holds the schema information for the "member_email" table. MemberEmailTable = &schema.Table{ Name: "member_email", Columns: MemberEmailColumns, PrimaryKey: []*schema.Column{MemberEmailColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "member_email_member_member_emails", Columns: []*schema.Column{MemberEmailColumns[8]}, RefColumns: []*schema.Column{MemberColumns[0]}, OnDelete: schema.SetNull, }, }, Indexes: []*schema.Index{ { Name: "memberemail_owner_id", Unique: false, Columns: []*schema.Column{MemberEmailColumns[8]}, }, { Name: "memberemail_verify", Unique: false, Columns: []*schema.Column{MemberEmailColumns[2]}, }, { Name: "memberemail_is_primary", Unique: false, Columns: []*schema.Column{MemberEmailColumns[5]}, }, { Name: "memberemail_create_time", Unique: false, Columns: []*schema.Column{MemberEmailColumns[6]}, }, { Name: "memberemail_update_time", Unique: false, Columns: []*schema.Column{MemberEmailColumns[7]}, }, { Name: "memberemail_email", Unique: true, Columns: []*schema.Column{MemberEmailColumns[1]}, }, }, } // MemberSecurityLogColumns holds the columns for the "member_security_log" table. MemberSecurityLogColumns = []*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}, } // MemberSecurityLogTable holds the schema information for the "member_security_log" table. MemberSecurityLogTable = &schema.Table{ Name: "member_security_log", Columns: MemberSecurityLogColumns, PrimaryKey: []*schema.Column{MemberSecurityLogColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "member_security_log_member_member_security_logs", Columns: []*schema.Column{MemberSecurityLogColumns[8]}, RefColumns: []*schema.Column{MemberColumns[0]}, OnDelete: schema.SetNull, }, }, } // MemberSettingColumns holds the columns for the "member_setting" table. MemberSettingColumns = []*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}, } // MemberSettingTable holds the schema information for the "member_setting" table. MemberSettingTable = &schema.Table{ Name: "member_setting", Columns: MemberSettingColumns, PrimaryKey: []*schema.Column{MemberSettingColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "member_setting_member_member_settings", Columns: []*schema.Column{MemberSettingColumns[4]}, RefColumns: []*schema.Column{MemberColumns[0]}, OnDelete: schema.SetNull, }, }, } // SnippetsColumns holds the columns for the "snippets" table. SnippetsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "sn", Type: field.TypeString, Unique: true, Size: 50}, {Name: "owner_id", Type: field.TypeInt}, {Name: "title", Type: field.TypeString, Nullable: true, Size: 100}, {Name: "folder_id", Type: field.TypeInt, Nullable: true}, {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, {Name: "member_member_snippets", Type: field.TypeInt, Nullable: true}, {Name: "snippet_folder_snippets", Type: field.TypeInt, Nullable: true}, } // SnippetsTable holds the schema information for the "snippets" table. SnippetsTable = &schema.Table{ Name: "snippets", Columns: SnippetsColumns, PrimaryKey: []*schema.Column{SnippetsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "snippets_member_member_snippets", Columns: []*schema.Column{SnippetsColumns[7]}, RefColumns: []*schema.Column{MemberColumns[0]}, OnDelete: schema.SetNull, }, { Symbol: "snippets_snippet_folders_snippets", Columns: []*schema.Column{SnippetsColumns[8]}, RefColumns: []*schema.Column{SnippetFoldersColumns[0]}, OnDelete: schema.SetNull, }, }, Indexes: []*schema.Index{ { Name: "snippet_owner_id", Unique: false, Columns: []*schema.Column{SnippetsColumns[2]}, }, { Name: "snippet_folder_id", Unique: false, Columns: []*schema.Column{SnippetsColumns[4]}, }, { Name: "snippet_title", Unique: false, Columns: []*schema.Column{SnippetsColumns[3]}, }, { Name: "snippet_create_time", Unique: false, Columns: []*schema.Column{SnippetsColumns[5]}, }, { Name: "snippet_update_time", Unique: false, Columns: []*schema.Column{SnippetsColumns[6]}, }, { Name: "snippet_sn", Unique: true, Columns: []*schema.Column{SnippetsColumns[1]}, }, }, } // SnippetDocsColumns holds the columns for the "snippet_docs" table. SnippetDocsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "owner_id", Type: field.TypeInt}, {Name: "language", Type: field.TypeString, Size: 20, Default: "text"}, {Name: "description", Type: field.TypeString, Size: 100}, {Name: "raw", Type: field.TypeString, Size: 2147483647}, {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, {Name: "member_member_snippet_docs", Type: field.TypeInt, Nullable: true}, {Name: "snippet_id", Type: field.TypeInt, Nullable: true}, } // SnippetDocsTable holds the schema information for the "snippet_docs" table. SnippetDocsTable = &schema.Table{ Name: "snippet_docs", Columns: SnippetDocsColumns, PrimaryKey: []*schema.Column{SnippetDocsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "snippet_docs_member_member_snippet_docs", Columns: []*schema.Column{SnippetDocsColumns[7]}, RefColumns: []*schema.Column{MemberColumns[0]}, OnDelete: schema.SetNull, }, { Symbol: "snippet_docs_snippets_snippet_docs", Columns: []*schema.Column{SnippetDocsColumns[8]}, RefColumns: []*schema.Column{SnippetsColumns[0]}, OnDelete: schema.SetNull, }, }, Indexes: []*schema.Index{ { Name: "snippetdocument_language", Unique: false, Columns: []*schema.Column{SnippetDocsColumns[2]}, }, { Name: "snippetdocument_description", Unique: false, Columns: []*schema.Column{SnippetDocsColumns[3]}, }, { Name: "snippetdocument_snippet_id", Unique: false, Columns: []*schema.Column{SnippetDocsColumns[8]}, }, { Name: "snippetdocument_owner_id", Unique: false, Columns: []*schema.Column{SnippetDocsColumns[1]}, }, { Name: "snippetdocument_create_time", Unique: false, Columns: []*schema.Column{SnippetDocsColumns[5]}, }, { Name: "snippetdocument_update_time", Unique: false, Columns: []*schema.Column{SnippetDocsColumns[6]}, }, }, } // SnippetFoldersColumns holds the columns for the "snippet_folders" table. SnippetFoldersColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "pid", Type: field.TypeInt, Nullable: true}, {Name: "owner_id", Type: field.TypeInt}, {Name: "snippet_id", Type: field.TypeInt}, {Name: "name", Type: field.TypeString, Size: 20}, {Name: "snippets_total", Type: field.TypeInt, Default: 0}, {Name: "language", Type: field.TypeString, Size: 20, Default: "text"}, {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, {Name: "member_member_snippet_folders", Type: field.TypeInt, Nullable: true}, } // SnippetFoldersTable holds the schema information for the "snippet_folders" table. SnippetFoldersTable = &schema.Table{ Name: "snippet_folders", Columns: SnippetFoldersColumns, PrimaryKey: []*schema.Column{SnippetFoldersColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "snippet_folders_member_member_snippet_folders", Columns: []*schema.Column{SnippetFoldersColumns[9]}, RefColumns: []*schema.Column{MemberColumns[0]}, OnDelete: schema.SetNull, }, }, Indexes: []*schema.Index{ { Name: "snippetfolder_pid", Unique: false, Columns: []*schema.Column{SnippetFoldersColumns[1]}, }, { Name: "snippetfolder_name", Unique: false, Columns: []*schema.Column{SnippetFoldersColumns[4]}, }, { Name: "snippetfolder_snippets_total", Unique: false, Columns: []*schema.Column{SnippetFoldersColumns[5]}, }, { Name: "snippetfolder_create_time", Unique: false, Columns: []*schema.Column{SnippetFoldersColumns[7]}, }, { Name: "snippetfolder_update_time", Unique: false, Columns: []*schema.Column{SnippetFoldersColumns[8]}, }, }, } // SnippetTagsColumns holds the columns for the "snippet_tags" table. SnippetTagsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "owner_id", Type: field.TypeInt}, {Name: "name", Type: field.TypeString, Size: 20}, {Name: "snippets_total", Type: field.TypeInt, Default: 0}, {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, {Name: "member_member_snippet_tags", Type: field.TypeInt, Nullable: true}, {Name: "snippet_id", Type: field.TypeInt, Nullable: true}, } // SnippetTagsTable holds the schema information for the "snippet_tags" table. SnippetTagsTable = &schema.Table{ Name: "snippet_tags", Columns: SnippetTagsColumns, PrimaryKey: []*schema.Column{SnippetTagsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "snippet_tags_member_member_snippet_tags", Columns: []*schema.Column{SnippetTagsColumns[6]}, RefColumns: []*schema.Column{MemberColumns[0]}, OnDelete: schema.SetNull, }, { Symbol: "snippet_tags_snippets_snippet_tags", Columns: []*schema.Column{SnippetTagsColumns[7]}, RefColumns: []*schema.Column{SnippetsColumns[0]}, OnDelete: schema.SetNull, }, }, Indexes: []*schema.Index{ { Name: "snippettag_name", Unique: false, Columns: []*schema.Column{SnippetTagsColumns[2]}, }, { Name: "snippettag_owner_id", Unique: false, Columns: []*schema.Column{SnippetTagsColumns[1]}, }, { Name: "snippettag_snippets_total", Unique: false, Columns: []*schema.Column{SnippetTagsColumns[3]}, }, { Name: "snippettag_create_time", Unique: false, Columns: []*schema.Column{SnippetTagsColumns[4]}, }, { Name: "snippettag_update_time", Unique: false, Columns: []*schema.Column{SnippetTagsColumns[5]}, }, }, } // 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{"id"}}, {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]}, }, }, } // Tables holds all the tables in the schema. Tables = []*schema.Table{ MemberGroupTable, MemberTable, MemberEmailTable, MemberSecurityLogTable, MemberSettingTable, SnippetsTable, SnippetDocsTable, SnippetFoldersTable, SnippetTagsTable, SystemSettingTable, } )
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.