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 ( // MmsMembersColumns holds the columns for the "mms_members" table. MmsMembersColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID}, {Name: "created_at", Type: field.TypeTime, Comment: "Create Time | 创建日期"}, {Name: "updated_at", Type: field.TypeTime, Comment: "Update Time | 修改日期"}, {Name: "status", Type: field.TypeUint8, Nullable: true, Comment: "Status 1: normal 2: ban | 状态 1 正常 2 禁用", Default: 1}, {Name: "username", Type: field.TypeString, Unique: true, Comment: "Member's login name | 登录名"}, {Name: "password", Type: field.TypeString, Comment: "Password | 密码"}, {Name: "nickname", Type: field.TypeString, Unique: true, Comment: "Nickname | 昵称"}, {Name: "mobile", Type: field.TypeString, Nullable: true, Comment: "Mobile number | 手机号"}, {Name: "email", Type: field.TypeString, Nullable: true, Comment: "Email | 邮箱号"}, {Name: "avatar", Type: field.TypeString, Nullable: true, Comment: "Avatar | 头像路径", Default: "", SchemaType: map[string]string{"mysql": "varchar(512)"}}, {Name: "wechat_open_id", Type: field.TypeString, Nullable: true, Comment: "Wechat Open ID | 微信 Open ID"}, {Name: "expired_at", Type: field.TypeTime, Nullable: true, Comment: "Member expired time | 会员到期时间", SchemaType: map[string]string{"mysql": "datetime"}}, {Name: "rank_id", Type: field.TypeUint64, Nullable: true, Comment: "Member Rank ID | 会员等级ID", Default: 2}, } // MmsMembersTable holds the schema information for the "mms_members" table. MmsMembersTable = &schema.Table{ Name: "mms_members", Columns: MmsMembersColumns, PrimaryKey: []*schema.Column{MmsMembersColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "mms_members_mms_ranks_ranks", Columns: []*schema.Column{MmsMembersColumns[12]}, RefColumns: []*schema.Column{MmsRanksColumns[0]}, OnDelete: schema.SetNull, }, }, Indexes: []*schema.Index{ { Name: "member_username_email", Unique: true, Columns: []*schema.Column{MmsMembersColumns[4], MmsMembersColumns[8]}, }, { Name: "member_wechat_open_id", Unique: true, Columns: []*schema.Column{MmsMembersColumns[10]}, }, }, } // MmsRanksColumns holds the columns for the "mms_ranks" table. MmsRanksColumns = []*schema.Column{ {Name: "id", Type: field.TypeUint64, Increment: true}, {Name: "created_at", Type: field.TypeTime, Comment: "Create Time | 创建日期"}, {Name: "updated_at", Type: field.TypeTime, Comment: "Update Time | 修改日期"}, {Name: "name", Type: field.TypeString}, {Name: "code", Type: field.TypeString}, {Name: "description", Type: field.TypeString}, {Name: "remark", Type: field.TypeString}, } // MmsRanksTable holds the schema information for the "mms_ranks" table. MmsRanksTable = &schema.Table{ Name: "mms_ranks", Columns: MmsRanksColumns, PrimaryKey: []*schema.Column{MmsRanksColumns[0]}, Indexes: []*schema.Index{ { Name: "memberrank_code", Unique: true, Columns: []*schema.Column{MmsRanksColumns[4]}, }, }, } // MmsOauthProvidersColumns holds the columns for the "mms_oauth_providers" table. MmsOauthProvidersColumns = []*schema.Column{ {Name: "id", Type: field.TypeUint64, Increment: true}, {Name: "created_at", Type: field.TypeTime, Comment: "Create Time | 创建日期"}, {Name: "updated_at", Type: field.TypeTime, Comment: "Update Time | 修改日期"}, {Name: "name", Type: field.TypeString, Unique: true, Comment: "The provider's name | 提供商名称"}, {Name: "client_id", Type: field.TypeString, Comment: "The client id | 客户端 id"}, {Name: "client_secret", Type: field.TypeString, Comment: "The client secret | 客户端密钥"}, {Name: "redirect_url", Type: field.TypeString, Comment: "The redirect url | 跳转地址"}, {Name: "scopes", Type: field.TypeString, Comment: "The scopes | 权限范围"}, {Name: "auth_url", Type: field.TypeString, Comment: "The auth url of the provider | 认证地址"}, {Name: "token_url", Type: field.TypeString, Comment: "The token url of the provider | 获取 token地址"}, {Name: "auth_style", Type: field.TypeUint64, Comment: "The auth style, 0: auto detect 1: third party log in 2: log in with username and password"}, {Name: "info_url", Type: field.TypeString, Comment: "The URL to request user information by token | 用户信息请求地址"}, } // MmsOauthProvidersTable holds the schema information for the "mms_oauth_providers" table. MmsOauthProvidersTable = &schema.Table{ Name: "mms_oauth_providers", Columns: MmsOauthProvidersColumns, PrimaryKey: []*schema.Column{MmsOauthProvidersColumns[0]}, } // MmsTokensColumns holds the columns for the "mms_tokens" table. MmsTokensColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID}, {Name: "created_at", Type: field.TypeTime, Comment: "Create Time | 创建日期"}, {Name: "updated_at", Type: field.TypeTime, Comment: "Update Time | 修改日期"}, {Name: "status", Type: field.TypeUint8, Nullable: true, Comment: "Status 1: normal 2: ban | 状态 1 正常 2 禁用", Default: 1}, {Name: "uuid", Type: field.TypeUUID, Comment: " User's UUID | 用户的UUID"}, {Name: "token", Type: field.TypeString, Comment: "Token string | Token 字符串"}, {Name: "username", Type: field.TypeString, Comment: "Username | 用户名", Default: "unknown"}, {Name: "source", Type: field.TypeString, Comment: "Log in source such as GitHub | Token 来源 (本地为core, 第三方如github等)"}, {Name: "expired_at", Type: field.TypeTime, Comment: " Expire time | 过期时间"}, } // MmsTokensTable holds the schema information for the "mms_tokens" table. MmsTokensTable = &schema.Table{ Name: "mms_tokens", Columns: MmsTokensColumns, PrimaryKey: []*schema.Column{MmsTokensColumns[0]}, Indexes: []*schema.Index{ { Name: "mms_token_uuid", Unique: false, Columns: []*schema.Column{MmsTokensColumns[4]}, }, { Name: "mms_token_expired_at", Unique: false, Columns: []*schema.Column{MmsTokensColumns[8]}, }, }, } // Tables holds all the tables in the schema. Tables = []*schema.Table{ MmsMembersTable, MmsRanksTable, MmsOauthProvidersTable, MmsTokensTable, } )
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.