Documentation ¶
Index ¶
- Variables
- func Create(ctx context.Context, s *Schema, tables []*schema.Table, ...) error
- func Diff(ctx context.Context, url string, opts ...schema.MigrateOption) error
- func NamedDiff(ctx context.Context, url, name string, opts ...schema.MigrateOption) error
- type Schema
- func (s *Schema) Create(ctx context.Context, opts ...schema.MigrateOption) error
- func (s *Schema) Diff(ctx context.Context, opts ...schema.MigrateOption) error
- func (s *Schema) NamedDiff(ctx context.Context, name string, opts ...schema.MigrateOption) error
- func (s *Schema) WriteTo(ctx context.Context, w io.Writer, opts ...schema.MigrateOption) error
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 ( // CatalogsColumns holds the columns for the "catalogs" table. CatalogsColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, SchemaType: map[string]string{"mysql": "bigint", "postgres": "bigint", "sqlite3": "integer"}}, {Name: "name", Type: field.TypeString}, {Name: "description", Type: field.TypeString, Nullable: true}, {Name: "labels", Type: field.TypeJSON, Nullable: true}, {Name: "annotations", Type: field.TypeJSON, Nullable: true}, {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, {Name: "status", Type: field.TypeJSON, Nullable: true}, {Name: "type", Type: field.TypeString}, {Name: "source", Type: field.TypeString}, {Name: "sync", Type: field.TypeJSON, Nullable: true}, } // CatalogsTable holds the schema information for the "catalogs" table. CatalogsTable = &schema.Table{ Name: "catalogs", Columns: CatalogsColumns, PrimaryKey: []*schema.Column{CatalogsColumns[0]}, Indexes: []*schema.Index{ { Name: "catalog_name", Unique: true, Columns: []*schema.Column{CatalogsColumns[1]}, }, }, } // ConnectorsColumns holds the columns for the "connectors" table. ConnectorsColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, SchemaType: map[string]string{"mysql": "bigint", "postgres": "bigint", "sqlite3": "integer"}}, {Name: "name", Type: field.TypeString}, {Name: "description", Type: field.TypeString, Nullable: true}, {Name: "labels", Type: field.TypeJSON, Nullable: true}, {Name: "annotations", Type: field.TypeJSON, Nullable: true}, {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, {Name: "status", Type: field.TypeJSON, Nullable: true}, {Name: "category", Type: field.TypeString}, {Name: "type", Type: field.TypeString}, {Name: "config_version", Type: field.TypeString}, {Name: "config_data", Type: field.TypeOther, Nullable: true, SchemaType: map[string]string{"mysql": "blob", "postgres": "bytea", "sqlite3": "blob"}}, {Name: "enable_fin_ops", Type: field.TypeBool}, {Name: "fin_ops_custom_pricing", Type: field.TypeJSON, Nullable: true}, {Name: "project_id", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"mysql": "bigint", "postgres": "bigint", "sqlite3": "integer"}}, } // ConnectorsTable holds the schema information for the "connectors" table. ConnectorsTable = &schema.Table{ Name: "connectors", Columns: ConnectorsColumns, PrimaryKey: []*schema.Column{ConnectorsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "connectors_projects_connectors", Columns: []*schema.Column{ConnectorsColumns[14]}, RefColumns: []*schema.Column{ProjectsColumns[0]}, OnDelete: schema.Cascade, }, }, Indexes: []*schema.Index{ { Name: "connector_project_id_name", Unique: true, Columns: []*schema.Column{ConnectorsColumns[14], ConnectorsColumns[1]}, Annotation: &entsql.IndexAnnotation{ Where: "project_id IS NOT NULL", }, }, { Name: "connector_name", Unique: true, Columns: []*schema.Column{ConnectorsColumns[1]}, Annotation: &entsql.IndexAnnotation{ Where: "project_id IS NULL", }, }, }, } // CostReportsColumns holds the columns for the "cost_reports" table. CostReportsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "start_time", Type: field.TypeTime}, {Name: "end_time", Type: field.TypeTime}, {Name: "minutes", Type: field.TypeFloat64}, {Name: "name", Type: field.TypeString}, {Name: "fingerprint", Type: field.TypeString}, {Name: "cluster_name", Type: field.TypeString, Nullable: true}, {Name: "namespace", Type: field.TypeString, Nullable: true}, {Name: "node", Type: field.TypeString, Nullable: true}, {Name: "controller", Type: field.TypeString, Nullable: true}, {Name: "controller_kind", Type: field.TypeString, Nullable: true}, {Name: "pod", Type: field.TypeString, Nullable: true}, {Name: "container", Type: field.TypeString, Nullable: true}, {Name: "pvs", Type: field.TypeJSON}, {Name: "labels", Type: field.TypeJSON}, {Name: "total_cost", Type: field.TypeFloat64, Default: 0}, {Name: "currency", Type: field.TypeInt, Nullable: true}, {Name: "cpu_cost", Type: field.TypeFloat64, Default: 0}, {Name: "cpu_core_request", Type: field.TypeFloat64, Default: 0}, {Name: "gpu_cost", Type: field.TypeFloat64, Default: 0}, {Name: "gpu_count", Type: field.TypeFloat64, Default: 0}, {Name: "ram_cost", Type: field.TypeFloat64, Default: 0}, {Name: "ram_byte_request", Type: field.TypeFloat64, Default: 0}, {Name: "pv_cost", Type: field.TypeFloat64, Default: 0}, {Name: "pv_bytes", Type: field.TypeFloat64, Default: 0}, {Name: "load_balancer_cost", Type: field.TypeFloat64, Default: 0}, {Name: "cpu_core_usage_average", Type: field.TypeFloat64, Default: 0}, {Name: "cpu_core_usage_max", Type: field.TypeFloat64, Default: 0}, {Name: "ram_byte_usage_average", Type: field.TypeFloat64, Default: 0}, {Name: "ram_byte_usage_max", Type: field.TypeFloat64, Default: 0}, {Name: "connector_id", Type: field.TypeString, SchemaType: map[string]string{"mysql": "bigint", "postgres": "bigint", "sqlite3": "integer"}}, } // CostReportsTable holds the schema information for the "cost_reports" table. CostReportsTable = &schema.Table{ Name: "cost_reports", Columns: CostReportsColumns, PrimaryKey: []*schema.Column{CostReportsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "cost_reports_connectors_cost_reports", Columns: []*schema.Column{CostReportsColumns[30]}, RefColumns: []*schema.Column{ConnectorsColumns[0]}, OnDelete: schema.Cascade, }, }, Indexes: []*schema.Index{ { Name: "costreport_start_time_end_time_connector_id_fingerprint", Unique: true, Columns: []*schema.Column{CostReportsColumns[1], CostReportsColumns[2], CostReportsColumns[30], CostReportsColumns[5]}, }, }, } // DistributeLocksColumns holds the columns for the "distribute_locks" table. DistributeLocksColumns = []*schema.Column{ {Name: "id", Type: field.TypeString}, {Name: "expire_at", Type: field.TypeInt64}, {Name: "holder", Type: field.TypeString}, } // DistributeLocksTable holds the schema information for the "distribute_locks" table. DistributeLocksTable = &schema.Table{ Name: "distribute_locks", Columns: DistributeLocksColumns, PrimaryKey: []*schema.Column{DistributeLocksColumns[0]}, } // EnvironmentsColumns holds the columns for the "environments" table. EnvironmentsColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, SchemaType: map[string]string{"mysql": "bigint", "postgres": "bigint", "sqlite3": "integer"}}, {Name: "name", Type: field.TypeString}, {Name: "description", Type: field.TypeString, Nullable: true}, {Name: "labels", Type: field.TypeJSON, Nullable: true}, {Name: "annotations", Type: field.TypeJSON, Nullable: true}, {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, {Name: "project_id", Type: field.TypeString, SchemaType: map[string]string{"mysql": "bigint", "postgres": "bigint", "sqlite3": "integer"}}, } // EnvironmentsTable holds the schema information for the "environments" table. EnvironmentsTable = &schema.Table{ Name: "environments", Columns: EnvironmentsColumns, PrimaryKey: []*schema.Column{EnvironmentsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "environments_projects_environments", Columns: []*schema.Column{EnvironmentsColumns[7]}, RefColumns: []*schema.Column{ProjectsColumns[0]}, OnDelete: schema.Restrict, }, }, Indexes: []*schema.Index{ { Name: "environment_project_id_name", Unique: true, Columns: []*schema.Column{EnvironmentsColumns[7], EnvironmentsColumns[1]}, }, }, } // EnvironmentConnectorRelationshipsColumns holds the columns for the "environment_connector_relationships" table. EnvironmentConnectorRelationshipsColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, SchemaType: map[string]string{"mysql": "bigint", "postgres": "bigint", "sqlite3": "integer"}}, {Name: "create_time", Type: field.TypeTime}, {Name: "environment_id", Type: field.TypeString, SchemaType: map[string]string{"mysql": "bigint", "postgres": "bigint", "sqlite3": "integer"}}, {Name: "connector_id", Type: field.TypeString, SchemaType: map[string]string{"mysql": "bigint", "postgres": "bigint", "sqlite3": "integer"}}, } // EnvironmentConnectorRelationshipsTable holds the schema information for the "environment_connector_relationships" table. EnvironmentConnectorRelationshipsTable = &schema.Table{ Name: "environment_connector_relationships", Columns: EnvironmentConnectorRelationshipsColumns, PrimaryKey: []*schema.Column{EnvironmentConnectorRelationshipsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "environment_connector_relationships_environments_environment", Columns: []*schema.Column{EnvironmentConnectorRelationshipsColumns[2]}, RefColumns: []*schema.Column{EnvironmentsColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "environment_connector_relationships_connectors_connector", Columns: []*schema.Column{EnvironmentConnectorRelationshipsColumns[3]}, RefColumns: []*schema.Column{ConnectorsColumns[0]}, OnDelete: schema.Restrict, }, }, Indexes: []*schema.Index{ { Name: "environmentconnectorrelationship_create_time", Unique: false, Columns: []*schema.Column{EnvironmentConnectorRelationshipsColumns[1]}, }, { Name: "environmentconnectorrelationship_environment_id_connector_id", Unique: true, Columns: []*schema.Column{EnvironmentConnectorRelationshipsColumns[2], EnvironmentConnectorRelationshipsColumns[3]}, }, }, } // PerspectivesColumns holds the columns for the "perspectives" table. PerspectivesColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, SchemaType: map[string]string{"mysql": "bigint", "postgres": "bigint", "sqlite3": "integer"}}, {Name: "name", Type: field.TypeString}, {Name: "description", Type: field.TypeString, Nullable: true}, {Name: "labels", Type: field.TypeJSON, Nullable: true}, {Name: "annotations", Type: field.TypeJSON, Nullable: true}, {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, {Name: "start_time", Type: field.TypeString}, {Name: "end_time", Type: field.TypeString}, {Name: "builtin", Type: field.TypeBool, Default: false}, {Name: "cost_queries", Type: field.TypeJSON}, } // PerspectivesTable holds the schema information for the "perspectives" table. PerspectivesTable = &schema.Table{ Name: "perspectives", Columns: PerspectivesColumns, PrimaryKey: []*schema.Column{PerspectivesColumns[0]}, Indexes: []*schema.Index{ { Name: "perspective_name", Unique: true, Columns: []*schema.Column{PerspectivesColumns[1]}, }, }, } // ProjectsColumns holds the columns for the "projects" table. ProjectsColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, SchemaType: map[string]string{"mysql": "bigint", "postgres": "bigint", "sqlite3": "integer"}}, {Name: "name", Type: field.TypeString}, {Name: "description", Type: field.TypeString, Nullable: true}, {Name: "labels", Type: field.TypeJSON, Nullable: true}, {Name: "annotations", Type: field.TypeJSON, Nullable: true}, {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, } // 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_name", Unique: true, Columns: []*schema.Column{ProjectsColumns[1]}, }, }, } // RolesColumns holds the columns for the "roles" table. RolesColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, Unique: true}, {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, {Name: "kind", Type: field.TypeString, Default: "system"}, {Name: "description", Type: field.TypeString, Nullable: true}, {Name: "policies", Type: field.TypeJSON}, {Name: "session", Type: field.TypeBool, Default: false}, {Name: "builtin", Type: field.TypeBool, Default: false}, } // RolesTable holds the schema information for the "roles" table. RolesTable = &schema.Table{ Name: "roles", Columns: RolesColumns, PrimaryKey: []*schema.Column{RolesColumns[0]}, Indexes: []*schema.Index{ { Name: "role_create_time", Unique: false, Columns: []*schema.Column{RolesColumns[1]}, }, }, } // ServicesColumns holds the columns for the "services" table. ServicesColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, SchemaType: map[string]string{"mysql": "bigint", "postgres": "bigint", "sqlite3": "integer"}}, {Name: "name", Type: field.TypeString}, {Name: "description", Type: field.TypeString, Nullable: true}, {Name: "labels", Type: field.TypeJSON, Nullable: true}, {Name: "annotations", Type: field.TypeJSON, Nullable: true}, {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, {Name: "status", Type: field.TypeJSON, Nullable: true}, {Name: "attributes", Type: field.TypeOther, Nullable: true, SchemaType: map[string]string{"mysql": "json", "postgres": "jsonb", "sqlite3": "text"}}, {Name: "environment_id", Type: field.TypeString, SchemaType: map[string]string{"mysql": "bigint", "postgres": "bigint", "sqlite3": "integer"}}, {Name: "project_id", Type: field.TypeString, SchemaType: map[string]string{"mysql": "bigint", "postgres": "bigint", "sqlite3": "integer"}}, {Name: "template_id", Type: field.TypeString, SchemaType: map[string]string{"mysql": "bigint", "postgres": "bigint", "sqlite3": "integer"}}, } // ServicesTable holds the schema information for the "services" table. ServicesTable = &schema.Table{ Name: "services", Columns: ServicesColumns, PrimaryKey: []*schema.Column{ServicesColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "services_environments_services", Columns: []*schema.Column{ServicesColumns[9]}, RefColumns: []*schema.Column{EnvironmentsColumns[0]}, OnDelete: schema.Restrict, }, { Symbol: "services_projects_services", Columns: []*schema.Column{ServicesColumns[10]}, RefColumns: []*schema.Column{ProjectsColumns[0]}, OnDelete: schema.NoAction, }, { Symbol: "services_template_versions_services", Columns: []*schema.Column{ServicesColumns[11]}, RefColumns: []*schema.Column{TemplateVersionsColumns[0]}, OnDelete: schema.Restrict, }, }, Indexes: []*schema.Index{ { Name: "service_project_id_environment_id_name", Unique: true, Columns: []*schema.Column{ServicesColumns[10], ServicesColumns[9], ServicesColumns[1]}, }, }, } // ServiceRelationshipsColumns holds the columns for the "service_relationships" table. ServiceRelationshipsColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, SchemaType: map[string]string{"mysql": "bigint", "postgres": "bigint", "sqlite3": "integer"}}, {Name: "create_time", Type: field.TypeTime}, {Name: "path", Type: field.TypeJSON}, {Name: "type", Type: field.TypeString}, {Name: "service_id", Type: field.TypeString, SchemaType: map[string]string{"mysql": "bigint", "postgres": "bigint", "sqlite3": "integer"}}, {Name: "dependency_id", Type: field.TypeString, SchemaType: map[string]string{"mysql": "bigint", "postgres": "bigint", "sqlite3": "integer"}}, } // ServiceRelationshipsTable holds the schema information for the "service_relationships" table. ServiceRelationshipsTable = &schema.Table{ Name: "service_relationships", Columns: ServiceRelationshipsColumns, PrimaryKey: []*schema.Column{ServiceRelationshipsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "service_relationships_services_service", Columns: []*schema.Column{ServiceRelationshipsColumns[4]}, RefColumns: []*schema.Column{ServicesColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "service_relationships_services_dependency", Columns: []*schema.Column{ServiceRelationshipsColumns[5]}, RefColumns: []*schema.Column{ServicesColumns[0]}, OnDelete: schema.Restrict, }, }, Indexes: []*schema.Index{ { Name: "servicerelationship_create_time", Unique: false, Columns: []*schema.Column{ServiceRelationshipsColumns[1]}, }, { Name: "servicerelationship_service_id_dependency_id_path", Unique: true, Columns: []*schema.Column{ServiceRelationshipsColumns[4], ServiceRelationshipsColumns[5], ServiceRelationshipsColumns[2]}, }, }, } // ServiceResourcesColumns holds the columns for the "service_resources" table. ServiceResourcesColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, SchemaType: map[string]string{"mysql": "bigint", "postgres": "bigint", "sqlite3": "integer"}}, {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, {Name: "mode", Type: field.TypeString}, {Name: "type", Type: field.TypeString}, {Name: "name", Type: field.TypeString}, {Name: "deployer_type", Type: field.TypeString}, {Name: "shape", Type: field.TypeString}, {Name: "status", Type: field.TypeJSON, Nullable: true}, {Name: "connector_id", Type: field.TypeString, SchemaType: map[string]string{"mysql": "bigint", "postgres": "bigint", "sqlite3": "integer"}}, {Name: "environment_id", Type: field.TypeString, SchemaType: map[string]string{"mysql": "bigint", "postgres": "bigint", "sqlite3": "integer"}}, {Name: "project_id", Type: field.TypeString, SchemaType: map[string]string{"mysql": "bigint", "postgres": "bigint", "sqlite3": "integer"}}, {Name: "service_id", Type: field.TypeString, SchemaType: map[string]string{"mysql": "bigint", "postgres": "bigint", "sqlite3": "integer"}}, {Name: "composition_id", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"mysql": "bigint", "postgres": "bigint", "sqlite3": "integer"}}, {Name: "class_id", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"mysql": "bigint", "postgres": "bigint", "sqlite3": "integer"}}, } // ServiceResourcesTable holds the schema information for the "service_resources" table. ServiceResourcesTable = &schema.Table{ Name: "service_resources", Columns: ServiceResourcesColumns, PrimaryKey: []*schema.Column{ServiceResourcesColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "service_resources_connectors_resources", Columns: []*schema.Column{ServiceResourcesColumns[9]}, RefColumns: []*schema.Column{ConnectorsColumns[0]}, OnDelete: schema.Restrict, }, { Symbol: "service_resources_environments_service_resources", Columns: []*schema.Column{ServiceResourcesColumns[10]}, RefColumns: []*schema.Column{EnvironmentsColumns[0]}, OnDelete: schema.NoAction, }, { Symbol: "service_resources_projects_service_resources", Columns: []*schema.Column{ServiceResourcesColumns[11]}, RefColumns: []*schema.Column{ProjectsColumns[0]}, OnDelete: schema.NoAction, }, { Symbol: "service_resources_services_resources", Columns: []*schema.Column{ServiceResourcesColumns[12]}, RefColumns: []*schema.Column{ServicesColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "service_resources_service_resources_components", Columns: []*schema.Column{ServiceResourcesColumns[13]}, RefColumns: []*schema.Column{ServiceResourcesColumns[0]}, OnDelete: schema.SetNull, }, { Symbol: "service_resources_service_resources_instances", Columns: []*schema.Column{ServiceResourcesColumns[14]}, RefColumns: []*schema.Column{ServiceResourcesColumns[0]}, OnDelete: schema.SetNull, }, }, Indexes: []*schema.Index{ { Name: "serviceresource_create_time", Unique: false, Columns: []*schema.Column{ServiceResourcesColumns[1]}, }, }, } // ServiceResourceRelationshipsColumns holds the columns for the "service_resource_relationships" table. ServiceResourceRelationshipsColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, SchemaType: map[string]string{"mysql": "bigint", "postgres": "bigint", "sqlite3": "integer"}}, {Name: "create_time", Type: field.TypeTime}, {Name: "type", Type: field.TypeString}, {Name: "service_resource_id", Type: field.TypeString, SchemaType: map[string]string{"mysql": "bigint", "postgres": "bigint", "sqlite3": "integer"}}, {Name: "dependency_id", Type: field.TypeString, SchemaType: map[string]string{"mysql": "bigint", "postgres": "bigint", "sqlite3": "integer"}}, } // ServiceResourceRelationshipsTable holds the schema information for the "service_resource_relationships" table. ServiceResourceRelationshipsTable = &schema.Table{ Name: "service_resource_relationships", Columns: ServiceResourceRelationshipsColumns, PrimaryKey: []*schema.Column{ServiceResourceRelationshipsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "service_resource_relationships_service_resources_serviceResource", Columns: []*schema.Column{ServiceResourceRelationshipsColumns[3]}, RefColumns: []*schema.Column{ServiceResourcesColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "service_resource_relationships_service_resources_dependency", Columns: []*schema.Column{ServiceResourceRelationshipsColumns[4]}, RefColumns: []*schema.Column{ServiceResourcesColumns[0]}, OnDelete: schema.Cascade, }, }, Indexes: []*schema.Index{ { Name: "serviceresourcerelationship_create_time", Unique: false, Columns: []*schema.Column{ServiceResourceRelationshipsColumns[1]}, }, { Name: "serviceresourcerelationship_service_resource_id_dependency_id_type", Unique: true, Columns: []*schema.Column{ServiceResourceRelationshipsColumns[3], ServiceResourceRelationshipsColumns[4], ServiceResourceRelationshipsColumns[2]}, }, }, } // ServiceRevisionsColumns holds the columns for the "service_revisions" table. ServiceRevisionsColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, SchemaType: map[string]string{"mysql": "bigint", "postgres": "bigint", "sqlite3": "integer"}}, {Name: "create_time", Type: field.TypeTime}, {Name: "status", Type: field.TypeJSON, Nullable: true}, {Name: "template_name", Type: field.TypeString}, {Name: "template_version", Type: field.TypeString}, {Name: "attributes", Type: field.TypeOther, Nullable: true, SchemaType: map[string]string{"mysql": "json", "postgres": "jsonb", "sqlite3": "text"}}, {Name: "variables", Type: field.TypeOther, SchemaType: map[string]string{"mysql": "blob", "postgres": "bytea", "sqlite3": "blob"}}, {Name: "input_plan", Type: field.TypeString}, {Name: "output", Type: field.TypeString}, {Name: "deployer_type", Type: field.TypeString, Default: "Terraform"}, {Name: "duration", Type: field.TypeInt, Default: 0}, {Name: "previous_required_providers", Type: field.TypeJSON}, {Name: "record", Type: field.TypeString, Nullable: true, Size: 2147483647}, {Name: "environment_id", Type: field.TypeString, SchemaType: map[string]string{"mysql": "bigint", "postgres": "bigint", "sqlite3": "integer"}}, {Name: "project_id", Type: field.TypeString, SchemaType: map[string]string{"mysql": "bigint", "postgres": "bigint", "sqlite3": "integer"}}, {Name: "service_id", Type: field.TypeString, SchemaType: map[string]string{"mysql": "bigint", "postgres": "bigint", "sqlite3": "integer"}}, } // ServiceRevisionsTable holds the schema information for the "service_revisions" table. ServiceRevisionsTable = &schema.Table{ Name: "service_revisions", Columns: ServiceRevisionsColumns, PrimaryKey: []*schema.Column{ServiceRevisionsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "service_revisions_environments_service_revisions", Columns: []*schema.Column{ServiceRevisionsColumns[13]}, RefColumns: []*schema.Column{EnvironmentsColumns[0]}, OnDelete: schema.NoAction, }, { Symbol: "service_revisions_projects_service_revisions", Columns: []*schema.Column{ServiceRevisionsColumns[14]}, RefColumns: []*schema.Column{ProjectsColumns[0]}, OnDelete: schema.NoAction, }, { Symbol: "service_revisions_services_revisions", Columns: []*schema.Column{ServiceRevisionsColumns[15]}, RefColumns: []*schema.Column{ServicesColumns[0]}, OnDelete: schema.Cascade, }, }, Indexes: []*schema.Index{ { Name: "servicerevision_create_time", Unique: false, Columns: []*schema.Column{ServiceRevisionsColumns[1]}, }, }, } // SettingsColumns holds the columns for the "settings" table. SettingsColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, SchemaType: map[string]string{"mysql": "bigint", "postgres": "bigint", "sqlite3": "integer"}}, {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, {Name: "name", Type: field.TypeString}, {Name: "value", Type: field.TypeString, SchemaType: map[string]string{"mysql": "blob", "postgres": "bytea", "sqlite3": "blob"}}, {Name: "hidden", Type: field.TypeBool, Nullable: true, Default: false}, {Name: "editable", Type: field.TypeBool, Nullable: true, Default: false}, {Name: "sensitive", Type: field.TypeBool, Nullable: true, Default: false}, {Name: "private", Type: field.TypeBool, Nullable: true, Default: false}, } // SettingsTable holds the schema information for the "settings" table. SettingsTable = &schema.Table{ Name: "settings", Columns: SettingsColumns, PrimaryKey: []*schema.Column{SettingsColumns[0]}, Indexes: []*schema.Index{ { Name: "setting_create_time", Unique: false, Columns: []*schema.Column{SettingsColumns[1]}, }, { Name: "setting_name", Unique: true, Columns: []*schema.Column{SettingsColumns[3]}, }, }, } // SubjectsColumns holds the columns for the "subjects" table. SubjectsColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, SchemaType: map[string]string{"mysql": "bigint", "postgres": "bigint", "sqlite3": "integer"}}, {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, {Name: "kind", Type: field.TypeString, Default: "user"}, {Name: "domain", Type: field.TypeString, Default: "builtin"}, {Name: "name", Type: field.TypeString}, {Name: "description", Type: field.TypeString, Nullable: true}, {Name: "builtin", Type: field.TypeBool, Default: false}, } // SubjectsTable holds the schema information for the "subjects" table. SubjectsTable = &schema.Table{ Name: "subjects", Columns: SubjectsColumns, PrimaryKey: []*schema.Column{SubjectsColumns[0]}, Indexes: []*schema.Index{ { Name: "subject_create_time", Unique: false, Columns: []*schema.Column{SubjectsColumns[1]}, }, { Name: "subject_kind_domain_name", Unique: true, Columns: []*schema.Column{SubjectsColumns[3], SubjectsColumns[4], SubjectsColumns[5]}, }, }, } // SubjectRoleRelationshipsColumns holds the columns for the "subject_role_relationships" table. SubjectRoleRelationshipsColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, SchemaType: map[string]string{"mysql": "bigint", "postgres": "bigint", "sqlite3": "integer"}}, {Name: "create_time", Type: field.TypeTime}, {Name: "project_id", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"mysql": "bigint", "postgres": "bigint", "sqlite3": "integer"}}, {Name: "subject_id", Type: field.TypeString, SchemaType: map[string]string{"mysql": "bigint", "postgres": "bigint", "sqlite3": "integer"}}, {Name: "role_id", Type: field.TypeString}, } // SubjectRoleRelationshipsTable holds the schema information for the "subject_role_relationships" table. SubjectRoleRelationshipsTable = &schema.Table{ Name: "subject_role_relationships", Columns: SubjectRoleRelationshipsColumns, PrimaryKey: []*schema.Column{SubjectRoleRelationshipsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "subject_role_relationships_projects_subject_roles", Columns: []*schema.Column{SubjectRoleRelationshipsColumns[2]}, RefColumns: []*schema.Column{ProjectsColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "subject_role_relationships_subjects_subject", Columns: []*schema.Column{SubjectRoleRelationshipsColumns[3]}, RefColumns: []*schema.Column{SubjectsColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "subject_role_relationships_roles_role", Columns: []*schema.Column{SubjectRoleRelationshipsColumns[4]}, RefColumns: []*schema.Column{RolesColumns[0]}, OnDelete: schema.Restrict, }, }, Indexes: []*schema.Index{ { Name: "subjectrolerelationship_create_time", Unique: false, Columns: []*schema.Column{SubjectRoleRelationshipsColumns[1]}, }, { Name: "subjectrolerelationship_project_id_subject_id_role_id", Unique: true, Columns: []*schema.Column{SubjectRoleRelationshipsColumns[2], SubjectRoleRelationshipsColumns[3], SubjectRoleRelationshipsColumns[4]}, Annotation: &entsql.IndexAnnotation{ Where: "project_id IS NOT NULL", }, }, { Name: "subjectrolerelationship_subject_id_role_id", Unique: true, Columns: []*schema.Column{SubjectRoleRelationshipsColumns[3], SubjectRoleRelationshipsColumns[4]}, Annotation: &entsql.IndexAnnotation{ Where: "project_id IS NULL", }, }, }, } // TemplatesColumns holds the columns for the "templates" table. TemplatesColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, SchemaType: map[string]string{"mysql": "bigint", "postgres": "bigint", "sqlite3": "integer"}}, {Name: "name", Type: field.TypeString}, {Name: "description", Type: field.TypeString, Nullable: true}, {Name: "labels", Type: field.TypeJSON, Nullable: true}, {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, {Name: "status", Type: field.TypeJSON, Nullable: true}, {Name: "icon", Type: field.TypeString, Nullable: true}, {Name: "source", Type: field.TypeString}, {Name: "catalog_id", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"mysql": "bigint", "postgres": "bigint", "sqlite3": "integer"}}, } // TemplatesTable holds the schema information for the "templates" table. TemplatesTable = &schema.Table{ Name: "templates", Columns: TemplatesColumns, PrimaryKey: []*schema.Column{TemplatesColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "templates_catalogs_templates", Columns: []*schema.Column{TemplatesColumns[9]}, RefColumns: []*schema.Column{CatalogsColumns[0]}, OnDelete: schema.Cascade, }, }, Indexes: []*schema.Index{ { Name: "template_name", Unique: true, Columns: []*schema.Column{TemplatesColumns[1]}, }, }, } // TemplateVersionsColumns holds the columns for the "template_versions" table. TemplateVersionsColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, SchemaType: map[string]string{"mysql": "bigint", "postgres": "bigint", "sqlite3": "integer"}}, {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, {Name: "name", Type: field.TypeString}, {Name: "version", Type: field.TypeString}, {Name: "source", Type: field.TypeString}, {Name: "schema", Type: field.TypeJSON}, {Name: "template_id", Type: field.TypeString, SchemaType: map[string]string{"mysql": "bigint", "postgres": "bigint", "sqlite3": "integer"}}, } // TemplateVersionsTable holds the schema information for the "template_versions" table. TemplateVersionsTable = &schema.Table{ Name: "template_versions", Columns: TemplateVersionsColumns, PrimaryKey: []*schema.Column{TemplateVersionsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "template_versions_templates_versions", Columns: []*schema.Column{TemplateVersionsColumns[7]}, RefColumns: []*schema.Column{TemplatesColumns[0]}, OnDelete: schema.Cascade, }, }, Indexes: []*schema.Index{ { Name: "templateversion_create_time", Unique: false, Columns: []*schema.Column{TemplateVersionsColumns[1]}, }, { Name: "templateversion_name_version", Unique: true, Columns: []*schema.Column{TemplateVersionsColumns[3], TemplateVersionsColumns[4]}, }, }, } // TokensColumns holds the columns for the "tokens" table. TokensColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, SchemaType: map[string]string{"mysql": "bigint", "postgres": "bigint", "sqlite3": "integer"}}, {Name: "create_time", Type: field.TypeTime}, {Name: "kind", Type: field.TypeString, Default: "api"}, {Name: "name", Type: field.TypeString}, {Name: "expiration", Type: field.TypeTime, Nullable: true}, {Name: "value", Type: field.TypeString, SchemaType: map[string]string{"mysql": "blob", "postgres": "bytea", "sqlite3": "blob"}}, {Name: "subject_id", Type: field.TypeString, SchemaType: map[string]string{"mysql": "bigint", "postgres": "bigint", "sqlite3": "integer"}}, } // TokensTable holds the schema information for the "tokens" table. TokensTable = &schema.Table{ Name: "tokens", Columns: TokensColumns, PrimaryKey: []*schema.Column{TokensColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "tokens_subjects_tokens", Columns: []*schema.Column{TokensColumns[6]}, RefColumns: []*schema.Column{SubjectsColumns[0]}, OnDelete: schema.Cascade, }, }, Indexes: []*schema.Index{ { Name: "token_create_time", Unique: false, Columns: []*schema.Column{TokensColumns[1]}, }, }, } // VariablesColumns holds the columns for the "variables" table. VariablesColumns = []*schema.Column{ {Name: "id", Type: field.TypeString, SchemaType: map[string]string{"mysql": "bigint", "postgres": "bigint", "sqlite3": "integer"}}, {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, {Name: "name", Type: field.TypeString}, {Name: "value", Type: field.TypeString, SchemaType: map[string]string{"mysql": "blob", "postgres": "bytea", "sqlite3": "blob"}}, {Name: "sensitive", Type: field.TypeBool, Default: false}, {Name: "description", Type: field.TypeString, Nullable: true}, {Name: "environment_id", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"mysql": "bigint", "postgres": "bigint", "sqlite3": "integer"}}, {Name: "project_id", Type: field.TypeString, Nullable: true, SchemaType: map[string]string{"mysql": "bigint", "postgres": "bigint", "sqlite3": "integer"}}, } // VariablesTable holds the schema information for the "variables" table. VariablesTable = &schema.Table{ Name: "variables", Columns: VariablesColumns, PrimaryKey: []*schema.Column{VariablesColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "variables_environments_variables", Columns: []*schema.Column{VariablesColumns[7]}, RefColumns: []*schema.Column{EnvironmentsColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "variables_projects_variables", Columns: []*schema.Column{VariablesColumns[8]}, RefColumns: []*schema.Column{ProjectsColumns[0]}, OnDelete: schema.Cascade, }, }, Indexes: []*schema.Index{ { Name: "variable_create_time", Unique: false, Columns: []*schema.Column{VariablesColumns[1]}, }, { Name: "variable_project_id_environment_id_name", Unique: true, Columns: []*schema.Column{VariablesColumns[8], VariablesColumns[7], VariablesColumns[3]}, Annotation: &entsql.IndexAnnotation{ Where: "project_id IS NOT NULL and environment_id IS NOT NULL", }, }, { Name: "variable_project_id_name", Unique: true, Columns: []*schema.Column{VariablesColumns[8], VariablesColumns[3]}, Annotation: &entsql.IndexAnnotation{ Where: "project_id IS NOT NULL AND environment_id IS NULL", }, }, { Name: "variable_name", Unique: true, Columns: []*schema.Column{VariablesColumns[3]}, Annotation: &entsql.IndexAnnotation{ Where: "project_id IS NULL AND environment_id IS NULL", }, }, }, } // Tables holds all the tables in the schema. Tables = []*schema.Table{ CatalogsTable, ConnectorsTable, CostReportsTable, DistributeLocksTable, EnvironmentsTable, EnvironmentConnectorRelationshipsTable, PerspectivesTable, ProjectsTable, RolesTable, ServicesTable, ServiceRelationshipsTable, ServiceResourcesTable, ServiceResourceRelationshipsTable, ServiceRevisionsTable, SettingsTable, SubjectsTable, SubjectRoleRelationshipsTable, TemplatesTable, TemplateVersionsTable, TokensTable, VariablesTable, } )
Functions ¶
func Create ¶
func Create(ctx context.Context, s *Schema, tables []*schema.Table, opts ...schema.MigrateOption) error
Create creates all table resources using the given schema driver.
Types ¶
type Schema ¶
type Schema struct {
// contains filtered or unexported fields
}
Schema is the API for creating, migrating and dropping a schema.
func (*Schema) Diff ¶
Diff creates a migration file containing the statements to resolve the diff between the Ent schema and the connected database.
func (*Schema) NamedDiff ¶
NamedDiff creates a named migration file containing the statements to resolve the diff between the Ent schema and the connected database.
Click to show internal directories.
Click to hide internal directories.