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 ( // BirthdaysColumns holds the columns for the "birthdays" table. BirthdaysColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "day", Type: field.TypeInt}, {Name: "month", Type: field.TypeInt}, {Name: "user_birthday", Type: field.TypeString, Unique: true, Nullable: true}, } // BirthdaysTable holds the schema information for the "birthdays" table. BirthdaysTable = &schema.Table{ Name: "birthdays", Columns: BirthdaysColumns, PrimaryKey: []*schema.Column{BirthdaysColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "birthdays_users_birthday", Columns: []*schema.Column{BirthdaysColumns[3]}, RefColumns: []*schema.Column{UsersColumns[0]}, OnDelete: schema.SetNull, }, }, } // OpenstacksColumns holds the columns for the "openstacks" table. OpenstacksColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "timestamp", Type: field.TypeTime}, {Name: "user_openstack", Type: field.TypeString, Unique: true, Nullable: true}, } // OpenstacksTable holds the schema information for the "openstacks" table. OpenstacksTable = &schema.Table{ Name: "openstacks", Columns: OpenstacksColumns, PrimaryKey: []*schema.Column{OpenstacksColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "openstacks_users_openstack", Columns: []*schema.Column{OpenstacksColumns[2]}, RefColumns: []*schema.Column{UsersColumns[0]}, OnDelete: schema.SetNull, }, }, } // ShitpostsColumns holds the columns for the "shitposts" table. ShitpostsColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, Unique: true}, {Name: "channel_id", Type: field.TypeString}, {Name: "count", Type: field.TypeInt}, {Name: "user_shitposts", Type: field.TypeString, Nullable: true}, } // ShitpostsTable holds the schema information for the "shitposts" table. ShitpostsTable = &schema.Table{ Name: "shitposts", Columns: ShitpostsColumns, PrimaryKey: []*schema.Column{ShitpostsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "shitposts_users_shitposts", Columns: []*schema.Column{ShitpostsColumns[3]}, RefColumns: []*schema.Column{UsersColumns[0]}, OnDelete: schema.SetNull, }, }, } // SigninsColumns holds the columns for the "signins" table. SigninsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "timestamp", Type: field.TypeTime}, {Name: "type", Type: field.TypeEnum, Enums: []string{"General Meeting", "Red Team", "Red Team Recruiting", "Reversing", "RVAPT", "Contagion", "Physical", "Wireless", "IR", "WiCyS", "Ops", "Ops IG", "Vulnerability Research", "Mentorship", "Other"}}, {Name: "user_signins", Type: field.TypeString}, } // SigninsTable holds the schema information for the "signins" table. SigninsTable = &schema.Table{ Name: "signins", Columns: SigninsColumns, PrimaryKey: []*schema.Column{SigninsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "signins_users_signins", Columns: []*schema.Column{SigninsColumns[3]}, RefColumns: []*schema.Column{UsersColumns[0]}, OnDelete: schema.NoAction, }, }, } // UsersColumns holds the columns for the "users" table. UsersColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, Unique: true}, {Name: "email", Type: field.TypeString, Default: ""}, {Name: "verification_attempts", Type: field.TypeInt8, Default: 0}, {Name: "verified", Type: field.TypeBool, Default: false}, } // UsersTable holds the schema information for the "users" table. UsersTable = &schema.Table{ Name: "users", Columns: UsersColumns, PrimaryKey: []*schema.Column{UsersColumns[0]}, } // VotesColumns holds the columns for the "votes" table. VotesColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "selection", Type: field.TypeString}, {Name: "rank", Type: field.TypeInt}, {Name: "vote_id", Type: field.TypeString}, {Name: "user_votes", Type: field.TypeString}, } // VotesTable holds the schema information for the "votes" table. VotesTable = &schema.Table{ Name: "votes", Columns: VotesColumns, PrimaryKey: []*schema.Column{VotesColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "votes_users_votes", Columns: []*schema.Column{VotesColumns[4]}, RefColumns: []*schema.Column{UsersColumns[0]}, OnDelete: schema.NoAction, }, }, } // VoteResultsColumns holds the columns for the "vote_results" table. VoteResultsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "html", Type: field.TypeString}, {Name: "plain", Type: field.TypeString}, {Name: "vote_id", Type: field.TypeString, Unique: true}, } // VoteResultsTable holds the schema information for the "vote_results" table. VoteResultsTable = &schema.Table{ Name: "vote_results", Columns: VoteResultsColumns, PrimaryKey: []*schema.Column{VoteResultsColumns[0]}, } // Tables holds all the tables in the schema. Tables = []*schema.Table{ BirthdaysTable, OpenstacksTable, ShitpostsTable, SigninsTable, UsersTable, VotesTable, VoteResultsTable, } )
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.