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 ( // PermissionsColumns holds the columns for the "permissions" table. PermissionsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "name", Type: field.TypeString, Unique: true}, {Name: "description", Type: field.TypeString, Nullable: true}, {Name: "created_at", Type: field.TypeTime}, } // PermissionsTable holds the schema information for the "permissions" table. PermissionsTable = &schema.Table{ Name: "permissions", Columns: PermissionsColumns, PrimaryKey: []*schema.Column{PermissionsColumns[0]}, } // RolesColumns holds the columns for the "roles" table. RolesColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "name", Type: field.TypeString, Unique: true}, {Name: "description", Type: field.TypeString, Nullable: true}, {Name: "created_at", Type: field.TypeTime}, } // RolesTable holds the schema information for the "roles" table. RolesTable = &schema.Table{ Name: "roles", Columns: RolesColumns, PrimaryKey: []*schema.Column{RolesColumns[0]}, } // UsersColumns holds the columns for the "users" table. UsersColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID}, {Name: "email", Type: field.TypeString, Unique: true}, {Name: "password_hash", Type: field.TypeString}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "last_login", Type: field.TypeTime, Nullable: true}, {Name: "is_active", Type: field.TypeBool, Default: false}, {Name: "email_verified", Type: field.TypeBool, Default: false}, {Name: "verification_token", Type: field.TypeString, Nullable: true}, {Name: "verification_token_expiry", Type: field.TypeTime, Nullable: true}, {Name: "password_reset_token", Type: field.TypeString, Nullable: true}, {Name: "password_reset_token_expiry", Type: field.TypeTime, Nullable: true}, {Name: "metadata", Type: field.TypeJSON, Nullable: true}, } // UsersTable holds the schema information for the "users" table. UsersTable = &schema.Table{ Name: "users", Columns: UsersColumns, PrimaryKey: []*schema.Column{UsersColumns[0]}, } // RolesPermissionsColumns holds the columns for the "roles_permissions" table. RolesPermissionsColumns = []*schema.Column{ {Name: "roles_id", Type: field.TypeInt}, {Name: "permissions_id", Type: field.TypeInt}, } // RolesPermissionsTable holds the schema information for the "roles_permissions" table. RolesPermissionsTable = &schema.Table{ Name: "roles_permissions", Columns: RolesPermissionsColumns, PrimaryKey: []*schema.Column{RolesPermissionsColumns[0], RolesPermissionsColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "roles_permissions_roles_id", Columns: []*schema.Column{RolesPermissionsColumns[0]}, RefColumns: []*schema.Column{RolesColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "roles_permissions_permissions_id", Columns: []*schema.Column{RolesPermissionsColumns[1]}, RefColumns: []*schema.Column{PermissionsColumns[0]}, OnDelete: schema.Cascade, }, }, } // UsersRolesColumns holds the columns for the "users_roles" table. UsersRolesColumns = []*schema.Column{ {Name: "users_id", Type: field.TypeUUID}, {Name: "roles_id", Type: field.TypeInt}, } // UsersRolesTable holds the schema information for the "users_roles" table. UsersRolesTable = &schema.Table{ Name: "users_roles", Columns: UsersRolesColumns, PrimaryKey: []*schema.Column{UsersRolesColumns[0], UsersRolesColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "users_roles_users_id", Columns: []*schema.Column{UsersRolesColumns[0]}, RefColumns: []*schema.Column{UsersColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "users_roles_roles_id", Columns: []*schema.Column{UsersRolesColumns[1]}, RefColumns: []*schema.Column{RolesColumns[0]}, OnDelete: schema.Cascade, }, }, } // Tables holds all the tables in the schema. Tables = []*schema.Table{ PermissionsTable, RolesTable, UsersTable, RolesPermissionsTable, UsersRolesTable, } )
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.