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 ( // MerchantsColumns holds the columns for the "merchants" table. MerchantsColumns = []*schema.Column{ {Name: "id", Type: field.TypeUint64, Increment: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "deleted_at", Type: field.TypeTime, Nullable: true}, {Name: "merchant_name", Type: field.TypeString}, {Name: "contact_person", Type: field.TypeString, Nullable: true}, {Name: "contact_phone", Type: field.TypeString, Nullable: true}, {Name: "country", Type: field.TypeString, Nullable: true}, {Name: "province", Type: field.TypeString, Nullable: true}, {Name: "city", Type: field.TypeString, Nullable: true}, {Name: "district", Type: field.TypeString, Nullable: true}, {Name: "address", Type: field.TypeString, Nullable: true}, } // MerchantsTable holds the schema information for the "merchants" table. MerchantsTable = &schema.Table{ Name: "merchants", Columns: MerchantsColumns, PrimaryKey: []*schema.Column{MerchantsColumns[0]}, Indexes: []*schema.Index{ { Name: "merchant_created_at_updated_at", Unique: false, Columns: []*schema.Column{MerchantsColumns[1], MerchantsColumns[2]}, }, }, } // MerchantAccountsColumns holds the columns for the "merchant_accounts" table. MerchantAccountsColumns = []*schema.Column{ {Name: "id", Type: field.TypeUint64, Increment: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "deleted_at", Type: field.TypeTime, Nullable: true}, {Name: "username", Type: field.TypeString, Unique: true}, {Name: "password", Type: field.TypeString}, {Name: "email", Type: field.TypeString, Nullable: true, Default: ""}, {Name: "phone", Type: field.TypeString, Nullable: true, Default: ""}, {Name: "is_main_account", Type: field.TypeBool, Default: false}, {Name: "merchant_accounts", Type: field.TypeUint64, Nullable: true}, } // MerchantAccountsTable holds the schema information for the "merchant_accounts" table. MerchantAccountsTable = &schema.Table{ Name: "merchant_accounts", Columns: MerchantAccountsColumns, PrimaryKey: []*schema.Column{MerchantAccountsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "merchant_accounts_merchants_accounts", Columns: []*schema.Column{MerchantAccountsColumns[9]}, RefColumns: []*schema.Column{MerchantsColumns[0]}, OnDelete: schema.SetNull, }, }, Indexes: []*schema.Index{ { Name: "merchantaccount_created_at_updated_at", Unique: false, Columns: []*schema.Column{MerchantAccountsColumns[1], MerchantAccountsColumns[2]}, }, { Name: "merchantaccount_is_main_account", Unique: false, Columns: []*schema.Column{MerchantAccountsColumns[8]}, }, }, } // PlatformAccountsColumns holds the columns for the "platform_accounts" table. PlatformAccountsColumns = []*schema.Column{ {Name: "id", Type: field.TypeUint64, Increment: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "deleted_at", Type: field.TypeTime, Nullable: true}, {Name: "username", Type: field.TypeString, Unique: true}, {Name: "password", Type: field.TypeString}, {Name: "email", Type: field.TypeString, Nullable: true, Default: ""}, } // PlatformAccountsTable holds the schema information for the "platform_accounts" table. PlatformAccountsTable = &schema.Table{ Name: "platform_accounts", Columns: PlatformAccountsColumns, PrimaryKey: []*schema.Column{PlatformAccountsColumns[0]}, Indexes: []*schema.Index{ { Name: "platformaccount_created_at_updated_at", Unique: false, Columns: []*schema.Column{PlatformAccountsColumns[1], PlatformAccountsColumns[2]}, }, }, } // UsersColumns holds the columns for the "users" table. UsersColumns = []*schema.Column{ {Name: "id", Type: field.TypeUint64, Increment: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "deleted_at", Type: field.TypeTime, Nullable: true}, {Name: "username", Type: field.TypeString}, {Name: "phone", Type: field.TypeString, Nullable: true, Default: ""}, {Name: "email", Type: field.TypeString, Nullable: true, Default: ""}, {Name: "user_introducer", Type: field.TypeUint64, Nullable: true}, {Name: "user_default_merchant", Type: field.TypeUint64, Nullable: true}, } // UsersTable holds the schema information for the "users" table. UsersTable = &schema.Table{ Name: "users", Columns: UsersColumns, PrimaryKey: []*schema.Column{UsersColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "users_user_login_methods_introducer", Columns: []*schema.Column{UsersColumns[7]}, RefColumns: []*schema.Column{UserLoginMethodsColumns[0]}, OnDelete: schema.SetNull, }, { Symbol: "users_merchants_default_merchant", Columns: []*schema.Column{UsersColumns[8]}, RefColumns: []*schema.Column{MerchantsColumns[0]}, OnDelete: schema.SetNull, }, }, Indexes: []*schema.Index{ { Name: "user_created_at_updated_at", Unique: false, Columns: []*schema.Column{UsersColumns[1], UsersColumns[2]}, }, }, } // UserLoginMethodsColumns holds the columns for the "user_login_methods" table. UserLoginMethodsColumns = []*schema.Column{ {Name: "id", Type: field.TypeUint64, Increment: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "deleted_at", Type: field.TypeTime, Nullable: true}, {Name: "login_type", Type: field.TypeString}, {Name: "identifier", Type: field.TypeString}, {Name: "user_login_methods", Type: field.TypeUint64, Nullable: true}, } // UserLoginMethodsTable holds the schema information for the "user_login_methods" table. UserLoginMethodsTable = &schema.Table{ Name: "user_login_methods", Columns: UserLoginMethodsColumns, PrimaryKey: []*schema.Column{UserLoginMethodsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "user_login_methods_users_login_methods", Columns: []*schema.Column{UserLoginMethodsColumns[6]}, RefColumns: []*schema.Column{UsersColumns[0]}, OnDelete: schema.SetNull, }, }, Indexes: []*schema.Index{ { Name: "userloginmethod_created_at_updated_at", Unique: false, Columns: []*schema.Column{UserLoginMethodsColumns[1], UserLoginMethodsColumns[2]}, }, }, } // Tables holds all the tables in the schema. Tables = []*schema.Table{ MerchantsTable, MerchantAccountsTable, PlatformAccountsTable, UsersTable, UserLoginMethodsTable, } )
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.