migrate

package
v0.0.0-...-aca7f8d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2021 License: MPL-2.0 Imports: 7 Imported by: 0

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
	// WithFixture sets the foreign-key renaming option to the migration when upgrading
	// ent from v0.1.0 (issue-#285). Defaults to false.
	WithFixture = schema.WithFixture
	// WithForeignKeys enables creating foreign-key in schema DDL. This defaults to true.
	WithForeignKeys = schema.WithForeignKeys
)
View Source
var (
	// AdapterColumns holds the columns for the "adapter" table.
	AdapterColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "name", Type: field.TypeString},
		{Name: "tag", Type: field.TypeString},
		{Name: "module", Type: field.TypeString},
		{Name: "adapter_owner", Type: field.TypeInt, Nullable: true},
	}
	// AdapterTable holds the schema information for the "adapter" table.
	AdapterTable = &schema.Table{
		Name:       "adapter",
		Columns:    AdapterColumns,
		PrimaryKey: []*schema.Column{AdapterColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "adapter_organization_owner",
				Columns:    []*schema.Column{AdapterColumns[4]},
				RefColumns: []*schema.Column{OrganizationColumns[0]},
				OnDelete:   schema.SetNull,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "adapter_name_tag",
				Unique:  true,
				Columns: []*schema.Column{AdapterColumns[1], AdapterColumns[2]},
			},
		},
	}
	// ArtifactColumns holds the columns for the "artifact" table.
	ArtifactColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "name", Type: field.TypeString},
		{Name: "sha256", Type: field.TypeString},
		{Name: "type", Type: field.TypeEnum, Enums: []string{"docker", "file"}},
		{Name: "time", Type: field.TypeTime},
		{Name: "metadata", Type: field.TypeJSON, Nullable: true},
		{Name: "artifact_release", Type: field.TypeInt, Nullable: true},
		{Name: "release_entry_artifact", Type: field.TypeInt, Unique: true, Nullable: true},
	}
	// ArtifactTable holds the schema information for the "artifact" table.
	ArtifactTable = &schema.Table{
		Name:       "artifact",
		Columns:    ArtifactColumns,
		PrimaryKey: []*schema.Column{ArtifactColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "artifact_release_release",
				Columns:    []*schema.Column{ArtifactColumns[6]},
				RefColumns: []*schema.Column{ReleaseColumns[0]},
				OnDelete:   schema.SetNull,
			},
			{
				Symbol:     "artifact_release_entry_artifact",
				Columns:    []*schema.Column{ArtifactColumns[7]},
				RefColumns: []*schema.Column{ReleaseEntryColumns[0]},
				OnDelete:   schema.SetNull,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "artifact_sha256",
				Unique:  true,
				Columns: []*schema.Column{ArtifactColumns[2]},
			},
		},
	}
	// CodeIssueColumns holds the columns for the "code_issue" table.
	CodeIssueColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "rule_id", Type: field.TypeString},
		{Name: "message", Type: field.TypeString},
		{Name: "severity", Type: field.TypeEnum, Enums: []string{"low", "medium", "high"}},
		{Name: "type", Type: field.TypeEnum, Enums: []string{"style", "security", "bug"}},
		{Name: "metadata", Type: field.TypeJSON, Nullable: true},
		{Name: "code_issue_scan", Type: field.TypeInt, Nullable: true},
	}
	// CodeIssueTable holds the schema information for the "code_issue" table.
	CodeIssueTable = &schema.Table{
		Name:       "code_issue",
		Columns:    CodeIssueColumns,
		PrimaryKey: []*schema.Column{CodeIssueColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "code_issue_code_scan_scan",
				Columns:    []*schema.Column{CodeIssueColumns[6]},
				RefColumns: []*schema.Column{CodeScanColumns[0]},
				OnDelete:   schema.SetNull,
			},
		},
	}
	// CodeScanColumns holds the columns for the "code_scan" table.
	CodeScanColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "tool", Type: field.TypeString},
		{Name: "time", Type: field.TypeTime},
		{Name: "metadata", Type: field.TypeJSON, Nullable: true},
		{Name: "code_scan_release", Type: field.TypeInt, Nullable: true},
		{Name: "release_entry_code_scan", Type: field.TypeInt, Unique: true, Nullable: true},
	}
	// CodeScanTable holds the schema information for the "code_scan" table.
	CodeScanTable = &schema.Table{
		Name:       "code_scan",
		Columns:    CodeScanColumns,
		PrimaryKey: []*schema.Column{CodeScanColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "code_scan_release_release",
				Columns:    []*schema.Column{CodeScanColumns[4]},
				RefColumns: []*schema.Column{ReleaseColumns[0]},
				OnDelete:   schema.SetNull,
			},
			{
				Symbol:     "code_scan_release_entry_code_scan",
				Columns:    []*schema.Column{CodeScanColumns[5]},
				RefColumns: []*schema.Column{ReleaseEntryColumns[0]},
				OnDelete:   schema.SetNull,
			},
		},
	}
	// ComponentColumns holds the columns for the "component" table.
	ComponentColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "scheme", Type: field.TypeString},
		{Name: "namespace", Type: field.TypeString, Default: ""},
		{Name: "name", Type: field.TypeString},
		{Name: "version", Type: field.TypeString},
		{Name: "description", Type: field.TypeString, Nullable: true},
		{Name: "url", Type: field.TypeString, Nullable: true},
		{Name: "metadata", Type: field.TypeJSON, Nullable: true},
		{Name: "labels", Type: field.TypeJSON, Nullable: true},
		{Name: "component_owner", Type: field.TypeInt, Nullable: true},
	}
	// ComponentTable holds the schema information for the "component" table.
	ComponentTable = &schema.Table{
		Name:       "component",
		Columns:    ComponentColumns,
		PrimaryKey: []*schema.Column{ComponentColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "component_organization_owner",
				Columns:    []*schema.Column{ComponentColumns[9]},
				RefColumns: []*schema.Column{OrganizationColumns[0]},
				OnDelete:   schema.SetNull,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "component_scheme_namespace_name_version",
				Unique:  true,
				Columns: []*schema.Column{ComponentColumns[1], ComponentColumns[2], ComponentColumns[3], ComponentColumns[4]},
			},
		},
	}
	// EventColumns holds the columns for the "event" table.
	EventColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "message", Type: field.TypeString, Default: ""},
		{Name: "status", Type: field.TypeEnum, Enums: []string{"ok", "error"}, Default: "ok"},
		{Name: "type", Type: field.TypeEnum, Enums: []string{"evaluate_release", "monitor"}},
		{Name: "time", Type: field.TypeTime},
		{Name: "event_release", Type: field.TypeInt, Nullable: true},
		{Name: "event_repo", Type: field.TypeInt, Nullable: true},
		{Name: "event_project", Type: field.TypeInt, Nullable: true},
	}
	// EventTable holds the schema information for the "event" table.
	EventTable = &schema.Table{
		Name:       "event",
		Columns:    EventColumns,
		PrimaryKey: []*schema.Column{EventColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "event_release_release",
				Columns:    []*schema.Column{EventColumns[5]},
				RefColumns: []*schema.Column{ReleaseColumns[0]},
				OnDelete:   schema.SetNull,
			},
			{
				Symbol:     "event_repo_repo",
				Columns:    []*schema.Column{EventColumns[6]},
				RefColumns: []*schema.Column{RepoColumns[0]},
				OnDelete:   schema.SetNull,
			},
			{
				Symbol:     "event_project_project",
				Columns:    []*schema.Column{EventColumns[7]},
				RefColumns: []*schema.Column{ProjectColumns[0]},
				OnDelete:   schema.SetNull,
			},
		},
	}
	// CommitColumns holds the columns for the "commit" table.
	CommitColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "hash", Type: field.TypeString},
		{Name: "branch", Type: field.TypeString},
		{Name: "tag", Type: field.TypeString, Nullable: true},
		{Name: "time", Type: field.TypeTime},
		{Name: "git_commit_repo", Type: field.TypeInt, Nullable: true},
	}
	// CommitTable holds the schema information for the "commit" table.
	CommitTable = &schema.Table{
		Name:       "commit",
		Columns:    CommitColumns,
		PrimaryKey: []*schema.Column{CommitColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "commit_repo_repo",
				Columns:    []*schema.Column{CommitColumns[5]},
				RefColumns: []*schema.Column{RepoColumns[0]},
				OnDelete:   schema.SetNull,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "gitcommit_hash_git_commit_repo",
				Unique:  true,
				Columns: []*schema.Column{CommitColumns[1], CommitColumns[5]},
			},
		},
	}
	// LicenseColumns holds the columns for the "license" table.
	LicenseColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "license_id", Type: field.TypeString, Unique: true},
		{Name: "name", Type: field.TypeString, Nullable: true},
		{Name: "license_owner", Type: field.TypeInt, Nullable: true},
		{Name: "license_spdx", Type: field.TypeInt, Nullable: true},
	}
	// LicenseTable holds the schema information for the "license" table.
	LicenseTable = &schema.Table{
		Name:       "license",
		Columns:    LicenseColumns,
		PrimaryKey: []*schema.Column{LicenseColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "license_organization_owner",
				Columns:    []*schema.Column{LicenseColumns[3]},
				RefColumns: []*schema.Column{OrganizationColumns[0]},
				OnDelete:   schema.SetNull,
			},
			{
				Symbol:     "license_spdx_license_spdx",
				Columns:    []*schema.Column{LicenseColumns[4]},
				RefColumns: []*schema.Column{SpdxLicenseColumns[0]},
				OnDelete:   schema.SetNull,
			},
		},
	}
	// OrganizationColumns holds the columns for the "organization" table.
	OrganizationColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "name", Type: field.TypeString, Unique: true},
	}
	// OrganizationTable holds the schema information for the "organization" table.
	OrganizationTable = &schema.Table{
		Name:       "organization",
		Columns:    OrganizationColumns,
		PrimaryKey: []*schema.Column{OrganizationColumns[0]},
	}
	// ProjectColumns holds the columns for the "project" table.
	ProjectColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "name", Type: field.TypeString},
		{Name: "project_owner", Type: field.TypeInt, Nullable: true},
	}
	// ProjectTable holds the schema information for the "project" table.
	ProjectTable = &schema.Table{
		Name:       "project",
		Columns:    ProjectColumns,
		PrimaryKey: []*schema.Column{ProjectColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "project_organization_owner",
				Columns:    []*schema.Column{ProjectColumns[2]},
				RefColumns: []*schema.Column{OrganizationColumns[0]},
				OnDelete:   schema.SetNull,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "project_name_project_owner",
				Unique:  true,
				Columns: []*schema.Column{ProjectColumns[1], ProjectColumns[2]},
			},
		},
	}
	// ReleaseColumns holds the columns for the "release" table.
	ReleaseColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "name", Type: field.TypeString},
		{Name: "version", Type: field.TypeString},
		{Name: "labels", Type: field.TypeJSON, Nullable: true},
		{Name: "git_commit_release", Type: field.TypeInt, Unique: true, Nullable: true},
		{Name: "repo_head", Type: field.TypeInt, Unique: true, Nullable: true},
	}
	// ReleaseTable holds the schema information for the "release" table.
	ReleaseTable = &schema.Table{
		Name:       "release",
		Columns:    ReleaseColumns,
		PrimaryKey: []*schema.Column{ReleaseColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "release_commit_release",
				Columns:    []*schema.Column{ReleaseColumns[4]},
				RefColumns: []*schema.Column{CommitColumns[0]},
				OnDelete:   schema.SetNull,
			},
			{
				Symbol:     "release_repo_head",
				Columns:    []*schema.Column{ReleaseColumns[5]},
				RefColumns: []*schema.Column{RepoColumns[0]},
				OnDelete:   schema.SetNull,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "release_git_commit_release",
				Unique:  true,
				Columns: []*schema.Column{ReleaseColumns[4]},
			},
		},
	}
	// ReleaseComponentColumns holds the columns for the "release_component" table.
	ReleaseComponentColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "type", Type: field.TypeEnum, Enums: []string{"embedded", "distributed", "development"}, Default: "embedded"},
		{Name: "release_component_release", Type: field.TypeInt, Nullable: true},
		{Name: "release_component_component", Type: field.TypeInt, Nullable: true},
	}
	// ReleaseComponentTable holds the schema information for the "release_component" table.
	ReleaseComponentTable = &schema.Table{
		Name:       "release_component",
		Columns:    ReleaseComponentColumns,
		PrimaryKey: []*schema.Column{ReleaseComponentColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "release_component_release_release",
				Columns:    []*schema.Column{ReleaseComponentColumns[2]},
				RefColumns: []*schema.Column{ReleaseColumns[0]},
				OnDelete:   schema.SetNull,
			},
			{
				Symbol:     "release_component_component_component",
				Columns:    []*schema.Column{ReleaseComponentColumns[3]},
				RefColumns: []*schema.Column{ComponentColumns[0]},
				OnDelete:   schema.SetNull,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "releasecomponent_release_component_release_release_component_component",
				Unique:  true,
				Columns: []*schema.Column{ReleaseComponentColumns[2], ReleaseComponentColumns[3]},
			},
		},
	}
	// ReleaseEntryColumns holds the columns for the "release_entry" table.
	ReleaseEntryColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "type", Type: field.TypeEnum, Enums: []string{"artifact", "deploy", "code_scan", "test_run"}},
		{Name: "time", Type: field.TypeTime},
		{Name: "release_entry_release", Type: field.TypeInt, Nullable: true},
	}
	// ReleaseEntryTable holds the schema information for the "release_entry" table.
	ReleaseEntryTable = &schema.Table{
		Name:       "release_entry",
		Columns:    ReleaseEntryColumns,
		PrimaryKey: []*schema.Column{ReleaseEntryColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "release_entry_release_release",
				Columns:    []*schema.Column{ReleaseEntryColumns[3]},
				RefColumns: []*schema.Column{ReleaseColumns[0]},
				OnDelete:   schema.SetNull,
			},
		},
	}
	// ReleaseLicenseColumns holds the columns for the "release_license" table.
	ReleaseLicenseColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "release_license_license", Type: field.TypeInt, Nullable: true},
		{Name: "release_license_component", Type: field.TypeInt, Nullable: true},
		{Name: "release_license_release", Type: field.TypeInt, Nullable: true},
	}
	// ReleaseLicenseTable holds the schema information for the "release_license" table.
	ReleaseLicenseTable = &schema.Table{
		Name:       "release_license",
		Columns:    ReleaseLicenseColumns,
		PrimaryKey: []*schema.Column{ReleaseLicenseColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "release_license_license_license",
				Columns:    []*schema.Column{ReleaseLicenseColumns[1]},
				RefColumns: []*schema.Column{LicenseColumns[0]},
				OnDelete:   schema.SetNull,
			},
			{
				Symbol:     "release_license_release_component_component",
				Columns:    []*schema.Column{ReleaseLicenseColumns[2]},
				RefColumns: []*schema.Column{ReleaseComponentColumns[0]},
				OnDelete:   schema.SetNull,
			},
			{
				Symbol:     "release_license_release_release",
				Columns:    []*schema.Column{ReleaseLicenseColumns[3]},
				RefColumns: []*schema.Column{ReleaseColumns[0]},
				OnDelete:   schema.SetNull,
			},
		},
	}
	// ReleasePolicyColumns holds the columns for the "release_policy" table.
	ReleasePolicyColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "name", Type: field.TypeString, Unique: true},
		{Name: "module", Type: field.TypeString},
		{Name: "release_policy_owner", Type: field.TypeInt, Nullable: true},
	}
	// ReleasePolicyTable holds the schema information for the "release_policy" table.
	ReleasePolicyTable = &schema.Table{
		Name:       "release_policy",
		Columns:    ReleasePolicyColumns,
		PrimaryKey: []*schema.Column{ReleasePolicyColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "release_policy_organization_owner",
				Columns:    []*schema.Column{ReleasePolicyColumns[3]},
				RefColumns: []*schema.Column{OrganizationColumns[0]},
				OnDelete:   schema.SetNull,
			},
		},
	}
	// ReleasePolicyViolationColumns holds the columns for the "release_policy_violation" table.
	ReleasePolicyViolationColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "message", Type: field.TypeString},
		{Name: "type", Type: field.TypeEnum, Enums: []string{"require", "deny"}},
		{Name: "severity", Type: field.TypeEnum, Enums: []string{"suggestion", "warning", "blocking"}},
		{Name: "release_policy_violation_policy", Type: field.TypeInt, Nullable: true},
		{Name: "release_policy_violation_release", Type: field.TypeInt, Nullable: true},
	}
	// ReleasePolicyViolationTable holds the schema information for the "release_policy_violation" table.
	ReleasePolicyViolationTable = &schema.Table{
		Name:       "release_policy_violation",
		Columns:    ReleasePolicyViolationColumns,
		PrimaryKey: []*schema.Column{ReleasePolicyViolationColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "release_policy_violation_release_policy_policy",
				Columns:    []*schema.Column{ReleasePolicyViolationColumns[4]},
				RefColumns: []*schema.Column{ReleasePolicyColumns[0]},
				OnDelete:   schema.SetNull,
			},
			{
				Symbol:     "release_policy_violation_release_release",
				Columns:    []*schema.Column{ReleasePolicyViolationColumns[5]},
				RefColumns: []*schema.Column{ReleaseColumns[0]},
				OnDelete:   schema.SetNull,
			},
		},
	}
	// ReleaseVulnerabilityColumns holds the columns for the "release_vulnerability" table.
	ReleaseVulnerabilityColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "release_vulnerability_vulnerability", Type: field.TypeInt, Nullable: true},
		{Name: "release_vulnerability_component", Type: field.TypeInt, Nullable: true},
		{Name: "release_vulnerability_release", Type: field.TypeInt, Nullable: true},
		{Name: "release_vulnerability_scan", Type: field.TypeInt, Nullable: true},
	}
	// ReleaseVulnerabilityTable holds the schema information for the "release_vulnerability" table.
	ReleaseVulnerabilityTable = &schema.Table{
		Name:       "release_vulnerability",
		Columns:    ReleaseVulnerabilityColumns,
		PrimaryKey: []*schema.Column{ReleaseVulnerabilityColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "release_vulnerability_vulnerability_vulnerability",
				Columns:    []*schema.Column{ReleaseVulnerabilityColumns[1]},
				RefColumns: []*schema.Column{VulnerabilityColumns[0]},
				OnDelete:   schema.SetNull,
			},
			{
				Symbol:     "release_vulnerability_release_component_component",
				Columns:    []*schema.Column{ReleaseVulnerabilityColumns[2]},
				RefColumns: []*schema.Column{ReleaseComponentColumns[0]},
				OnDelete:   schema.SetNull,
			},
			{
				Symbol:     "release_vulnerability_release_release",
				Columns:    []*schema.Column{ReleaseVulnerabilityColumns[3]},
				RefColumns: []*schema.Column{ReleaseColumns[0]},
				OnDelete:   schema.SetNull,
			},
			{
				Symbol:     "release_vulnerability_code_scan_scan",
				Columns:    []*schema.Column{ReleaseVulnerabilityColumns[4]},
				RefColumns: []*schema.Column{CodeScanColumns[0]},
				OnDelete:   schema.SetNull,
			},
		},
	}
	// RepoColumns holds the columns for the "repo" table.
	RepoColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "name", Type: field.TypeString},
		{Name: "default_branch", Type: field.TypeString, Default: "main"},
		{Name: "repo_owner", Type: field.TypeInt, Nullable: true},
		{Name: "repo_project", Type: field.TypeInt, Nullable: true},
	}
	// RepoTable holds the schema information for the "repo" table.
	RepoTable = &schema.Table{
		Name:       "repo",
		Columns:    RepoColumns,
		PrimaryKey: []*schema.Column{RepoColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "repo_organization_owner",
				Columns:    []*schema.Column{RepoColumns[3]},
				RefColumns: []*schema.Column{OrganizationColumns[0]},
				OnDelete:   schema.SetNull,
			},
			{
				Symbol:     "repo_project_project",
				Columns:    []*schema.Column{RepoColumns[4]},
				RefColumns: []*schema.Column{ProjectColumns[0]},
				OnDelete:   schema.SetNull,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "repo_name_repo_owner",
				Unique:  true,
				Columns: []*schema.Column{RepoColumns[1], RepoColumns[3]},
			},
		},
	}
	// SpdxLicenseColumns holds the columns for the "spdx_license" table.
	SpdxLicenseColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "license_id", Type: field.TypeString, Unique: true},
		{Name: "name", Type: field.TypeString},
		{Name: "reference", Type: field.TypeString, Nullable: true},
		{Name: "details_url", Type: field.TypeString, Nullable: true},
		{Name: "is_osi_approved", Type: field.TypeBool, Default: false},
	}
	// SpdxLicenseTable holds the schema information for the "spdx_license" table.
	SpdxLicenseTable = &schema.Table{
		Name:       "spdx_license",
		Columns:    SpdxLicenseColumns,
		PrimaryKey: []*schema.Column{SpdxLicenseColumns[0]},
	}
	// TestCaseColumns holds the columns for the "test_case" table.
	TestCaseColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "name", Type: field.TypeString},
		{Name: "result", Type: field.TypeBool},
		{Name: "message", Type: field.TypeString},
		{Name: "elapsed", Type: field.TypeFloat64, Default: 0},
		{Name: "metadata", Type: field.TypeJSON, Nullable: true},
		{Name: "test_case_run", Type: field.TypeInt, Nullable: true},
	}
	// TestCaseTable holds the schema information for the "test_case" table.
	TestCaseTable = &schema.Table{
		Name:       "test_case",
		Columns:    TestCaseColumns,
		PrimaryKey: []*schema.Column{TestCaseColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "test_case_test_run_run",
				Columns:    []*schema.Column{TestCaseColumns[6]},
				RefColumns: []*schema.Column{TestRunColumns[0]},
				OnDelete:   schema.SetNull,
			},
		},
	}
	// TestRunColumns holds the columns for the "test_run" table.
	TestRunColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "tool", Type: field.TypeString},
		{Name: "time", Type: field.TypeTime},
		{Name: "metadata", Type: field.TypeJSON, Nullable: true},
		{Name: "release_entry_test_run", Type: field.TypeInt, Unique: true, Nullable: true},
		{Name: "test_run_release", Type: field.TypeInt, Nullable: true},
	}
	// TestRunTable holds the schema information for the "test_run" table.
	TestRunTable = &schema.Table{
		Name:       "test_run",
		Columns:    TestRunColumns,
		PrimaryKey: []*schema.Column{TestRunColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "test_run_release_entry_test_run",
				Columns:    []*schema.Column{TestRunColumns[4]},
				RefColumns: []*schema.Column{ReleaseEntryColumns[0]},
				OnDelete:   schema.SetNull,
			},
			{
				Symbol:     "test_run_release_release",
				Columns:    []*schema.Column{TestRunColumns[5]},
				RefColumns: []*schema.Column{ReleaseColumns[0]},
				OnDelete:   schema.SetNull,
			},
		},
	}
	// VulnerabilityColumns holds the columns for the "vulnerability" table.
	VulnerabilityColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "vid", Type: field.TypeString, Unique: true},
		{Name: "summary", Type: field.TypeString, Nullable: true},
		{Name: "description", Type: field.TypeString, Nullable: true},
		{Name: "severity_score", Type: field.TypeFloat64, Default: 0},
		{Name: "severity", Type: field.TypeEnum, Enums: []string{"None", "Low", "Medium", "High", "Critical"}, Default: "None"},
		{Name: "published", Type: field.TypeTime, Nullable: true},
		{Name: "modified", Type: field.TypeTime, Nullable: true},
		{Name: "metadata", Type: field.TypeJSON, Nullable: true},
		{Name: "vulnerability_owner", Type: field.TypeInt, Nullable: true},
	}
	// VulnerabilityTable holds the schema information for the "vulnerability" table.
	VulnerabilityTable = &schema.Table{
		Name:       "vulnerability",
		Columns:    VulnerabilityColumns,
		PrimaryKey: []*schema.Column{VulnerabilityColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "vulnerability_organization_owner",
				Columns:    []*schema.Column{VulnerabilityColumns[9]},
				RefColumns: []*schema.Column{OrganizationColumns[0]},
				OnDelete:   schema.SetNull,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "vulnerability_vid",
				Unique:  true,
				Columns: []*schema.Column{VulnerabilityColumns[1]},
			},
		},
	}
	// VulnerabilityReviewColumns holds the columns for the "vulnerability_review" table.
	VulnerabilityReviewColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "note", Type: field.TypeString},
		{Name: "decision", Type: field.TypeEnum, Enums: []string{"exploitable", "in_progress", "invalid", "mitigated", "ineffective", "patched"}, Default: "exploitable"},
		{Name: "vulnerability_review_vulnerability", Type: field.TypeInt, Nullable: true},
	}
	// VulnerabilityReviewTable holds the schema information for the "vulnerability_review" table.
	VulnerabilityReviewTable = &schema.Table{
		Name:       "vulnerability_review",
		Columns:    VulnerabilityReviewColumns,
		PrimaryKey: []*schema.Column{VulnerabilityReviewColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "vulnerability_review_vulnerability_vulnerability",
				Columns:    []*schema.Column{VulnerabilityReviewColumns[3]},
				RefColumns: []*schema.Column{VulnerabilityColumns[0]},
				OnDelete:   schema.SetNull,
			},
		},
	}
	// ComponentVulnerabilitiesColumns holds the columns for the "component_vulnerabilities" table.
	ComponentVulnerabilitiesColumns = []*schema.Column{
		{Name: "component_id", Type: field.TypeInt},
		{Name: "vulnerability_id", Type: field.TypeInt},
	}
	// ComponentVulnerabilitiesTable holds the schema information for the "component_vulnerabilities" table.
	ComponentVulnerabilitiesTable = &schema.Table{
		Name:       "component_vulnerabilities",
		Columns:    ComponentVulnerabilitiesColumns,
		PrimaryKey: []*schema.Column{ComponentVulnerabilitiesColumns[0], ComponentVulnerabilitiesColumns[1]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "component_vulnerabilities_component_id",
				Columns:    []*schema.Column{ComponentVulnerabilitiesColumns[0]},
				RefColumns: []*schema.Column{ComponentColumns[0]},
				OnDelete:   schema.Cascade,
			},
			{
				Symbol:     "component_vulnerabilities_vulnerability_id",
				Columns:    []*schema.Column{ComponentVulnerabilitiesColumns[1]},
				RefColumns: []*schema.Column{VulnerabilityColumns[0]},
				OnDelete:   schema.Cascade,
			},
		},
	}
	// ComponentLicensesColumns holds the columns for the "component_licenses" table.
	ComponentLicensesColumns = []*schema.Column{
		{Name: "component_id", Type: field.TypeInt},
		{Name: "license_id", Type: field.TypeInt},
	}
	// ComponentLicensesTable holds the schema information for the "component_licenses" table.
	ComponentLicensesTable = &schema.Table{
		Name:       "component_licenses",
		Columns:    ComponentLicensesColumns,
		PrimaryKey: []*schema.Column{ComponentLicensesColumns[0], ComponentLicensesColumns[1]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "component_licenses_component_id",
				Columns:    []*schema.Column{ComponentLicensesColumns[0]},
				RefColumns: []*schema.Column{ComponentColumns[0]},
				OnDelete:   schema.Cascade,
			},
			{
				Symbol:     "component_licenses_license_id",
				Columns:    []*schema.Column{ComponentLicensesColumns[1]},
				RefColumns: []*schema.Column{LicenseColumns[0]},
				OnDelete:   schema.Cascade,
			},
		},
	}
	// ReleaseDependenciesColumns holds the columns for the "release_dependencies" table.
	ReleaseDependenciesColumns = []*schema.Column{
		{Name: "release_id", Type: field.TypeInt},
		{Name: "subrelease_id", Type: field.TypeInt},
	}
	// ReleaseDependenciesTable holds the schema information for the "release_dependencies" table.
	ReleaseDependenciesTable = &schema.Table{
		Name:       "release_dependencies",
		Columns:    ReleaseDependenciesColumns,
		PrimaryKey: []*schema.Column{ReleaseDependenciesColumns[0], ReleaseDependenciesColumns[1]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "release_dependencies_release_id",
				Columns:    []*schema.Column{ReleaseDependenciesColumns[0]},
				RefColumns: []*schema.Column{ReleaseColumns[0]},
				OnDelete:   schema.Cascade,
			},
			{
				Symbol:     "release_dependencies_subrelease_id",
				Columns:    []*schema.Column{ReleaseDependenciesColumns[1]},
				RefColumns: []*schema.Column{ReleaseColumns[0]},
				OnDelete:   schema.Cascade,
			},
		},
	}
	// ReleaseComponentScansColumns holds the columns for the "release_component_scans" table.
	ReleaseComponentScansColumns = []*schema.Column{
		{Name: "release_component_id", Type: field.TypeInt},
		{Name: "code_scan_id", Type: field.TypeInt},
	}
	// ReleaseComponentScansTable holds the schema information for the "release_component_scans" table.
	ReleaseComponentScansTable = &schema.Table{
		Name:       "release_component_scans",
		Columns:    ReleaseComponentScansColumns,
		PrimaryKey: []*schema.Column{ReleaseComponentScansColumns[0], ReleaseComponentScansColumns[1]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "release_component_scans_release_component_id",
				Columns:    []*schema.Column{ReleaseComponentScansColumns[0]},
				RefColumns: []*schema.Column{ReleaseComponentColumns[0]},
				OnDelete:   schema.Cascade,
			},
			{
				Symbol:     "release_component_scans_code_scan_id",
				Columns:    []*schema.Column{ReleaseComponentScansColumns[1]},
				RefColumns: []*schema.Column{CodeScanColumns[0]},
				OnDelete:   schema.Cascade,
			},
		},
	}
	// ReleaseLicenseScansColumns holds the columns for the "release_license_scans" table.
	ReleaseLicenseScansColumns = []*schema.Column{
		{Name: "release_license_id", Type: field.TypeInt},
		{Name: "code_scan_id", Type: field.TypeInt},
	}
	// ReleaseLicenseScansTable holds the schema information for the "release_license_scans" table.
	ReleaseLicenseScansTable = &schema.Table{
		Name:       "release_license_scans",
		Columns:    ReleaseLicenseScansColumns,
		PrimaryKey: []*schema.Column{ReleaseLicenseScansColumns[0], ReleaseLicenseScansColumns[1]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "release_license_scans_release_license_id",
				Columns:    []*schema.Column{ReleaseLicenseScansColumns[0]},
				RefColumns: []*schema.Column{ReleaseLicenseColumns[0]},
				OnDelete:   schema.Cascade,
			},
			{
				Symbol:     "release_license_scans_code_scan_id",
				Columns:    []*schema.Column{ReleaseLicenseScansColumns[1]},
				RefColumns: []*schema.Column{CodeScanColumns[0]},
				OnDelete:   schema.Cascade,
			},
		},
	}
	// ReleasePolicyProjectsColumns holds the columns for the "release_policy_projects" table.
	ReleasePolicyProjectsColumns = []*schema.Column{
		{Name: "release_policy_id", Type: field.TypeInt},
		{Name: "project_id", Type: field.TypeInt},
	}
	// ReleasePolicyProjectsTable holds the schema information for the "release_policy_projects" table.
	ReleasePolicyProjectsTable = &schema.Table{
		Name:       "release_policy_projects",
		Columns:    ReleasePolicyProjectsColumns,
		PrimaryKey: []*schema.Column{ReleasePolicyProjectsColumns[0], ReleasePolicyProjectsColumns[1]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "release_policy_projects_release_policy_id",
				Columns:    []*schema.Column{ReleasePolicyProjectsColumns[0]},
				RefColumns: []*schema.Column{ReleasePolicyColumns[0]},
				OnDelete:   schema.Cascade,
			},
			{
				Symbol:     "release_policy_projects_project_id",
				Columns:    []*schema.Column{ReleasePolicyProjectsColumns[1]},
				RefColumns: []*schema.Column{ProjectColumns[0]},
				OnDelete:   schema.Cascade,
			},
		},
	}
	// ReleasePolicyReposColumns holds the columns for the "release_policy_repos" table.
	ReleasePolicyReposColumns = []*schema.Column{
		{Name: "release_policy_id", Type: field.TypeInt},
		{Name: "repo_id", Type: field.TypeInt},
	}
	// ReleasePolicyReposTable holds the schema information for the "release_policy_repos" table.
	ReleasePolicyReposTable = &schema.Table{
		Name:       "release_policy_repos",
		Columns:    ReleasePolicyReposColumns,
		PrimaryKey: []*schema.Column{ReleasePolicyReposColumns[0], ReleasePolicyReposColumns[1]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "release_policy_repos_release_policy_id",
				Columns:    []*schema.Column{ReleasePolicyReposColumns[0]},
				RefColumns: []*schema.Column{ReleasePolicyColumns[0]},
				OnDelete:   schema.Cascade,
			},
			{
				Symbol:     "release_policy_repos_repo_id",
				Columns:    []*schema.Column{ReleasePolicyReposColumns[1]},
				RefColumns: []*schema.Column{RepoColumns[0]},
				OnDelete:   schema.Cascade,
			},
		},
	}
	// ReleaseVulnerabilityReviewsColumns holds the columns for the "release_vulnerability_reviews" table.
	ReleaseVulnerabilityReviewsColumns = []*schema.Column{
		{Name: "release_vulnerability_id", Type: field.TypeInt},
		{Name: "vulnerability_review_id", Type: field.TypeInt},
	}
	// ReleaseVulnerabilityReviewsTable holds the schema information for the "release_vulnerability_reviews" table.
	ReleaseVulnerabilityReviewsTable = &schema.Table{
		Name:       "release_vulnerability_reviews",
		Columns:    ReleaseVulnerabilityReviewsColumns,
		PrimaryKey: []*schema.Column{ReleaseVulnerabilityReviewsColumns[0], ReleaseVulnerabilityReviewsColumns[1]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "release_vulnerability_reviews_release_vulnerability_id",
				Columns:    []*schema.Column{ReleaseVulnerabilityReviewsColumns[0]},
				RefColumns: []*schema.Column{ReleaseVulnerabilityColumns[0]},
				OnDelete:   schema.Cascade,
			},
			{
				Symbol:     "release_vulnerability_reviews_vulnerability_review_id",
				Columns:    []*schema.Column{ReleaseVulnerabilityReviewsColumns[1]},
				RefColumns: []*schema.Column{VulnerabilityReviewColumns[0]},
				OnDelete:   schema.Cascade,
			},
		},
	}
	// VulnerabilityReviewProjectsColumns holds the columns for the "vulnerability_review_projects" table.
	VulnerabilityReviewProjectsColumns = []*schema.Column{
		{Name: "vulnerability_review_id", Type: field.TypeInt},
		{Name: "project_id", Type: field.TypeInt},
	}
	// VulnerabilityReviewProjectsTable holds the schema information for the "vulnerability_review_projects" table.
	VulnerabilityReviewProjectsTable = &schema.Table{
		Name:       "vulnerability_review_projects",
		Columns:    VulnerabilityReviewProjectsColumns,
		PrimaryKey: []*schema.Column{VulnerabilityReviewProjectsColumns[0], VulnerabilityReviewProjectsColumns[1]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "vulnerability_review_projects_vulnerability_review_id",
				Columns:    []*schema.Column{VulnerabilityReviewProjectsColumns[0]},
				RefColumns: []*schema.Column{VulnerabilityReviewColumns[0]},
				OnDelete:   schema.Cascade,
			},
			{
				Symbol:     "vulnerability_review_projects_project_id",
				Columns:    []*schema.Column{VulnerabilityReviewProjectsColumns[1]},
				RefColumns: []*schema.Column{ProjectColumns[0]},
				OnDelete:   schema.Cascade,
			},
		},
	}
	// VulnerabilityReviewReposColumns holds the columns for the "vulnerability_review_repos" table.
	VulnerabilityReviewReposColumns = []*schema.Column{
		{Name: "vulnerability_review_id", Type: field.TypeInt},
		{Name: "repo_id", Type: field.TypeInt},
	}
	// VulnerabilityReviewReposTable holds the schema information for the "vulnerability_review_repos" table.
	VulnerabilityReviewReposTable = &schema.Table{
		Name:       "vulnerability_review_repos",
		Columns:    VulnerabilityReviewReposColumns,
		PrimaryKey: []*schema.Column{VulnerabilityReviewReposColumns[0], VulnerabilityReviewReposColumns[1]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "vulnerability_review_repos_vulnerability_review_id",
				Columns:    []*schema.Column{VulnerabilityReviewReposColumns[0]},
				RefColumns: []*schema.Column{VulnerabilityReviewColumns[0]},
				OnDelete:   schema.Cascade,
			},
			{
				Symbol:     "vulnerability_review_repos_repo_id",
				Columns:    []*schema.Column{VulnerabilityReviewReposColumns[1]},
				RefColumns: []*schema.Column{RepoColumns[0]},
				OnDelete:   schema.Cascade,
			},
		},
	}
	// VulnerabilityReviewReleasesColumns holds the columns for the "vulnerability_review_releases" table.
	VulnerabilityReviewReleasesColumns = []*schema.Column{
		{Name: "vulnerability_review_id", Type: field.TypeInt},
		{Name: "release_id", Type: field.TypeInt},
	}
	// VulnerabilityReviewReleasesTable holds the schema information for the "vulnerability_review_releases" table.
	VulnerabilityReviewReleasesTable = &schema.Table{
		Name:       "vulnerability_review_releases",
		Columns:    VulnerabilityReviewReleasesColumns,
		PrimaryKey: []*schema.Column{VulnerabilityReviewReleasesColumns[0], VulnerabilityReviewReleasesColumns[1]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "vulnerability_review_releases_vulnerability_review_id",
				Columns:    []*schema.Column{VulnerabilityReviewReleasesColumns[0]},
				RefColumns: []*schema.Column{VulnerabilityReviewColumns[0]},
				OnDelete:   schema.Cascade,
			},
			{
				Symbol:     "vulnerability_review_releases_release_id",
				Columns:    []*schema.Column{VulnerabilityReviewReleasesColumns[1]},
				RefColumns: []*schema.Column{ReleaseColumns[0]},
				OnDelete:   schema.Cascade,
			},
		},
	}
	// Tables holds all the tables in the schema.
	Tables = []*schema.Table{
		AdapterTable,
		ArtifactTable,
		CodeIssueTable,
		CodeScanTable,
		ComponentTable,
		EventTable,
		CommitTable,
		LicenseTable,
		OrganizationTable,
		ProjectTable,
		ReleaseTable,
		ReleaseComponentTable,
		ReleaseEntryTable,
		ReleaseLicenseTable,
		ReleasePolicyTable,
		ReleasePolicyViolationTable,
		ReleaseVulnerabilityTable,
		RepoTable,
		SpdxLicenseTable,
		TestCaseTable,
		TestRunTable,
		VulnerabilityTable,
		VulnerabilityReviewTable,
		ComponentVulnerabilitiesTable,
		ComponentLicensesTable,
		ReleaseDependenciesTable,
		ReleaseComponentScansTable,
		ReleaseLicenseScansTable,
		ReleasePolicyProjectsTable,
		ReleasePolicyReposTable,
		ReleaseVulnerabilityReviewsTable,
		VulnerabilityReviewProjectsTable,
		VulnerabilityReviewReposTable,
		VulnerabilityReviewReleasesTable,
	}
)

Functions

This section is empty.

Types

type Schema

type Schema struct {
	// contains filtered or unexported fields
}

Schema is the API for creating, migrating and dropping a schema.

func NewSchema

func NewSchema(drv dialect.Driver) *Schema

NewSchema creates a new schema client.

func (*Schema) Create

func (s *Schema) Create(ctx context.Context, opts ...schema.MigrateOption) error

Create creates all schema resources.

func (*Schema) WriteTo

func (s *Schema) WriteTo(ctx context.Context, w io.Writer, opts ...schema.MigrateOption) error

WriteTo writes the schema changes to w instead of running them against the database.

if err := client.Schema.WriteTo(context.Background(), os.Stdout); err != nil {
	log.Fatal(err)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL