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 ( // 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}, {Name: "name", Type: field.TypeString, Size: 40}, {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]}, ForeignKeys: []*schema.ForeignKey{}, } // 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}, {Name: "nickname", Type: field.TypeString, Unique: true, Size: 20}, {Name: "phone", Type: field.TypeString, Nullable: true, Size: 11}, {Name: "password", Type: field.TypeString, 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: "group_id", Type: field.TypeInt, Nullable: true}, {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, {Name: "delete_time", Type: field.TypeTime, Nullable: true}, {Name: "group_members", 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_group_members", Columns: []*schema.Column{MemberColumns[12]}, RefColumns: []*schema.Column{GroupColumns[0]}, OnDelete: schema.SetNull, }, }, } // MemberEmailColumns holds the columns for the "member_email" table. MemberEmailColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "owner", Type: field.TypeString, Unique: true}, {Name: "email", Type: field.TypeString, Size: 40}, {Name: "verify", Type: field.TypeBool, Default: false}, {Name: "verify_ticker", Type: field.TypeString, Nullable: true, Size: 40}, {Name: "verify_time", Type: field.TypeTime}, {Name: "is_primary", Type: field.TypeBool, Default: false}, {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, } // 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{}, } // MemberSecurityLogColumns holds the columns for the "member_security_log" table. MemberSecurityLogColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID, Unique: true}, {Name: "uid", Type: field.TypeString, Size: 40}, {Name: "action", Type: field.TypeEnum, Enums: []string{"UNKNOWN", "SIGN_IN", "SIGN_OUT", "PWD_AUTH", "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}, } // 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{}, } // MemberSettingColumns holds the columns for the "member_setting" table. MemberSettingColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "member_id", Type: field.TypeString}, {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"}, } // 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{}, } // SysSettingColumns holds the columns for the "sys_setting" table. SysSettingColumns = []*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"}, } // SysSettingTable holds the schema information for the "sys_setting" table. SysSettingTable = &schema.Table{ Name: "sys_setting", Columns: SysSettingColumns, PrimaryKey: []*schema.Column{SysSettingColumns[0]}, ForeignKeys: []*schema.ForeignKey{}, } // MemberEmailsColumns holds the columns for the "member_emails" table. MemberEmailsColumns = []*schema.Column{ {Name: "member_id", Type: field.TypeInt}, {Name: "member_email_id", Type: field.TypeInt}, } // MemberEmailsTable holds the schema information for the "member_emails" table. MemberEmailsTable = &schema.Table{ Name: "member_emails", Columns: MemberEmailsColumns, PrimaryKey: []*schema.Column{MemberEmailsColumns[0], MemberEmailsColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "member_emails_member_id", Columns: []*schema.Column{MemberEmailsColumns[0]}, RefColumns: []*schema.Column{MemberColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "member_emails_member_email_id", Columns: []*schema.Column{MemberEmailsColumns[1]}, RefColumns: []*schema.Column{MemberEmailColumns[0]}, OnDelete: schema.Cascade, }, }, } // MemberSettingsColumns holds the columns for the "member_settings" table. MemberSettingsColumns = []*schema.Column{ {Name: "member_id", Type: field.TypeInt}, {Name: "member_setting_id", Type: field.TypeInt}, } // MemberSettingsTable holds the schema information for the "member_settings" table. MemberSettingsTable = &schema.Table{ Name: "member_settings", Columns: MemberSettingsColumns, PrimaryKey: []*schema.Column{MemberSettingsColumns[0], MemberSettingsColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "member_settings_member_id", Columns: []*schema.Column{MemberSettingsColumns[0]}, RefColumns: []*schema.Column{MemberColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "member_settings_member_setting_id", Columns: []*schema.Column{MemberSettingsColumns[1]}, RefColumns: []*schema.Column{MemberSettingColumns[0]}, OnDelete: schema.Cascade, }, }, } // Tables holds all the tables in the schema. Tables = []*schema.Table{ GroupTable, MemberTable, MemberEmailTable, MemberSecurityLogTable, MemberSettingTable, SysSettingTable, MemberEmailsTable, MemberSettingsTable, } )
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.