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 ( // BlocksColumns holds the columns for the "blocks" table. BlocksColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "block_reports", Type: field.TypeInt, Default: 0}, {Name: "unblock_reports", Type: field.TypeInt, Default: 0}, {Name: "last_reported_at", Type: field.TypeTime}, {Name: "isp_id", Type: field.TypeInt}, {Name: "site_id", Type: field.TypeInt}, } // BlocksTable holds the schema information for the "blocks" table. BlocksTable = &schema.Table{ Name: "blocks", Columns: BlocksColumns, PrimaryKey: []*schema.Column{BlocksColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "blocks_isps_isp_blocks", Columns: []*schema.Column{BlocksColumns[6]}, RefColumns: []*schema.Column{IspsColumns[0]}, OnDelete: schema.NoAction, }, { Symbol: "blocks_sites_blocks", Columns: []*schema.Column{BlocksColumns[7]}, RefColumns: []*schema.Column{SitesColumns[0]}, OnDelete: schema.NoAction, }, }, Indexes: []*schema.Index{ { Name: "blocks_site_id_isp_id", Unique: true, Columns: []*schema.Column{BlocksColumns[7], BlocksColumns[6]}, }, }, } // CategoriesColumns holds the columns for the "categories" table. CategoriesColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {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]}, Indexes: []*schema.Index{ { Name: "categories_name", Unique: true, Columns: []*schema.Column{CategoriesColumns[3]}, }, }, } // CountersColumns holds the columns for the "counters" table. CountersColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "count", Type: field.TypeInt, Default: 0}, } // CountersTable holds the schema information for the "counters" table. CountersTable = &schema.Table{ Name: "counters", Columns: CountersColumns, PrimaryKey: []*schema.Column{CountersColumns[0]}, } // IspsColumns holds the columns for the "isps" table. IspsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "latitude", Type: field.TypeFloat64}, {Name: "longitude", Type: field.TypeFloat64}, {Name: "name", Type: field.TypeString}, } // IspsTable holds the schema information for the "isps" table. IspsTable = &schema.Table{ Name: "isps", Columns: IspsColumns, PrimaryKey: []*schema.Column{IspsColumns[0]}, } // SitesColumns holds the columns for the "sites" table. SitesColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "domain", Type: field.TypeString, Unique: true}, } // SitesTable holds the schema information for the "sites" table. SitesTable = &schema.Table{ Name: "sites", Columns: SitesColumns, PrimaryKey: []*schema.Column{SitesColumns[0]}, Indexes: []*schema.Index{ { Name: "sites_domain", Unique: true, Columns: []*schema.Column{SitesColumns[3]}, }, }, } // SitesCategoriesColumns holds the columns for the "sites_categories" table. SitesCategoriesColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "sites_id", Type: field.TypeInt}, {Name: "categories_id", Type: field.TypeInt}, } // SitesCategoriesTable holds the schema information for the "sites_categories" table. SitesCategoriesTable = &schema.Table{ Name: "sites_categories", Columns: SitesCategoriesColumns, PrimaryKey: []*schema.Column{SitesCategoriesColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "sites_categories_sites_sites", Columns: []*schema.Column{SitesCategoriesColumns[1]}, RefColumns: []*schema.Column{SitesColumns[0]}, OnDelete: schema.NoAction, }, { Symbol: "sites_categories_categories_categories", Columns: []*schema.Column{SitesCategoriesColumns[2]}, RefColumns: []*schema.Column{CategoriesColumns[0]}, OnDelete: schema.NoAction, }, }, Indexes: []*schema.Index{ { Name: "sitescategories_sites_id_categories_id", Unique: true, Columns: []*schema.Column{SitesCategoriesColumns[1], SitesCategoriesColumns[2]}, }, }, } // Tables holds all the tables in the schema. Tables = []*schema.Table{ BlocksTable, CategoriesTable, CountersTable, IspsTable, SitesTable, SitesCategoriesTable, } )
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.