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 ( // ProjectsColumns holds the columns for the "projects" table. ProjectsColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID}, {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, {Name: "name", Type: field.TypeString, Unique: true}, } // ProjectsTable holds the schema information for the "projects" table. ProjectsTable = &schema.Table{ Name: "projects", Columns: ProjectsColumns, PrimaryKey: []*schema.Column{ProjectsColumns[0]}, Indexes: []*schema.Index{ { Name: "project_id", Unique: true, Columns: []*schema.Column{ProjectsColumns[0]}, }, }, } // RequestsColumns holds the columns for the "requests" table. RequestsColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID}, {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, {Name: "type", Type: field.TypeString}, {Name: "requested_by", Type: field.TypeString}, {Name: "status", Type: field.TypeEnum, Enums: []string{"pending_approval", "rejected", "approved"}, Default: "pending_approval"}, {Name: "spec", Type: field.TypeJSON}, {Name: "request_project", Type: field.TypeUUID}, {Name: "request_service", Type: field.TypeUUID}, } // RequestsTable holds the schema information for the "requests" table. RequestsTable = &schema.Table{ Name: "requests", Columns: RequestsColumns, PrimaryKey: []*schema.Column{RequestsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "requests_projects_Project", Columns: []*schema.Column{RequestsColumns[7]}, RefColumns: []*schema.Column{ProjectsColumns[0]}, OnDelete: schema.NoAction, }, { Symbol: "requests_services_Service", Columns: []*schema.Column{RequestsColumns[8]}, RefColumns: []*schema.Column{ServicesColumns[0]}, OnDelete: schema.NoAction, }, }, Indexes: []*schema.Index{ { Name: "request_id", Unique: true, Columns: []*schema.Column{RequestsColumns[0]}, }, }, } // ReviewsColumns holds the columns for the "reviews" table. ReviewsColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID}, {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, {Name: "status", Type: field.TypeEnum, Enums: []string{"reject", "approve"}}, {Name: "type", Type: field.TypeEnum, Enums: []string{"user", "auto"}, Default: "user"}, {Name: "review_request", Type: field.TypeUUID}, } // ReviewsTable holds the schema information for the "reviews" table. ReviewsTable = &schema.Table{ Name: "reviews", Columns: ReviewsColumns, PrimaryKey: []*schema.Column{ReviewsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "reviews_requests_Request", Columns: []*schema.Column{ReviewsColumns[5]}, RefColumns: []*schema.Column{RequestsColumns[0]}, OnDelete: schema.NoAction, }, }, Indexes: []*schema.Index{ { Name: "review_id", Unique: true, Columns: []*schema.Column{ReviewsColumns[0]}, }, }, } // ServicesColumns holds the columns for the "services" table. ServicesColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID}, {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, {Name: "name", Type: field.TypeString, Unique: true}, } // ServicesTable holds the schema information for the "services" table. ServicesTable = &schema.Table{ Name: "services", Columns: ServicesColumns, PrimaryKey: []*schema.Column{ServicesColumns[0]}, Indexes: []*schema.Index{ { Name: "service_id", Unique: true, Columns: []*schema.Column{ServicesColumns[0]}, }, }, } // Tables holds all the tables in the schema. Tables = []*schema.Table{ ProjectsTable, RequestsTable, ReviewsTable, ServicesTable, } )
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.