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 ( // SessionsColumns holds the columns for the "sessions" table. SessionsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "key", Type: field.TypeString, Unique: true}, {Name: "data", Type: field.TypeJSON}, } // SessionsTable holds the schema information for the "sessions" table. SessionsTable = &schema.Table{ Name: "sessions", Columns: SessionsColumns, PrimaryKey: []*schema.Column{SessionsColumns[0]}, } // UsersColumns holds the columns for the "users" table. UsersColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, Unique: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "created_by", Type: field.TypeString}, {Name: "updated_at", Type: field.TypeTime}, {Name: "updated_by", Type: field.TypeString}, {Name: "status", Type: field.TypeEnum, Enums: []string{"ACTIVE", "INACTIVE", "DELETED"}, Default: "ACTIVE"}, {Name: "type", Type: field.TypeEnum, Enums: []string{"USER", "ADMIN"}, Default: "USER"}, {Name: "signup", Type: field.TypeBool, Default: false}, {Name: "username", Type: field.TypeString, Unique: true}, } // UsersTable holds the schema information for the "users" table. UsersTable = &schema.Table{ Name: "users", Columns: UsersColumns, PrimaryKey: []*schema.Column{UsersColumns[0]}, } // UserDevicesColumns holds the columns for the "user_devices" table. UserDevicesColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, Unique: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "created_by", Type: field.TypeString}, {Name: "updated_at", Type: field.TypeTime}, {Name: "updated_by", Type: field.TypeString}, {Name: "status", Type: field.TypeEnum, Enums: []string{"ACTIVE", "INACTIVE", "DELETED"}, Default: "ACTIVE"}, {Name: "type", Type: field.TypeEnum, Enums: []string{"DESKTOP", "MOBILE"}}, {Name: "os", Type: field.TypeEnum, Enums: []string{"MAC", "ANDROID", "WINDOWS"}}, {Name: "platform", Type: field.TypeEnum, Enums: []string{"native", "chrome", "safari", "explorer"}}, {Name: "user_id", Type: field.TypeString, Nullable: true}, } // UserDevicesTable holds the schema information for the "user_devices" table. UserDevicesTable = &schema.Table{ Name: "user_devices", Columns: UserDevicesColumns, PrimaryKey: []*schema.Column{UserDevicesColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "user_devices_users_devices", Columns: []*schema.Column{UserDevicesColumns[9]}, RefColumns: []*schema.Column{UsersColumns[0]}, OnDelete: schema.SetNull, }, }, Indexes: []*schema.Index{ { Name: "userdevice_user_id", Unique: true, Columns: []*schema.Column{UserDevicesColumns[9]}, }, }, } // UserMetaColumns holds the columns for the "user_meta" table. UserMetaColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, Unique: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "created_by", Type: field.TypeString}, {Name: "updated_at", Type: field.TypeTime}, {Name: "updated_by", Type: field.TypeString}, {Name: "profile", Type: field.TypeString}, {Name: "user_id", Type: field.TypeString, Nullable: true}, } // UserMetaTable holds the schema information for the "user_meta" table. UserMetaTable = &schema.Table{ Name: "user_meta", Columns: UserMetaColumns, PrimaryKey: []*schema.Column{UserMetaColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "user_meta_users_meta", Columns: []*schema.Column{UserMetaColumns[6]}, RefColumns: []*schema.Column{UsersColumns[0]}, OnDelete: schema.SetNull, }, }, Indexes: []*schema.Index{ { Name: "usermeta_user_id", Unique: true, Columns: []*schema.Column{UserMetaColumns[6]}, }, }, } // UserOauthProvidersColumns holds the columns for the "user_oauth_providers" table. UserOauthProvidersColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, Unique: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "created_by", Type: field.TypeString}, {Name: "updated_at", Type: field.TypeTime}, {Name: "updated_by", Type: field.TypeString}, {Name: "status", Type: field.TypeEnum, Enums: []string{"ACTIVE", "INACTIVE", "DELETED"}, Default: "ACTIVE"}, {Name: "provider", Type: field.TypeEnum, Enums: []string{"GOOGLE", "KAKAO"}}, {Name: "expiry", Type: field.TypeTime}, {Name: "access_token", Type: field.TypeString, Unique: true}, {Name: "refresh_token", Type: field.TypeString, Unique: true}, {Name: "user_id", Type: field.TypeString, Nullable: true}, } // UserOauthProvidersTable holds the schema information for the "user_oauth_providers" table. UserOauthProvidersTable = &schema.Table{ Name: "user_oauth_providers", Columns: UserOauthProvidersColumns, PrimaryKey: []*schema.Column{UserOauthProvidersColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "user_oauth_providers_users_oauth_providers", Columns: []*schema.Column{UserOauthProvidersColumns[10]}, RefColumns: []*schema.Column{UsersColumns[0]}, OnDelete: schema.SetNull, }, }, Indexes: []*schema.Index{ { Name: "useroauthprovider_user_id", Unique: false, Columns: []*schema.Column{UserOauthProvidersColumns[10]}, }, { Name: "useroauthprovider_status_provider_access_token", Unique: true, Columns: []*schema.Column{UserOauthProvidersColumns[5], UserOauthProvidersColumns[6], UserOauthProvidersColumns[8]}, }, { Name: "useroauthprovider_provider_refresh_token", Unique: true, Columns: []*schema.Column{UserOauthProvidersColumns[6], UserOauthProvidersColumns[9]}, }, }, } // Tables holds all the tables in the schema. Tables = []*schema.Table{ SessionsTable, UsersTable, UserDevicesTable, UserMetaTable, UserOauthProvidersTable, } )
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.