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 ( // BootstrapFlagColumns holds the columns for the "bootstrap_flag" table. BootstrapFlagColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "is_bootstrapped", Type: field.TypeBool}, } // BootstrapFlagTable holds the schema information for the "bootstrap_flag" table. BootstrapFlagTable = &schema.Table{ Name: "bootstrap_flag", Columns: BootstrapFlagColumns, PrimaryKey: []*schema.Column{BootstrapFlagColumns[0]}, } // DeploymentsColumns holds the columns for the "deployments" table. DeploymentsColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID, Unique: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "status", Type: field.TypeEnum, Enums: []string{"build-pending", "build-queued", "build-running", "build-succeeded", "build-cancelled", "build-failed", "active", "launching", "launch-error", "crashing", "removed"}}, {Name: "source", Type: field.TypeEnum, Enums: []string{"manual", "git"}, Default: "manual"}, {Name: "error", Type: field.TypeString, Nullable: true}, {Name: "commit_sha", Type: field.TypeString, Nullable: true}, {Name: "commit_message", Type: field.TypeString, Nullable: true}, {Name: "commit_author", Type: field.TypeJSON, Nullable: true}, {Name: "queued_at", Type: field.TypeTime, Nullable: true}, {Name: "started_at", Type: field.TypeTime, Nullable: true}, {Name: "completed_at", Type: field.TypeTime, Nullable: true}, {Name: "kubernetes_job_name", Type: field.TypeString, Nullable: true}, {Name: "kubernetes_job_status", Type: field.TypeString, Nullable: true}, {Name: "attempts", Type: field.TypeInt, Default: 0}, {Name: "image", Type: field.TypeString, Nullable: true}, {Name: "resource_definition", Type: field.TypeJSON, Nullable: true}, {Name: "service_id", Type: field.TypeUUID}, } // DeploymentsTable holds the schema information for the "deployments" table. DeploymentsTable = &schema.Table{ Name: "deployments", Columns: DeploymentsColumns, PrimaryKey: []*schema.Column{DeploymentsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "deployments_services_deployments", Columns: []*schema.Column{DeploymentsColumns[17]}, RefColumns: []*schema.Column{ServicesColumns[0]}, OnDelete: schema.Cascade, }, }, Indexes: []*schema.Index{ { Name: "deployment_service_id", Unique: false, Columns: []*schema.Column{DeploymentsColumns[17]}, }, { Name: "deployment_created_at", Unique: false, Columns: []*schema.Column{DeploymentsColumns[1]}, }, { Name: "deployment_service_id_created_at", Unique: false, Columns: []*schema.Column{DeploymentsColumns[17], DeploymentsColumns[1]}, }, { Name: "deployment_service_id_status_created_at", Unique: false, Columns: []*schema.Column{DeploymentsColumns[17], DeploymentsColumns[3], DeploymentsColumns[1]}, }, }, } // EnvironmentsColumns holds the columns for the "environments" table. EnvironmentsColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID, Unique: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "kubernetes_name", Type: field.TypeString, Unique: true}, {Name: "name", Type: field.TypeString}, {Name: "description", Type: field.TypeString, Nullable: true}, {Name: "active", Type: field.TypeBool, Default: true}, {Name: "kubernetes_secret", Type: field.TypeString}, {Name: "project_id", Type: field.TypeUUID}, } // 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[8]}, RefColumns: []*schema.Column{ProjectsColumns[0]}, OnDelete: schema.Cascade, }, }, } // GithubAppsColumns holds the columns for the "github_apps" table. GithubAppsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt64, Increment: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "uuid", Type: field.TypeUUID, Unique: true}, {Name: "name", Type: field.TypeString}, {Name: "client_id", Type: field.TypeString}, {Name: "client_secret", Type: field.TypeString}, {Name: "webhook_secret", Type: field.TypeString}, {Name: "private_key", Type: field.TypeString, Size: 2147483647}, {Name: "created_by", Type: field.TypeUUID}, } // GithubAppsTable holds the schema information for the "github_apps" table. GithubAppsTable = &schema.Table{ Name: "github_apps", Columns: GithubAppsColumns, PrimaryKey: []*schema.Column{GithubAppsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "github_apps_users_created_by", Columns: []*schema.Column{GithubAppsColumns[9]}, RefColumns: []*schema.Column{UsersColumns[0]}, OnDelete: schema.Cascade, }, }, } // GithubInstallationsColumns holds the columns for the "github_installations" table. GithubInstallationsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt64, Increment: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "account_id", Type: field.TypeInt64}, {Name: "account_login", Type: field.TypeString}, {Name: "account_type", Type: field.TypeEnum, Enums: []string{"Organization", "User"}}, {Name: "account_url", Type: field.TypeString}, {Name: "repository_selection", Type: field.TypeEnum, Enums: []string{"all", "selected"}, Default: "all"}, {Name: "suspended", Type: field.TypeBool, Default: false}, {Name: "active", Type: field.TypeBool, Default: true}, {Name: "permissions", Type: field.TypeJSON, Nullable: true}, {Name: "events", Type: field.TypeJSON, Nullable: true}, {Name: "github_app_id", Type: field.TypeInt64}, } // GithubInstallationsTable holds the schema information for the "github_installations" table. GithubInstallationsTable = &schema.Table{ Name: "github_installations", Columns: GithubInstallationsColumns, PrimaryKey: []*schema.Column{GithubInstallationsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "github_installations_github_apps_installations", Columns: []*schema.Column{GithubInstallationsColumns[12]}, RefColumns: []*schema.Column{GithubAppsColumns[0]}, OnDelete: schema.Cascade, }, }, Indexes: []*schema.Index{ { Name: "githubinstallation_github_app_id", Unique: true, Columns: []*schema.Column{GithubInstallationsColumns[12]}, }, }, } // GroupsColumns holds the columns for the "groups" table. GroupsColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID, Unique: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "name", Type: field.TypeString}, {Name: "description", Type: field.TypeString, Nullable: true}, {Name: "k8s_role_name", Type: field.TypeString, Nullable: true}, } // GroupsTable holds the schema information for the "groups" table. GroupsTable = &schema.Table{ Name: "groups", Columns: GroupsColumns, PrimaryKey: []*schema.Column{GroupsColumns[0]}, } // JwtKeysColumns holds the columns for the "jwt_keys" table. JwtKeysColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "label", Type: field.TypeString}, {Name: "private_key", Type: field.TypeBytes}, } // JwtKeysTable holds the schema information for the "jwt_keys" table. JwtKeysTable = &schema.Table{ Name: "jwt_keys", Columns: JwtKeysColumns, PrimaryKey: []*schema.Column{JwtKeysColumns[0]}, } // Oauth2CodesColumns holds the columns for the "oauth2_codes" table. Oauth2CodesColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID, Unique: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "auth_code", Type: field.TypeString, Unique: true}, {Name: "client_id", Type: field.TypeString}, {Name: "scope", Type: field.TypeString}, {Name: "expires_at", Type: field.TypeTime}, {Name: "revoked", Type: field.TypeBool, Default: false}, {Name: "user_oauth2_codes", Type: field.TypeUUID}, } // Oauth2CodesTable holds the schema information for the "oauth2_codes" table. Oauth2CodesTable = &schema.Table{ Name: "oauth2_codes", Columns: Oauth2CodesColumns, PrimaryKey: []*schema.Column{Oauth2CodesColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "oauth2_codes_users_oauth2_codes", Columns: []*schema.Column{Oauth2CodesColumns[8]}, RefColumns: []*schema.Column{UsersColumns[0]}, OnDelete: schema.NoAction, }, }, } // Oauth2TokensColumns holds the columns for the "oauth2_tokens" table. Oauth2TokensColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID, Unique: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "access_token", Type: field.TypeString, Unique: true}, {Name: "refresh_token", Type: field.TypeString, Unique: true}, {Name: "client_id", Type: field.TypeString}, {Name: "expires_at", Type: field.TypeTime}, {Name: "revoked", Type: field.TypeBool, Default: false}, {Name: "scope", Type: field.TypeString}, {Name: "device_info", Type: field.TypeString, Nullable: true}, {Name: "user_oauth2_tokens", Type: field.TypeUUID}, } // Oauth2TokensTable holds the schema information for the "oauth2_tokens" table. Oauth2TokensTable = &schema.Table{ Name: "oauth2_tokens", Columns: Oauth2TokensColumns, PrimaryKey: []*schema.Column{Oauth2TokensColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "oauth2_tokens_users_oauth2_tokens", Columns: []*schema.Column{Oauth2TokensColumns[10]}, RefColumns: []*schema.Column{UsersColumns[0]}, OnDelete: schema.NoAction, }, }, } // PvcMetadataColumns holds the columns for the "pvc_metadata" table. PvcMetadataColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID, Unique: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "pvc_id", Type: field.TypeString, Unique: true}, {Name: "name", Type: field.TypeString, Nullable: true}, {Name: "description", Type: field.TypeString, Nullable: true}, } // PvcMetadataTable holds the schema information for the "pvc_metadata" table. PvcMetadataTable = &schema.Table{ Name: "pvc_metadata", Columns: PvcMetadataColumns, PrimaryKey: []*schema.Column{PvcMetadataColumns[0]}, } // PermissionsColumns holds the columns for the "permissions" table. PermissionsColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID, Unique: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "action", Type: field.TypeEnum, Enums: []string{"admin", "edit", "view"}}, {Name: "resource_type", Type: field.TypeEnum, Enums: []string{"system", "team", "project", "environment", "service"}}, {Name: "resource_selector", Type: field.TypeJSON}, } // PermissionsTable holds the schema information for the "permissions" table. PermissionsTable = &schema.Table{ Name: "permissions", Columns: PermissionsColumns, PrimaryKey: []*schema.Column{PermissionsColumns[0]}, } // ProjectsColumns holds the columns for the "projects" table. ProjectsColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID, Unique: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "kubernetes_name", Type: field.TypeString, Unique: true}, {Name: "name", Type: field.TypeString}, {Name: "description", Type: field.TypeString, Nullable: true}, {Name: "status", Type: field.TypeString, Default: "active"}, {Name: "kubernetes_secret", Type: field.TypeString}, {Name: "default_environment_id", Type: field.TypeUUID, Nullable: true}, {Name: "team_id", Type: field.TypeUUID}, } // ProjectsTable holds the schema information for the "projects" table. ProjectsTable = &schema.Table{ Name: "projects", Columns: ProjectsColumns, PrimaryKey: []*schema.Column{ProjectsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "projects_environments_project_default", Columns: []*schema.Column{ProjectsColumns[8]}, RefColumns: []*schema.Column{EnvironmentsColumns[0]}, OnDelete: schema.SetNull, }, { Symbol: "projects_teams_projects", Columns: []*schema.Column{ProjectsColumns[9]}, RefColumns: []*schema.Column{TeamsColumns[0]}, OnDelete: schema.NoAction, }, }, } // RegistriesColumns holds the columns for the "registries" table. RegistriesColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID, Unique: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "host", Type: field.TypeString}, {Name: "kubernetes_secret", Type: field.TypeString}, {Name: "is_default", Type: field.TypeBool}, } // RegistriesTable holds the schema information for the "registries" table. RegistriesTable = &schema.Table{ Name: "registries", Columns: RegistriesColumns, PrimaryKey: []*schema.Column{RegistriesColumns[0]}, } // S3SourcesColumns holds the columns for the "s3_sources" table. S3SourcesColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID, Unique: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "name", Type: field.TypeString}, {Name: "endpoint", Type: field.TypeString}, {Name: "region", Type: field.TypeString}, {Name: "force_path_style", Type: field.TypeBool, Default: true}, {Name: "kubernetes_secret", Type: field.TypeString}, {Name: "team_id", Type: field.TypeUUID}, } // S3SourcesTable holds the schema information for the "s3_sources" table. S3SourcesTable = &schema.Table{ Name: "s3_sources", Columns: S3SourcesColumns, PrimaryKey: []*schema.Column{S3SourcesColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "s3_sources_teams_s3_sources", Columns: []*schema.Column{S3SourcesColumns[8]}, RefColumns: []*schema.Column{TeamsColumns[0]}, OnDelete: schema.NoAction, }, }, } // ServicesColumns holds the columns for the "services" table. ServicesColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID, Unique: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "type", Type: field.TypeEnum, Enums: []string{"github", "docker-image", "database"}}, {Name: "kubernetes_name", Type: field.TypeString, Unique: true}, {Name: "name", Type: field.TypeString}, {Name: "description", Type: field.TypeString, Nullable: true}, {Name: "detected_ports", Type: field.TypeJSON, Nullable: true}, {Name: "database", Type: field.TypeString, Nullable: true}, {Name: "database_version", Type: field.TypeString, Nullable: true}, {Name: "git_repository_owner", Type: field.TypeString, Nullable: true}, {Name: "git_repository", Type: field.TypeString, Nullable: true}, {Name: "kubernetes_secret", Type: field.TypeString}, {Name: "template_instance_id", Type: field.TypeUUID, Nullable: true}, {Name: "environment_id", Type: field.TypeUUID}, {Name: "github_installation_id", Type: field.TypeInt64, Nullable: true}, {Name: "current_deployment_id", Type: field.TypeUUID, Nullable: true}, {Name: "service_group_id", Type: field.TypeUUID, Nullable: true}, {Name: "template_id", Type: field.TypeUUID, Nullable: true}, } // 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[14]}, RefColumns: []*schema.Column{EnvironmentsColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "services_github_installations_services", Columns: []*schema.Column{ServicesColumns[15]}, RefColumns: []*schema.Column{GithubInstallationsColumns[0]}, OnDelete: schema.SetNull, }, { Symbol: "services_deployments_current_deployment", Columns: []*schema.Column{ServicesColumns[16]}, RefColumns: []*schema.Column{DeploymentsColumns[0]}, OnDelete: schema.SetNull, }, { Symbol: "services_service_groups_services", Columns: []*schema.Column{ServicesColumns[17]}, RefColumns: []*schema.Column{ServiceGroupsColumns[0]}, OnDelete: schema.SetNull, }, { Symbol: "services_templates_services", Columns: []*schema.Column{ServicesColumns[18]}, RefColumns: []*schema.Column{TemplatesColumns[0]}, OnDelete: schema.SetNull, }, }, Indexes: []*schema.Index{ { Name: "service_environment_id_created_at", Unique: false, Columns: []*schema.Column{ServicesColumns[14], ServicesColumns[1]}, }, { Name: "service_service_group_id_created_at", Unique: false, Columns: []*schema.Column{ServicesColumns[17], ServicesColumns[1]}, }, { Name: "service_created_at", Unique: false, Columns: []*schema.Column{ServicesColumns[1]}, }, }, } // ServiceConfigsColumns holds the columns for the "service_configs" table. ServiceConfigsColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID, Unique: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "builder", Type: field.TypeEnum, Enums: []string{"railpack", "docker", "database"}}, {Name: "icon", Type: field.TypeString}, {Name: "docker_builder_dockerfile_path", Type: field.TypeString, Nullable: true}, {Name: "docker_builder_build_context", Type: field.TypeString, Nullable: true}, {Name: "railpack_provider", Type: field.TypeEnum, Nullable: true, Enums: []string{"node", "deno", "bun", "go", "java", "php", "python", "ruby", "rust", "elixir", "staticfile", "unknown"}}, {Name: "railpack_framework", Type: field.TypeEnum, Nullable: true, Enums: []string{"next", "astro", "vite", "cra", "angular", "remix", "bun", "express", "sveltekit", "svelte", "solid", "hono", "tanstack-start", "python", "django", "flask", "fastapi", "fasthtml", "gin", "spring-boot", "laravel", "rails", "rocket", "unknown"}}, {Name: "git_branch", Type: field.TypeString, Nullable: true}, {Name: "git_tag", Type: field.TypeString, Nullable: true}, {Name: "hosts", Type: field.TypeJSON, Nullable: true}, {Name: "ports", Type: field.TypeJSON, Nullable: true}, {Name: "replicas", Type: field.TypeInt32, Default: 1}, {Name: "auto_deploy", Type: field.TypeBool, Default: false}, {Name: "railpack_builder_install_command", Type: field.TypeString, Nullable: true}, {Name: "railpack_builder_build_command", Type: field.TypeString, Nullable: true}, {Name: "run_command", Type: field.TypeString, Nullable: true}, {Name: "is_public", Type: field.TypeBool, Default: false}, {Name: "image", Type: field.TypeString, Nullable: true}, {Name: "definition_version", Type: field.TypeString, Nullable: true}, {Name: "database_config", Type: field.TypeJSON, Nullable: true}, {Name: "s3_backup_bucket", Type: field.TypeString, Nullable: true}, {Name: "backup_schedule", Type: field.TypeString, Default: "5 5 * * *"}, {Name: "backup_retention_count", Type: field.TypeInt, Default: 3}, {Name: "volumes", Type: field.TypeJSON, Nullable: true}, {Name: "security_context", Type: field.TypeJSON, Nullable: true}, {Name: "health_check", Type: field.TypeJSON, Nullable: true}, {Name: "variable_mounts", Type: field.TypeJSON, Nullable: true}, {Name: "protected_variables", Type: field.TypeJSON, Nullable: true}, {Name: "init_containers", Type: field.TypeJSON, Nullable: true}, {Name: "resources", Type: field.TypeJSON, Nullable: true}, {Name: "s3_backup_source_id", Type: field.TypeUUID, Nullable: true}, {Name: "service_id", Type: field.TypeUUID, Unique: true}, } // ServiceConfigsTable holds the schema information for the "service_configs" table. ServiceConfigsTable = &schema.Table{ Name: "service_configs", Columns: ServiceConfigsColumns, PrimaryKey: []*schema.Column{ServiceConfigsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "service_configs_s3_sources_service_backup_source", Columns: []*schema.Column{ServiceConfigsColumns[32]}, RefColumns: []*schema.Column{S3SourcesColumns[0]}, OnDelete: schema.SetNull, }, { Symbol: "service_configs_services_service_config", Columns: []*schema.Column{ServiceConfigsColumns[33]}, RefColumns: []*schema.Column{ServicesColumns[0]}, OnDelete: schema.Cascade, }, }, } // ServiceGroupsColumns holds the columns for the "service_groups" table. ServiceGroupsColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID, Unique: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "name", Type: field.TypeString}, {Name: "icon", Type: field.TypeString, Nullable: true}, {Name: "description", Type: field.TypeString, Nullable: true}, {Name: "environment_id", Type: field.TypeUUID}, } // ServiceGroupsTable holds the schema information for the "service_groups" table. ServiceGroupsTable = &schema.Table{ Name: "service_groups", Columns: ServiceGroupsColumns, PrimaryKey: []*schema.Column{ServiceGroupsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "service_groups_environments_service_groups", Columns: []*schema.Column{ServiceGroupsColumns[6]}, RefColumns: []*schema.Column{EnvironmentsColumns[0]}, OnDelete: schema.NoAction, }, }, } // SystemSettingsColumns holds the columns for the "system_settings" table. SystemSettingsColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID, Unique: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "wildcard_base_url", Type: field.TypeString, Nullable: true}, {Name: "buildkit_settings", Type: field.TypeJSON, Nullable: true}, } // SystemSettingsTable holds the schema information for the "system_settings" table. SystemSettingsTable = &schema.Table{ Name: "system_settings", Columns: SystemSettingsColumns, PrimaryKey: []*schema.Column{SystemSettingsColumns[0]}, } // TeamsColumns holds the columns for the "teams" table. TeamsColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID, Unique: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "kubernetes_name", Type: field.TypeString, Unique: true}, {Name: "name", Type: field.TypeString}, {Name: "namespace", Type: field.TypeString, Unique: true}, {Name: "kubernetes_secret", Type: field.TypeString}, {Name: "description", Type: field.TypeString, Nullable: true}, } // TeamsTable holds the schema information for the "teams" table. TeamsTable = &schema.Table{ Name: "teams", Columns: TeamsColumns, PrimaryKey: []*schema.Column{TeamsColumns[0]}, } // TemplatesColumns holds the columns for the "templates" table. TemplatesColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID, Unique: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "name", Type: field.TypeString}, {Name: "description", Type: field.TypeString}, {Name: "icon", Type: field.TypeString}, {Name: "keywords", Type: field.TypeJSON, Nullable: true}, {Name: "resource_recommendations", Type: field.TypeJSON}, {Name: "display_rank", Type: field.TypeUint, Default: 0}, {Name: "version", Type: field.TypeInt}, {Name: "immutable", Type: field.TypeBool, Default: false}, {Name: "definition", Type: field.TypeJSON}, } // TemplatesTable holds the schema information for the "templates" table. TemplatesTable = &schema.Table{ Name: "templates", Columns: TemplatesColumns, PrimaryKey: []*schema.Column{TemplatesColumns[0]}, Indexes: []*schema.Index{ { Name: "template_name_version", Unique: true, Columns: []*schema.Column{TemplatesColumns[3], TemplatesColumns[9]}, }, }, } // UsersColumns holds the columns for the "users" table. UsersColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID, Unique: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "email", Type: field.TypeString, Unique: true}, {Name: "password_hash", Type: field.TypeString}, } // UsersTable holds the schema information for the "users" table. UsersTable = &schema.Table{ Name: "users", Columns: UsersColumns, PrimaryKey: []*schema.Column{UsersColumns[0]}, } // VariableReferencesColumns holds the columns for the "variable_references" table. VariableReferencesColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID, Unique: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "target_name", Type: field.TypeString}, {Name: "sources", Type: field.TypeJSON}, {Name: "value_template", Type: field.TypeString}, {Name: "error", Type: field.TypeString, Nullable: true}, {Name: "target_service_id", Type: field.TypeUUID}, } // VariableReferencesTable holds the schema information for the "variable_references" table. VariableReferencesTable = &schema.Table{ Name: "variable_references", Columns: VariableReferencesColumns, PrimaryKey: []*schema.Column{VariableReferencesColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "variable_references_services_variable_references", Columns: []*schema.Column{VariableReferencesColumns[7]}, RefColumns: []*schema.Column{ServicesColumns[0]}, OnDelete: schema.Cascade, }, }, Indexes: []*schema.Index{ { Name: "variablereference_target_service_id_target_name", Unique: true, Columns: []*schema.Column{VariableReferencesColumns[7], VariableReferencesColumns[3]}, }, { Name: "variablereference_target_service_id", Unique: false, Columns: []*schema.Column{VariableReferencesColumns[7]}, }, { Name: "variablereference_target_service_id_created_at", Unique: false, Columns: []*schema.Column{VariableReferencesColumns[7], VariableReferencesColumns[1]}, }, { Name: "variablereference_created_at", Unique: false, Columns: []*schema.Column{VariableReferencesColumns[1]}, }, }, } // WebhooksColumns holds the columns for the "webhooks" table. WebhooksColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID, Unique: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "url", Type: field.TypeString}, {Name: "type", Type: field.TypeEnum, Enums: []string{"team", "project"}}, {Name: "events", Type: field.TypeJSON}, {Name: "project_id", Type: field.TypeUUID, Nullable: true}, {Name: "team_id", Type: field.TypeUUID}, } // WebhooksTable holds the schema information for the "webhooks" table. WebhooksTable = &schema.Table{ Name: "webhooks", Columns: WebhooksColumns, PrimaryKey: []*schema.Column{WebhooksColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "webhooks_projects_project_webhooks", Columns: []*schema.Column{WebhooksColumns[6]}, RefColumns: []*schema.Column{ProjectsColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "webhooks_teams_team_webhooks", Columns: []*schema.Column{WebhooksColumns[7]}, RefColumns: []*schema.Column{TeamsColumns[0]}, OnDelete: schema.Cascade, }, }, } // GroupPermissionsColumns holds the columns for the "group_permissions" table. GroupPermissionsColumns = []*schema.Column{ {Name: "group_id", Type: field.TypeUUID}, {Name: "permission_id", Type: field.TypeUUID}, } // GroupPermissionsTable holds the schema information for the "group_permissions" table. GroupPermissionsTable = &schema.Table{ Name: "group_permissions", Columns: GroupPermissionsColumns, PrimaryKey: []*schema.Column{GroupPermissionsColumns[0], GroupPermissionsColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "group_permissions_group_id", Columns: []*schema.Column{GroupPermissionsColumns[0]}, RefColumns: []*schema.Column{GroupsColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "group_permissions_permission_id", Columns: []*schema.Column{GroupPermissionsColumns[1]}, RefColumns: []*schema.Column{PermissionsColumns[0]}, OnDelete: schema.Cascade, }, }, } // UserGroupsColumns holds the columns for the "user_groups" table. UserGroupsColumns = []*schema.Column{ {Name: "user_id", Type: field.TypeUUID}, {Name: "group_id", Type: field.TypeUUID}, } // UserGroupsTable holds the schema information for the "user_groups" table. UserGroupsTable = &schema.Table{ Name: "user_groups", Columns: UserGroupsColumns, PrimaryKey: []*schema.Column{UserGroupsColumns[0], UserGroupsColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "user_groups_user_id", Columns: []*schema.Column{UserGroupsColumns[0]}, RefColumns: []*schema.Column{UsersColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "user_groups_group_id", Columns: []*schema.Column{UserGroupsColumns[1]}, RefColumns: []*schema.Column{GroupsColumns[0]}, OnDelete: schema.Cascade, }, }, } // UserTeamsColumns holds the columns for the "user_teams" table. UserTeamsColumns = []*schema.Column{ {Name: "user_id", Type: field.TypeUUID}, {Name: "team_id", Type: field.TypeUUID}, } // UserTeamsTable holds the schema information for the "user_teams" table. UserTeamsTable = &schema.Table{ Name: "user_teams", Columns: UserTeamsColumns, PrimaryKey: []*schema.Column{UserTeamsColumns[0], UserTeamsColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "user_teams_user_id", Columns: []*schema.Column{UserTeamsColumns[0]}, RefColumns: []*schema.Column{UsersColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "user_teams_team_id", Columns: []*schema.Column{UserTeamsColumns[1]}, RefColumns: []*schema.Column{TeamsColumns[0]}, OnDelete: schema.Cascade, }, }, } // Tables holds all the tables in the schema. Tables = []*schema.Table{ BootstrapFlagTable, DeploymentsTable, EnvironmentsTable, GithubAppsTable, GithubInstallationsTable, GroupsTable, JwtKeysTable, Oauth2CodesTable, Oauth2TokensTable, PvcMetadataTable, PermissionsTable, ProjectsTable, RegistriesTable, S3SourcesTable, ServicesTable, ServiceConfigsTable, ServiceGroupsTable, SystemSettingsTable, TeamsTable, TemplatesTable, UsersTable, VariableReferencesTable, WebhooksTable, GroupPermissionsTable, UserGroupsTable, UserTeamsTable, } )
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.