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 ( // CategoriesColumns holds the columns for the "categories" table. CategoriesColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "name", Type: field.TypeString, Unique: true}, } // CategoriesTable holds the schema information for the "categories" table. CategoriesTable = &schema.Table{ Name: "categories", Columns: CategoriesColumns, PrimaryKey: []*schema.Column{CategoriesColumns[0]}, } // ChallengesColumns holds the columns for the "challenges" table. ChallengesColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "media", Type: field.TypeString}, {Name: "prompt", Type: field.TypeString}, {Name: "response", Type: field.TypeString}, {Name: "value", Type: field.TypeInt}, } // ChallengesTable holds the schema information for the "challenges" table. ChallengesTable = &schema.Table{ Name: "challenges", Columns: ChallengesColumns, PrimaryKey: []*schema.Column{ChallengesColumns[0]}, } // ChallengeGroupsColumns holds the columns for the "challenge_groups" table. ChallengeGroupsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, } // ChallengeGroupsTable holds the schema information for the "challenge_groups" table. ChallengeGroupsTable = &schema.Table{ Name: "challenge_groups", Columns: ChallengeGroupsColumns, PrimaryKey: []*schema.Column{ChallengeGroupsColumns[0]}, } // CategoryChallengeGroupsColumns holds the columns for the "category_challenge_groups" table. CategoryChallengeGroupsColumns = []*schema.Column{ {Name: "category_id", Type: field.TypeInt}, {Name: "challenge_group_id", Type: field.TypeInt}, } // CategoryChallengeGroupsTable holds the schema information for the "category_challenge_groups" table. CategoryChallengeGroupsTable = &schema.Table{ Name: "category_challenge_groups", Columns: CategoryChallengeGroupsColumns, PrimaryKey: []*schema.Column{CategoryChallengeGroupsColumns[0], CategoryChallengeGroupsColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "category_challenge_groups_category_id", Columns: []*schema.Column{CategoryChallengeGroupsColumns[0]}, RefColumns: []*schema.Column{CategoriesColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "category_challenge_groups_challenge_group_id", Columns: []*schema.Column{CategoryChallengeGroupsColumns[1]}, RefColumns: []*schema.Column{ChallengeGroupsColumns[0]}, OnDelete: schema.Cascade, }, }, } // ChallengeGroupChallengesColumns holds the columns for the "challenge_group_challenges" table. ChallengeGroupChallengesColumns = []*schema.Column{ {Name: "challenge_group_id", Type: field.TypeInt}, {Name: "challenge_id", Type: field.TypeInt}, } // ChallengeGroupChallengesTable holds the schema information for the "challenge_group_challenges" table. ChallengeGroupChallengesTable = &schema.Table{ Name: "challenge_group_challenges", Columns: ChallengeGroupChallengesColumns, PrimaryKey: []*schema.Column{ChallengeGroupChallengesColumns[0], ChallengeGroupChallengesColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "challenge_group_challenges_challenge_group_id", Columns: []*schema.Column{ChallengeGroupChallengesColumns[0]}, RefColumns: []*schema.Column{ChallengeGroupsColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "challenge_group_challenges_challenge_id", Columns: []*schema.Column{ChallengeGroupChallengesColumns[1]}, RefColumns: []*schema.Column{ChallengesColumns[0]}, OnDelete: schema.Cascade, }, }, } // EpisodesColumns holds the columns for the "episodes" table. EpisodesColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "aired", Type: field.TypeTime}, {Name: "difficulty", Type: field.TypeEnum, Enums: []string{"UNKNOWN", "Kids", "College", "Standard", "Champions"}}, } // EpisodesTable holds the schema information for the "episodes" table. EpisodesTable = &schema.Table{ Name: "episodes", Columns: EpisodesColumns, PrimaryKey: []*schema.Column{EpisodesColumns[0]}, } // EpisodeRoundsColumns holds the columns for the "episode_rounds" table. EpisodeRoundsColumns = []*schema.Column{ {Name: "episode_id", Type: field.TypeInt}, {Name: "episode_round_id", Type: field.TypeInt}, } // EpisodeRoundsTable holds the schema information for the "episode_rounds" table. EpisodeRoundsTable = &schema.Table{ Name: "episode_rounds", Columns: EpisodeRoundsColumns, PrimaryKey: []*schema.Column{EpisodeRoundsColumns[0], EpisodeRoundsColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "episode_rounds_episode_id", Columns: []*schema.Column{EpisodeRoundsColumns[0]}, RefColumns: []*schema.Column{EpisodesColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "episode_rounds_episode_round_id", Columns: []*schema.Column{EpisodeRoundsColumns[1]}, RefColumns: []*schema.Column{EpisodeRoundsColumns[0]}, OnDelete: schema.Cascade, }, }, } // EpisodeRoundCategoriesColumns holds the columns for the "episode_round_categories" table. EpisodeRoundCategoriesColumns = []*schema.Column{ {Name: "episode_round_id", Type: field.TypeInt}, {Name: "challenge_group_id", Type: field.TypeInt}, } // EpisodeRoundCategoriesTable holds the schema information for the "episode_round_categories" table. EpisodeRoundCategoriesTable = &schema.Table{ Name: "episode_round_categories", Columns: EpisodeRoundCategoriesColumns, PrimaryKey: []*schema.Column{EpisodeRoundCategoriesColumns[0], EpisodeRoundCategoriesColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "episode_round_categories_episode_round_id", Columns: []*schema.Column{EpisodeRoundCategoriesColumns[0]}, RefColumns: []*schema.Column{EpisodeRoundsColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "episode_round_categories_challenge_group_id", Columns: []*schema.Column{EpisodeRoundCategoriesColumns[1]}, RefColumns: []*schema.Column{ChallengeGroupsColumns[0]}, OnDelete: schema.Cascade, }, }, } // Tables holds all the tables in the schema. Tables = []*schema.Table{ CategoriesTable, ChallengesTable, ChallengeGroupsTable, CategoryChallengeGroupsTable, ChallengeGroupChallengesTable, EpisodesTable, EpisodeRoundsTable, EpisodeRoundCategoriesTable, } )
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.