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 ( // GuildsColumns holds the columns for the "guilds" table. GuildsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, {Name: "guild_id", Type: field.TypeString, Unique: true}, {Name: "name", Type: field.TypeString, Size: 100}, {Name: "features", Type: field.TypeJSON, Nullable: true}, {Name: "icon_hash", Type: field.TypeString, Nullable: true, Size: 2048}, {Name: "icon_url", Type: field.TypeString, Size: 2048}, {Name: "joined_at", Type: field.TypeTime, Nullable: true}, {Name: "large", Type: field.TypeBool, Nullable: true, Default: false}, {Name: "member_count", Type: field.TypeInt, Nullable: true, Default: 0}, {Name: "owner_id", Type: field.TypeString, Nullable: true}, {Name: "permissions", Type: field.TypeUint64, Nullable: true, Default: 0}, {Name: "system_channel_flags", Type: field.TypeString, Nullable: true, Size: 32}, } // GuildsTable holds the schema information for the "guilds" table. GuildsTable = &schema.Table{ Name: "guilds", Columns: GuildsColumns, PrimaryKey: []*schema.Column{GuildsColumns[0]}, } // GuildAdminConfigsColumns holds the columns for the "guild_admin_configs" table. GuildAdminConfigsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, {Name: "enabled", Type: field.TypeBool, Nullable: true, Default: true}, {Name: "default_max_channels", Type: field.TypeInt, Nullable: true, Default: 0}, {Name: "default_max_clones", Type: field.TypeInt, Nullable: true, Default: 0}, {Name: "comment", Type: field.TypeString, Nullable: true, Default: ""}, {Name: "guild_guild_admin_config", Type: field.TypeInt, Unique: true}, } // GuildAdminConfigsTable holds the schema information for the "guild_admin_configs" table. GuildAdminConfigsTable = &schema.Table{ Name: "guild_admin_configs", Columns: GuildAdminConfigsColumns, PrimaryKey: []*schema.Column{GuildAdminConfigsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "guild_admin_configs_guilds_guild_admin_config", Columns: []*schema.Column{GuildAdminConfigsColumns[7]}, RefColumns: []*schema.Column{GuildsColumns[0]}, OnDelete: schema.NoAction, }, }, } // GuildConfigsColumns holds the columns for the "guild_configs" table. GuildConfigsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, {Name: "enabled", Type: field.TypeBool, Nullable: true, Default: true}, {Name: "default_max_clones", Type: field.TypeInt, Nullable: true, Default: 0}, {Name: "regex_match", Type: field.TypeString, Nullable: true, Size: 100, Default: ""}, {Name: "contact_email", Type: field.TypeString, Nullable: true, Size: 255, Default: ""}, {Name: "guild_guild_config", Type: field.TypeInt, Unique: true}, } // GuildConfigsTable holds the schema information for the "guild_configs" table. GuildConfigsTable = &schema.Table{ Name: "guild_configs", Columns: GuildConfigsColumns, PrimaryKey: []*schema.Column{GuildConfigsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "guild_configs_guilds_guild_config", Columns: []*schema.Column{GuildConfigsColumns[7]}, RefColumns: []*schema.Column{GuildsColumns[0]}, OnDelete: schema.NoAction, }, }, } // GuildEventsColumns holds the columns for the "guild_events" table. GuildEventsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, {Name: "type", Type: field.TypeEnum, Enums: []string{"INFO", "WARNING", "ERROR", "DEBUG"}}, {Name: "message", Type: field.TypeString}, {Name: "metadata", Type: field.TypeJSON, Nullable: true}, {Name: "guild_guild_events", Type: field.TypeInt}, } // GuildEventsTable holds the schema information for the "guild_events" table. GuildEventsTable = &schema.Table{ Name: "guild_events", Columns: GuildEventsColumns, PrimaryKey: []*schema.Column{GuildEventsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "guild_events_guilds_guild_events", Columns: []*schema.Column{GuildEventsColumns[6]}, RefColumns: []*schema.Column{GuildsColumns[0]}, OnDelete: schema.NoAction, }, }, } // UsersColumns holds the columns for the "users" table. UsersColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, {Name: "user_id", Type: field.TypeString, Unique: true}, {Name: "admin", Type: field.TypeBool, Nullable: true}, {Name: "banned", Type: field.TypeBool, Nullable: true}, {Name: "ban_reason", Type: field.TypeString, Nullable: true}, {Name: "username", Type: field.TypeString}, {Name: "discriminator", Type: field.TypeString, Size: 4}, {Name: "email", Type: field.TypeString, Size: 320}, {Name: "avatar_hash", Type: field.TypeString, Nullable: true, Size: 2048}, {Name: "avatar_url", Type: field.TypeString, Size: 2048}, {Name: "locale", Type: field.TypeString, Nullable: true, Size: 10}, {Name: "bot", Type: field.TypeBool, Nullable: true}, {Name: "system", Type: field.TypeBool, Nullable: true}, {Name: "mfa_enabled", Type: field.TypeBool, Nullable: true}, {Name: "verified", Type: field.TypeBool, Nullable: true}, {Name: "flags", Type: field.TypeUint64, Nullable: true}, {Name: "premium_type", Type: field.TypeInt, Nullable: true}, {Name: "public_flags", Type: field.TypeUint64, Nullable: true}, {Name: "user_banned_users", Type: field.TypeInt, 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_users_banned_users", Columns: []*schema.Column{UsersColumns[20]}, RefColumns: []*schema.Column{UsersColumns[0]}, OnDelete: schema.SetNull, }, }, } // UserUserGuildsColumns holds the columns for the "user_user_guilds" table. UserUserGuildsColumns = []*schema.Column{ {Name: "user_id", Type: field.TypeInt}, {Name: "guild_id", Type: field.TypeInt}, } // UserUserGuildsTable holds the schema information for the "user_user_guilds" table. UserUserGuildsTable = &schema.Table{ Name: "user_user_guilds", Columns: UserUserGuildsColumns, PrimaryKey: []*schema.Column{UserUserGuildsColumns[0], UserUserGuildsColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "user_user_guilds_user_id", Columns: []*schema.Column{UserUserGuildsColumns[0]}, RefColumns: []*schema.Column{UsersColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "user_user_guilds_guild_id", Columns: []*schema.Column{UserUserGuildsColumns[1]}, RefColumns: []*schema.Column{GuildsColumns[0]}, OnDelete: schema.Cascade, }, }, } // Tables holds all the tables in the schema. Tables = []*schema.Table{ GuildsTable, GuildAdminConfigsTable, GuildConfigsTable, GuildEventsTable, UsersTable, UserUserGuildsTable, } )
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.