migrate

package
v0.8.6 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

README

atlas migration

This dockerfile allows for running atlas migration for ENT.

  1. docker build: docker build . -t atlas-migration
  2. Run via:

To run it on a local server (for example: postgres://guac:guac@0.0.0.0:5432/guac?search_path=public&sslmode=disable):

docker run -e PGHOST=host.docker.internal \
           -e PGPORT=5432 \
           -e PGDATABASE=guac \
           -e PGUSER=guac \
           -e PGPASSWORD=guac \
           --network bridge \
           atlas-migration

For remote servers:

docker run -e PGHOST=your_host \
           -e PGPORT=your_port \
           -e PGDATABASE=your_database \
           -e PGUSER=your_user \
           -e PGPASSWORD=your_password \
           atlas-migration

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// WithGlobalUniqueID sets the universal ids options to the migration.
	// If this option is enabled, ent migration will allocate a 1<<32 range
	// for the ids of each entity (table).
	// Note that this option cannot be applied on tables that already exist.
	WithGlobalUniqueID = schema.WithGlobalUniqueID
	// WithDropColumn sets the drop column option to the migration.
	// If this option is enabled, ent migration will drop old columns
	// that were used for both fields and edges. This defaults to false.
	WithDropColumn = schema.WithDropColumn
	// WithDropIndex sets the drop index option to the migration.
	// If this option is enabled, ent migration will drop old indexes
	// that were defined in the schema. This defaults to false.
	// Note that unique constraints are defined using `UNIQUE INDEX`,
	// and therefore, it's recommended to enable this option to get more
	// flexibility in the schema changes.
	WithDropIndex = schema.WithDropIndex
	// WithForeignKeys enables creating foreign-key in schema DDL. This defaults to true.
	WithForeignKeys = schema.WithForeignKeys
)
View Source
var (
	// ArtifactsColumns holds the columns for the "artifacts" table.
	ArtifactsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUUID, Unique: true},
		{Name: "algorithm", Type: field.TypeString},
		{Name: "digest", Type: field.TypeString},
	}
	// ArtifactsTable holds the schema information for the "artifacts" table.
	ArtifactsTable = &schema.Table{
		Name:       "artifacts",
		Columns:    ArtifactsColumns,
		PrimaryKey: []*schema.Column{ArtifactsColumns[0]},
		Indexes: []*schema.Index{
			{
				Name:    "artifact_algorithm_digest",
				Unique:  true,
				Columns: []*schema.Column{ArtifactsColumns[1], ArtifactsColumns[2]},
			},
		},
	}
	// BillOfMaterialsColumns holds the columns for the "bill_of_materials" table.
	BillOfMaterialsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUUID, Unique: true},
		{Name: "uri", Type: field.TypeString},
		{Name: "algorithm", Type: field.TypeString},
		{Name: "digest", Type: field.TypeString},
		{Name: "download_location", Type: field.TypeString},
		{Name: "origin", Type: field.TypeString},
		{Name: "collector", Type: field.TypeString},
		{Name: "document_ref", Type: field.TypeString},
		{Name: "known_since", Type: field.TypeTime},
		{Name: "included_packages_hash", Type: field.TypeString},
		{Name: "included_artifacts_hash", Type: field.TypeString},
		{Name: "included_dependencies_hash", Type: field.TypeString},
		{Name: "included_occurrences_hash", Type: field.TypeString},
		{Name: "package_id", Type: field.TypeUUID, Nullable: true},
		{Name: "artifact_id", Type: field.TypeUUID, Nullable: true},
	}
	// BillOfMaterialsTable holds the schema information for the "bill_of_materials" table.
	BillOfMaterialsTable = &schema.Table{
		Name:       "bill_of_materials",
		Columns:    BillOfMaterialsColumns,
		PrimaryKey: []*schema.Column{BillOfMaterialsColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "bill_of_materials_package_versions_package",
				Columns:    []*schema.Column{BillOfMaterialsColumns[13]},
				RefColumns: []*schema.Column{PackageVersionsColumns[0]},
				OnDelete:   schema.Cascade,
			},
			{
				Symbol:     "bill_of_materials_artifacts_artifact",
				Columns:    []*schema.Column{BillOfMaterialsColumns[14]},
				RefColumns: []*schema.Column{ArtifactsColumns[0]},
				OnDelete:   schema.Cascade,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "sbom_package_id",
				Unique:  true,
				Columns: []*schema.Column{BillOfMaterialsColumns[2], BillOfMaterialsColumns[3], BillOfMaterialsColumns[1], BillOfMaterialsColumns[4], BillOfMaterialsColumns[8], BillOfMaterialsColumns[9], BillOfMaterialsColumns[10], BillOfMaterialsColumns[11], BillOfMaterialsColumns[12], BillOfMaterialsColumns[5], BillOfMaterialsColumns[6], BillOfMaterialsColumns[7], BillOfMaterialsColumns[13]},
				Annotation: &entsql.IndexAnnotation{
					Where: "package_id IS NOT NULL AND artifact_id IS NULL",
				},
			},
			{
				Name:    "sbom_artifact_id",
				Unique:  true,
				Columns: []*schema.Column{BillOfMaterialsColumns[2], BillOfMaterialsColumns[3], BillOfMaterialsColumns[1], BillOfMaterialsColumns[4], BillOfMaterialsColumns[8], BillOfMaterialsColumns[9], BillOfMaterialsColumns[10], BillOfMaterialsColumns[11], BillOfMaterialsColumns[12], BillOfMaterialsColumns[5], BillOfMaterialsColumns[6], BillOfMaterialsColumns[7], BillOfMaterialsColumns[14]},
				Annotation: &entsql.IndexAnnotation{
					Where: "package_id IS NULL AND artifact_id IS NOT NULL",
				},
			},
			{
				Name:    "billofmaterials_package_id",
				Unique:  false,
				Columns: []*schema.Column{BillOfMaterialsColumns[13]},
				Annotation: &entsql.IndexAnnotation{
					Where: "package_id IS NOT NULL AND artifact_id IS NULL",
				},
			},
			{
				Name:    "billofmaterials_artifact_id",
				Unique:  false,
				Columns: []*schema.Column{BillOfMaterialsColumns[14]},
				Annotation: &entsql.IndexAnnotation{
					Where: "package_id IS NULL AND artifact_id IS NOT NULL",
				},
			},
		},
	}
	// BuildersColumns holds the columns for the "builders" table.
	BuildersColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUUID, Unique: true},
		{Name: "uri", Type: field.TypeString, Unique: true},
	}
	// BuildersTable holds the schema information for the "builders" table.
	BuildersTable = &schema.Table{
		Name:       "builders",
		Columns:    BuildersColumns,
		PrimaryKey: []*schema.Column{BuildersColumns[0]},
		Indexes: []*schema.Index{
			{
				Name:    "builder_uri",
				Unique:  true,
				Columns: []*schema.Column{BuildersColumns[1]},
			},
		},
	}
	// CertificationsColumns holds the columns for the "certifications" table.
	CertificationsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUUID, Unique: true},
		{Name: "type", Type: field.TypeEnum, Enums: []string{"GOOD", "BAD"}, Default: "GOOD"},
		{Name: "justification", Type: field.TypeString},
		{Name: "known_since", Type: field.TypeTime},
		{Name: "origin", Type: field.TypeString},
		{Name: "collector", Type: field.TypeString},
		{Name: "document_ref", Type: field.TypeString},
		{Name: "source_id", Type: field.TypeUUID, Nullable: true},
		{Name: "package_version_id", Type: field.TypeUUID, Nullable: true},
		{Name: "package_name_id", Type: field.TypeUUID, Nullable: true},
		{Name: "artifact_id", Type: field.TypeUUID, Nullable: true},
	}
	// CertificationsTable holds the schema information for the "certifications" table.
	CertificationsTable = &schema.Table{
		Name:       "certifications",
		Columns:    CertificationsColumns,
		PrimaryKey: []*schema.Column{CertificationsColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "certifications_source_names_source",
				Columns:    []*schema.Column{CertificationsColumns[7]},
				RefColumns: []*schema.Column{SourceNamesColumns[0]},
				OnDelete:   schema.SetNull,
			},
			{
				Symbol:     "certifications_package_versions_package_version",
				Columns:    []*schema.Column{CertificationsColumns[8]},
				RefColumns: []*schema.Column{PackageVersionsColumns[0]},
				OnDelete:   schema.SetNull,
			},
			{
				Symbol:     "certifications_package_names_all_versions",
				Columns:    []*schema.Column{CertificationsColumns[9]},
				RefColumns: []*schema.Column{PackageNamesColumns[0]},
				OnDelete:   schema.SetNull,
			},
			{
				Symbol:     "certifications_artifacts_artifact",
				Columns:    []*schema.Column{CertificationsColumns[10]},
				RefColumns: []*schema.Column{ArtifactsColumns[0]},
				OnDelete:   schema.SetNull,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "certification_type_justification_origin_collector_source_id_known_since_document_ref",
				Unique:  true,
				Columns: []*schema.Column{CertificationsColumns[1], CertificationsColumns[2], CertificationsColumns[4], CertificationsColumns[5], CertificationsColumns[7], CertificationsColumns[3], CertificationsColumns[6]},
				Annotation: &entsql.IndexAnnotation{
					Where: "source_id IS NOT NULL AND package_version_id IS NULL AND package_name_id IS NULL AND artifact_id IS NULL",
				},
			},
			{
				Name:    "certification_type_justification_origin_collector_package_version_id_known_since_document_ref",
				Unique:  true,
				Columns: []*schema.Column{CertificationsColumns[1], CertificationsColumns[2], CertificationsColumns[4], CertificationsColumns[5], CertificationsColumns[8], CertificationsColumns[3], CertificationsColumns[6]},
				Annotation: &entsql.IndexAnnotation{
					Where: "source_id IS NULL AND package_version_id IS NOT NULL AND package_name_id IS NULL AND artifact_id IS NULL",
				},
			},
			{
				Name:    "certification_type_justification_origin_collector_package_name_id_known_since_document_ref",
				Unique:  true,
				Columns: []*schema.Column{CertificationsColumns[1], CertificationsColumns[2], CertificationsColumns[4], CertificationsColumns[5], CertificationsColumns[9], CertificationsColumns[3], CertificationsColumns[6]},
				Annotation: &entsql.IndexAnnotation{
					Where: "source_id IS NULL AND package_version_id IS NULL AND package_name_id IS NOT NULL AND artifact_id IS NULL",
				},
			},
			{
				Name:    "certification_type_justification_origin_collector_artifact_id_known_since_document_ref",
				Unique:  true,
				Columns: []*schema.Column{CertificationsColumns[1], CertificationsColumns[2], CertificationsColumns[4], CertificationsColumns[5], CertificationsColumns[10], CertificationsColumns[3], CertificationsColumns[6]},
				Annotation: &entsql.IndexAnnotation{
					Where: "source_id IS NULL AND package_version_id IS NULL AND package_name_id IS NULL AND artifact_id IS NOT NULL",
				},
			},
		},
	}
	// CertifyLegalsColumns holds the columns for the "certify_legals" table.
	CertifyLegalsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUUID, Unique: true},
		{Name: "declared_license", Type: field.TypeString},
		{Name: "discovered_license", Type: field.TypeString},
		{Name: "attribution", Type: field.TypeString},
		{Name: "justification", Type: field.TypeString},
		{Name: "time_scanned", Type: field.TypeTime},
		{Name: "origin", Type: field.TypeString},
		{Name: "collector", Type: field.TypeString},
		{Name: "document_ref", Type: field.TypeString},
		{Name: "declared_licenses_hash", Type: field.TypeString},
		{Name: "discovered_licenses_hash", Type: field.TypeString},
		{Name: "package_id", Type: field.TypeUUID, Nullable: true},
		{Name: "source_id", Type: field.TypeUUID, Nullable: true},
	}
	// CertifyLegalsTable holds the schema information for the "certify_legals" table.
	CertifyLegalsTable = &schema.Table{
		Name:       "certify_legals",
		Columns:    CertifyLegalsColumns,
		PrimaryKey: []*schema.Column{CertifyLegalsColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "certify_legals_package_versions_package",
				Columns:    []*schema.Column{CertifyLegalsColumns[11]},
				RefColumns: []*schema.Column{PackageVersionsColumns[0]},
				OnDelete:   schema.SetNull,
			},
			{
				Symbol:     "certify_legals_source_names_source",
				Columns:    []*schema.Column{CertifyLegalsColumns[12]},
				RefColumns: []*schema.Column{SourceNamesColumns[0]},
				OnDelete:   schema.SetNull,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "certifylegal_source_id_declared_license_justification_time_scanned_origin_collector_document_ref_declared_licenses_hash_discovered_licenses_hash",
				Unique:  true,
				Columns: []*schema.Column{CertifyLegalsColumns[12], CertifyLegalsColumns[1], CertifyLegalsColumns[4], CertifyLegalsColumns[5], CertifyLegalsColumns[6], CertifyLegalsColumns[7], CertifyLegalsColumns[8], CertifyLegalsColumns[9], CertifyLegalsColumns[10]},
				Annotation: &entsql.IndexAnnotation{
					Where: "package_id IS NULL AND source_id IS NOT NULL",
				},
			},
			{
				Name:    "certifylegal_package_id_declared_license_justification_time_scanned_origin_collector_document_ref_declared_licenses_hash_discovered_licenses_hash",
				Unique:  true,
				Columns: []*schema.Column{CertifyLegalsColumns[11], CertifyLegalsColumns[1], CertifyLegalsColumns[4], CertifyLegalsColumns[5], CertifyLegalsColumns[6], CertifyLegalsColumns[7], CertifyLegalsColumns[8], CertifyLegalsColumns[9], CertifyLegalsColumns[10]},
				Annotation: &entsql.IndexAnnotation{
					Where: "package_id IS NOT NULL AND source_id IS NULL",
				},
			},
			{
				Name:    "certifylegal_package_id",
				Unique:  false,
				Columns: []*schema.Column{CertifyLegalsColumns[11]},
				Annotation: &entsql.IndexAnnotation{
					Where: "package_id IS NOT NULL AND source_id IS NULL",
				},
			},
		},
	}
	// CertifyScorecardsColumns holds the columns for the "certify_scorecards" table.
	CertifyScorecardsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUUID, Unique: true},
		{Name: "checks", Type: field.TypeJSON},
		{Name: "aggregate_score", Type: field.TypeFloat64, Default: 0},
		{Name: "time_scanned", Type: field.TypeTime},
		{Name: "scorecard_version", Type: field.TypeString},
		{Name: "scorecard_commit", Type: field.TypeString},
		{Name: "origin", Type: field.TypeString},
		{Name: "collector", Type: field.TypeString},
		{Name: "document_ref", Type: field.TypeString},
		{Name: "checks_hash", Type: field.TypeString},
		{Name: "source_id", Type: field.TypeUUID},
	}
	// CertifyScorecardsTable holds the schema information for the "certify_scorecards" table.
	CertifyScorecardsTable = &schema.Table{
		Name:       "certify_scorecards",
		Columns:    CertifyScorecardsColumns,
		PrimaryKey: []*schema.Column{CertifyScorecardsColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "certify_scorecards_source_names_source",
				Columns:    []*schema.Column{CertifyScorecardsColumns[10]},
				RefColumns: []*schema.Column{SourceNamesColumns[0]},
				OnDelete:   schema.NoAction,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "certifyscorecard_source_id_origin_collector_scorecard_version_scorecard_commit_aggregate_score_time_scanned_checks_hash_document_ref",
				Unique:  true,
				Columns: []*schema.Column{CertifyScorecardsColumns[10], CertifyScorecardsColumns[6], CertifyScorecardsColumns[7], CertifyScorecardsColumns[4], CertifyScorecardsColumns[5], CertifyScorecardsColumns[2], CertifyScorecardsColumns[3], CertifyScorecardsColumns[9], CertifyScorecardsColumns[8]},
			},
		},
	}
	// CertifyVexesColumns holds the columns for the "certify_vexes" table.
	CertifyVexesColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUUID, Unique: true},
		{Name: "known_since", Type: field.TypeTime},
		{Name: "status", Type: field.TypeString},
		{Name: "statement", Type: field.TypeString},
		{Name: "status_notes", Type: field.TypeString},
		{Name: "justification", Type: field.TypeString},
		{Name: "origin", Type: field.TypeString},
		{Name: "collector", Type: field.TypeString},
		{Name: "document_ref", Type: field.TypeString},
		{Name: "package_id", Type: field.TypeUUID, Nullable: true},
		{Name: "artifact_id", Type: field.TypeUUID, Nullable: true},
		{Name: "vulnerability_id", Type: field.TypeUUID},
	}
	// CertifyVexesTable holds the schema information for the "certify_vexes" table.
	CertifyVexesTable = &schema.Table{
		Name:       "certify_vexes",
		Columns:    CertifyVexesColumns,
		PrimaryKey: []*schema.Column{CertifyVexesColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "certify_vexes_package_versions_package",
				Columns:    []*schema.Column{CertifyVexesColumns[9]},
				RefColumns: []*schema.Column{PackageVersionsColumns[0]},
				OnDelete:   schema.SetNull,
			},
			{
				Symbol:     "certify_vexes_artifacts_artifact",
				Columns:    []*schema.Column{CertifyVexesColumns[10]},
				RefColumns: []*schema.Column{ArtifactsColumns[0]},
				OnDelete:   schema.SetNull,
			},
			{
				Symbol:     "certify_vexes_vulnerability_ids_vulnerability",
				Columns:    []*schema.Column{CertifyVexesColumns[11]},
				RefColumns: []*schema.Column{VulnerabilityIdsColumns[0]},
				OnDelete:   schema.NoAction,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "vex_artifact_id",
				Unique:  true,
				Columns: []*schema.Column{CertifyVexesColumns[1], CertifyVexesColumns[5], CertifyVexesColumns[2], CertifyVexesColumns[3], CertifyVexesColumns[4], CertifyVexesColumns[6], CertifyVexesColumns[7], CertifyVexesColumns[8], CertifyVexesColumns[11], CertifyVexesColumns[9]},
				Annotation: &entsql.IndexAnnotation{
					Where: "artifact_id IS NULL",
				},
			},
			{
				Name:    "vex_package_id",
				Unique:  true,
				Columns: []*schema.Column{CertifyVexesColumns[1], CertifyVexesColumns[5], CertifyVexesColumns[2], CertifyVexesColumns[3], CertifyVexesColumns[4], CertifyVexesColumns[6], CertifyVexesColumns[7], CertifyVexesColumns[8], CertifyVexesColumns[11], CertifyVexesColumns[10]},
				Annotation: &entsql.IndexAnnotation{
					Where: "package_id IS NULL",
				},
			},
		},
	}
	// CertifyVulnsColumns holds the columns for the "certify_vulns" table.
	CertifyVulnsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUUID, Unique: true},
		{Name: "time_scanned", Type: field.TypeTime},
		{Name: "db_uri", Type: field.TypeString},
		{Name: "db_version", Type: field.TypeString},
		{Name: "scanner_uri", Type: field.TypeString},
		{Name: "scanner_version", Type: field.TypeString},
		{Name: "origin", Type: field.TypeString},
		{Name: "collector", Type: field.TypeString},
		{Name: "document_ref", Type: field.TypeString},
		{Name: "vulnerability_id", Type: field.TypeUUID},
		{Name: "package_id", Type: field.TypeUUID},
	}
	// CertifyVulnsTable holds the schema information for the "certify_vulns" table.
	CertifyVulnsTable = &schema.Table{
		Name:       "certify_vulns",
		Columns:    CertifyVulnsColumns,
		PrimaryKey: []*schema.Column{CertifyVulnsColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "certify_vulns_vulnerability_ids_vulnerability",
				Columns:    []*schema.Column{CertifyVulnsColumns[9]},
				RefColumns: []*schema.Column{VulnerabilityIdsColumns[0]},
				OnDelete:   schema.Cascade,
			},
			{
				Symbol:     "certify_vulns_package_versions_package",
				Columns:    []*schema.Column{CertifyVulnsColumns[10]},
				RefColumns: []*schema.Column{PackageVersionsColumns[0]},
				OnDelete:   schema.Cascade,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "certifyvuln_db_uri_db_version_scanner_uri_scanner_version_origin_collector_time_scanned_document_ref_vulnerability_id_package_id",
				Unique:  true,
				Columns: []*schema.Column{CertifyVulnsColumns[2], CertifyVulnsColumns[3], CertifyVulnsColumns[4], CertifyVulnsColumns[5], CertifyVulnsColumns[6], CertifyVulnsColumns[7], CertifyVulnsColumns[1], CertifyVulnsColumns[8], CertifyVulnsColumns[9], CertifyVulnsColumns[10]},
			},
			{
				Name:    "certifyvuln_package_id",
				Unique:  false,
				Columns: []*schema.Column{CertifyVulnsColumns[10]},
			},
		},
	}
	// DependenciesColumns holds the columns for the "dependencies" table.
	DependenciesColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUUID, Unique: true},
		{Name: "dependency_type", Type: field.TypeEnum, Enums: []string{"DIRECT", "INDIRECT", "UNKNOWN"}},
		{Name: "justification", Type: field.TypeString},
		{Name: "origin", Type: field.TypeString},
		{Name: "collector", Type: field.TypeString},
		{Name: "document_ref", Type: field.TypeString},
		{Name: "package_id", Type: field.TypeUUID},
		{Name: "dependent_package_version_id", Type: field.TypeUUID},
	}
	// DependenciesTable holds the schema information for the "dependencies" table.
	DependenciesTable = &schema.Table{
		Name:       "dependencies",
		Columns:    DependenciesColumns,
		PrimaryKey: []*schema.Column{DependenciesColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "dependencies_package_versions_package",
				Columns:    []*schema.Column{DependenciesColumns[6]},
				RefColumns: []*schema.Column{PackageVersionsColumns[0]},
				OnDelete:   schema.Cascade,
			},
			{
				Symbol:     "dependencies_package_versions_dependent_package_version",
				Columns:    []*schema.Column{DependenciesColumns[7]},
				RefColumns: []*schema.Column{PackageVersionsColumns[0]},
				OnDelete:   schema.Cascade,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "dependency_dependency_type_justification_origin_collector_document_ref_package_id_dependent_package_version_id",
				Unique:  true,
				Columns: []*schema.Column{DependenciesColumns[1], DependenciesColumns[2], DependenciesColumns[3], DependenciesColumns[4], DependenciesColumns[5], DependenciesColumns[6], DependenciesColumns[7]},
			},
			{
				Name:    "dependency_package_id",
				Unique:  false,
				Columns: []*schema.Column{DependenciesColumns[6]},
			},
			{
				Name:    "dependency_dependent_package_version_id",
				Unique:  false,
				Columns: []*schema.Column{DependenciesColumns[7]},
			},
		},
	}
	// HasMetadataColumns holds the columns for the "has_metadata" table.
	HasMetadataColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUUID, Unique: true},
		{Name: "timestamp", Type: field.TypeTime},
		{Name: "key", Type: field.TypeString},
		{Name: "value", Type: field.TypeString},
		{Name: "justification", Type: field.TypeString},
		{Name: "origin", Type: field.TypeString},
		{Name: "collector", Type: field.TypeString},
		{Name: "document_ref", Type: field.TypeString},
		{Name: "source_id", Type: field.TypeUUID, Nullable: true},
		{Name: "package_version_id", Type: field.TypeUUID, Nullable: true},
		{Name: "package_name_id", Type: field.TypeUUID, Nullable: true},
		{Name: "artifact_id", Type: field.TypeUUID, Nullable: true},
	}
	// HasMetadataTable holds the schema information for the "has_metadata" table.
	HasMetadataTable = &schema.Table{
		Name:       "has_metadata",
		Columns:    HasMetadataColumns,
		PrimaryKey: []*schema.Column{HasMetadataColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "has_metadata_source_names_source",
				Columns:    []*schema.Column{HasMetadataColumns[8]},
				RefColumns: []*schema.Column{SourceNamesColumns[0]},
				OnDelete:   schema.SetNull,
			},
			{
				Symbol:     "has_metadata_package_versions_package_version",
				Columns:    []*schema.Column{HasMetadataColumns[9]},
				RefColumns: []*schema.Column{PackageVersionsColumns[0]},
				OnDelete:   schema.SetNull,
			},
			{
				Symbol:     "has_metadata_package_names_all_versions",
				Columns:    []*schema.Column{HasMetadataColumns[10]},
				RefColumns: []*schema.Column{PackageNamesColumns[0]},
				OnDelete:   schema.SetNull,
			},
			{
				Symbol:     "has_metadata_artifacts_artifact",
				Columns:    []*schema.Column{HasMetadataColumns[11]},
				RefColumns: []*schema.Column{ArtifactsColumns[0]},
				OnDelete:   schema.SetNull,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "has_metadata_source_id",
				Unique:  true,
				Columns: []*schema.Column{HasMetadataColumns[2], HasMetadataColumns[3], HasMetadataColumns[4], HasMetadataColumns[5], HasMetadataColumns[6], HasMetadataColumns[1], HasMetadataColumns[7], HasMetadataColumns[8]},
				Annotation: &entsql.IndexAnnotation{
					Where: "source_id IS NOT NULL AND package_version_id IS NULL AND package_name_id IS NULL AND artifact_id IS NULL",
				},
			},
			{
				Name:    "has_metadata_package_version_id",
				Unique:  true,
				Columns: []*schema.Column{HasMetadataColumns[2], HasMetadataColumns[3], HasMetadataColumns[4], HasMetadataColumns[5], HasMetadataColumns[6], HasMetadataColumns[1], HasMetadataColumns[7], HasMetadataColumns[9]},
				Annotation: &entsql.IndexAnnotation{
					Where: "source_id IS NULL AND package_version_id IS NOT NULL AND package_name_id IS NULL AND artifact_id IS NULL",
				},
			},
			{
				Name:    "has_metadata_package_name_id",
				Unique:  true,
				Columns: []*schema.Column{HasMetadataColumns[2], HasMetadataColumns[3], HasMetadataColumns[4], HasMetadataColumns[5], HasMetadataColumns[6], HasMetadataColumns[1], HasMetadataColumns[7], HasMetadataColumns[10]},
				Annotation: &entsql.IndexAnnotation{
					Where: "source_id IS NULL AND package_version_id IS NULL AND package_name_id IS NOT NULL AND artifact_id IS NULL",
				},
			},
			{
				Name:    "has_metadata_artifact_id",
				Unique:  true,
				Columns: []*schema.Column{HasMetadataColumns[2], HasMetadataColumns[3], HasMetadataColumns[4], HasMetadataColumns[5], HasMetadataColumns[6], HasMetadataColumns[1], HasMetadataColumns[7], HasMetadataColumns[11]},
				Annotation: &entsql.IndexAnnotation{
					Where: "source_id IS NULL AND package_version_id IS NULL AND package_name_id IS NULL AND artifact_id IS NOT NULL",
				},
			},
		},
	}
	// HasSourceAtsColumns holds the columns for the "has_source_ats" table.
	HasSourceAtsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUUID, Unique: true},
		{Name: "known_since", Type: field.TypeTime},
		{Name: "justification", Type: field.TypeString},
		{Name: "origin", Type: field.TypeString},
		{Name: "collector", Type: field.TypeString},
		{Name: "document_ref", Type: field.TypeString},
		{Name: "package_version_id", Type: field.TypeUUID, Nullable: true},
		{Name: "package_name_id", Type: field.TypeUUID, Nullable: true},
		{Name: "source_id", Type: field.TypeUUID},
	}
	// HasSourceAtsTable holds the schema information for the "has_source_ats" table.
	HasSourceAtsTable = &schema.Table{
		Name:       "has_source_ats",
		Columns:    HasSourceAtsColumns,
		PrimaryKey: []*schema.Column{HasSourceAtsColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "has_source_ats_package_versions_package_version",
				Columns:    []*schema.Column{HasSourceAtsColumns[6]},
				RefColumns: []*schema.Column{PackageVersionsColumns[0]},
				OnDelete:   schema.SetNull,
			},
			{
				Symbol:     "has_source_ats_package_names_all_versions",
				Columns:    []*schema.Column{HasSourceAtsColumns[7]},
				RefColumns: []*schema.Column{PackageNamesColumns[0]},
				OnDelete:   schema.SetNull,
			},
			{
				Symbol:     "has_source_ats_source_names_source",
				Columns:    []*schema.Column{HasSourceAtsColumns[8]},
				RefColumns: []*schema.Column{SourceNamesColumns[0]},
				OnDelete:   schema.NoAction,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "hassourceat_source_id_package_version_id_justification_origin_collector_known_since_document_ref",
				Unique:  true,
				Columns: []*schema.Column{HasSourceAtsColumns[8], HasSourceAtsColumns[6], HasSourceAtsColumns[2], HasSourceAtsColumns[3], HasSourceAtsColumns[4], HasSourceAtsColumns[1], HasSourceAtsColumns[5]},
				Annotation: &entsql.IndexAnnotation{
					Where: "package_version_id IS NOT NULL AND package_name_id IS NULL",
				},
			},
			{
				Name:    "hassourceat_source_id_package_name_id_justification_origin_collector_known_since_document_ref",
				Unique:  true,
				Columns: []*schema.Column{HasSourceAtsColumns[8], HasSourceAtsColumns[7], HasSourceAtsColumns[2], HasSourceAtsColumns[3], HasSourceAtsColumns[4], HasSourceAtsColumns[1], HasSourceAtsColumns[5]},
				Annotation: &entsql.IndexAnnotation{
					Where: "package_name_id IS NOT NULL AND package_version_id IS NULL",
				},
			},
		},
	}
	// HashEqualsColumns holds the columns for the "hash_equals" table.
	HashEqualsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUUID, Unique: true},
		{Name: "origin", Type: field.TypeString},
		{Name: "collector", Type: field.TypeString},
		{Name: "justification", Type: field.TypeString},
		{Name: "document_ref", Type: field.TypeString},
		{Name: "artifacts_hash", Type: field.TypeString},
		{Name: "art_id", Type: field.TypeUUID},
		{Name: "equal_art_id", Type: field.TypeUUID},
	}
	// HashEqualsTable holds the schema information for the "hash_equals" table.
	HashEqualsTable = &schema.Table{
		Name:       "hash_equals",
		Columns:    HashEqualsColumns,
		PrimaryKey: []*schema.Column{HashEqualsColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "hash_equals_artifacts_artifact_a",
				Columns:    []*schema.Column{HashEqualsColumns[6]},
				RefColumns: []*schema.Column{ArtifactsColumns[0]},
				OnDelete:   schema.NoAction,
			},
			{
				Symbol:     "hash_equals_artifacts_artifact_b",
				Columns:    []*schema.Column{HashEqualsColumns[7]},
				RefColumns: []*schema.Column{ArtifactsColumns[0]},
				OnDelete:   schema.NoAction,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "hashequal_art_id_equal_art_id_artifacts_hash_origin_justification_collector_document_ref",
				Unique:  true,
				Columns: []*schema.Column{HashEqualsColumns[6], HashEqualsColumns[7], HashEqualsColumns[5], HashEqualsColumns[1], HashEqualsColumns[3], HashEqualsColumns[2], HashEqualsColumns[4]},
			},
		},
	}
	// LicensesColumns holds the columns for the "licenses" table.
	LicensesColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUUID, Unique: true},
		{Name: "name", Type: field.TypeString},
		{Name: "inline", Type: field.TypeString, Nullable: true},
		{Name: "list_version", Type: field.TypeString, Nullable: true},
	}
	// LicensesTable holds the schema information for the "licenses" table.
	LicensesTable = &schema.Table{
		Name:       "licenses",
		Columns:    LicensesColumns,
		PrimaryKey: []*schema.Column{LicensesColumns[0]},
		Indexes: []*schema.Index{
			{
				Name:    "license_name_inline_list_version",
				Unique:  true,
				Columns: []*schema.Column{LicensesColumns[1], LicensesColumns[2], LicensesColumns[3]},
			},
		},
	}
	// OccurrencesColumns holds the columns for the "occurrences" table.
	OccurrencesColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUUID, Unique: true},
		{Name: "justification", Type: field.TypeString},
		{Name: "origin", Type: field.TypeString},
		{Name: "collector", Type: field.TypeString},
		{Name: "document_ref", Type: field.TypeString},
		{Name: "artifact_id", Type: field.TypeUUID},
		{Name: "package_id", Type: field.TypeUUID, Nullable: true},
		{Name: "source_id", Type: field.TypeUUID, Nullable: true},
	}
	// OccurrencesTable holds the schema information for the "occurrences" table.
	OccurrencesTable = &schema.Table{
		Name:       "occurrences",
		Columns:    OccurrencesColumns,
		PrimaryKey: []*schema.Column{OccurrencesColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "occurrences_artifacts_artifact",
				Columns:    []*schema.Column{OccurrencesColumns[5]},
				RefColumns: []*schema.Column{ArtifactsColumns[0]},
				OnDelete:   schema.Cascade,
			},
			{
				Symbol:     "occurrences_package_versions_package",
				Columns:    []*schema.Column{OccurrencesColumns[6]},
				RefColumns: []*schema.Column{PackageVersionsColumns[0]},
				OnDelete:   schema.Cascade,
			},
			{
				Symbol:     "occurrences_source_names_source",
				Columns:    []*schema.Column{OccurrencesColumns[7]},
				RefColumns: []*schema.Column{SourceNamesColumns[0]},
				OnDelete:   schema.Cascade,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "occurrence_package_id",
				Unique:  true,
				Columns: []*schema.Column{OccurrencesColumns[1], OccurrencesColumns[2], OccurrencesColumns[3], OccurrencesColumns[4], OccurrencesColumns[5], OccurrencesColumns[6]},
				Annotation: &entsql.IndexAnnotation{
					Where: "package_id IS NOT NULL AND source_id IS NULL",
				},
			},
			{
				Name:    "occurrence_source_id",
				Unique:  true,
				Columns: []*schema.Column{OccurrencesColumns[1], OccurrencesColumns[2], OccurrencesColumns[3], OccurrencesColumns[4], OccurrencesColumns[5], OccurrencesColumns[7]},
				Annotation: &entsql.IndexAnnotation{
					Where: "package_id IS NULL AND source_id IS NOT NULL",
				},
			},
			{
				Name:    "query_occurrence_package_id",
				Unique:  false,
				Columns: []*schema.Column{OccurrencesColumns[6]},
				Annotation: &entsql.IndexAnnotation{
					Where: "package_id IS NOT NULL AND source_id IS NULL",
				},
			},
			{
				Name:    "occurrence_artifact_id",
				Unique:  false,
				Columns: []*schema.Column{OccurrencesColumns[5]},
			},
		},
	}
	// PackageNamesColumns holds the columns for the "package_names" table.
	PackageNamesColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUUID, Unique: true},
		{Name: "type", Type: field.TypeString},
		{Name: "namespace", Type: field.TypeString},
		{Name: "name", Type: field.TypeString},
	}
	// PackageNamesTable holds the schema information for the "package_names" table.
	PackageNamesTable = &schema.Table{
		Name:       "package_names",
		Columns:    PackageNamesColumns,
		PrimaryKey: []*schema.Column{PackageNamesColumns[0]},
		Indexes: []*schema.Index{
			{
				Name:    "packagename_name_namespace_type",
				Unique:  true,
				Columns: []*schema.Column{PackageNamesColumns[3], PackageNamesColumns[2], PackageNamesColumns[1]},
			},
		},
	}
	// PackageVersionsColumns holds the columns for the "package_versions" table.
	PackageVersionsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUUID, Unique: true},
		{Name: "version", Type: field.TypeString, Default: ""},
		{Name: "subpath", Type: field.TypeString, Default: ""},
		{Name: "qualifiers", Type: field.TypeJSON, Nullable: true},
		{Name: "hash", Type: field.TypeString},
		{Name: "name_id", Type: field.TypeUUID},
	}
	// PackageVersionsTable holds the schema information for the "package_versions" table.
	PackageVersionsTable = &schema.Table{
		Name:       "package_versions",
		Columns:    PackageVersionsColumns,
		PrimaryKey: []*schema.Column{PackageVersionsColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "package_versions_package_names_versions",
				Columns:    []*schema.Column{PackageVersionsColumns[5]},
				RefColumns: []*schema.Column{PackageNamesColumns[0]},
				OnDelete:   schema.Cascade,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "packageversion_hash_name_id",
				Unique:  true,
				Columns: []*schema.Column{PackageVersionsColumns[4], PackageVersionsColumns[5]},
			},
			{
				Name:    "packageversion_qualifiers",
				Unique:  false,
				Columns: []*schema.Column{PackageVersionsColumns[3]},
				Annotation: &entsql.IndexAnnotation{
					Types: map[string]string{
						"postgres": "GIN",
					},
				},
			},
			{
				Name:    "packageversion_version_subpath_qualifiers_name_id",
				Unique:  true,
				Columns: []*schema.Column{PackageVersionsColumns[1], PackageVersionsColumns[2], PackageVersionsColumns[3], PackageVersionsColumns[5]},
			},
		},
	}
	// PkgEqualsColumns holds the columns for the "pkg_equals" table.
	PkgEqualsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUUID, Unique: true},
		{Name: "origin", Type: field.TypeString},
		{Name: "collector", Type: field.TypeString},
		{Name: "document_ref", Type: field.TypeString},
		{Name: "justification", Type: field.TypeString},
		{Name: "packages_hash", Type: field.TypeString},
		{Name: "pkg_id", Type: field.TypeUUID},
		{Name: "equal_pkg_id", Type: field.TypeUUID},
	}
	// PkgEqualsTable holds the schema information for the "pkg_equals" table.
	PkgEqualsTable = &schema.Table{
		Name:       "pkg_equals",
		Columns:    PkgEqualsColumns,
		PrimaryKey: []*schema.Column{PkgEqualsColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "pkg_equals_package_versions_package_a",
				Columns:    []*schema.Column{PkgEqualsColumns[6]},
				RefColumns: []*schema.Column{PackageVersionsColumns[0]},
				OnDelete:   schema.NoAction,
			},
			{
				Symbol:     "pkg_equals_package_versions_package_b",
				Columns:    []*schema.Column{PkgEqualsColumns[7]},
				RefColumns: []*schema.Column{PackageVersionsColumns[0]},
				OnDelete:   schema.NoAction,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "pkgequal_pkg_id_equal_pkg_id_packages_hash_origin_justification_collector_document_ref",
				Unique:  true,
				Columns: []*schema.Column{PkgEqualsColumns[6], PkgEqualsColumns[7], PkgEqualsColumns[5], PkgEqualsColumns[1], PkgEqualsColumns[4], PkgEqualsColumns[2], PkgEqualsColumns[3]},
			},
		},
	}
	// PointOfContactsColumns holds the columns for the "point_of_contacts" table.
	PointOfContactsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUUID, Unique: true},
		{Name: "email", Type: field.TypeString},
		{Name: "info", Type: field.TypeString},
		{Name: "since", Type: field.TypeTime},
		{Name: "justification", Type: field.TypeString},
		{Name: "origin", Type: field.TypeString},
		{Name: "collector", Type: field.TypeString},
		{Name: "document_ref", Type: field.TypeString},
		{Name: "source_id", Type: field.TypeUUID, Nullable: true},
		{Name: "package_version_id", Type: field.TypeUUID, Nullable: true},
		{Name: "package_name_id", Type: field.TypeUUID, Nullable: true},
		{Name: "artifact_id", Type: field.TypeUUID, Nullable: true},
	}
	// PointOfContactsTable holds the schema information for the "point_of_contacts" table.
	PointOfContactsTable = &schema.Table{
		Name:       "point_of_contacts",
		Columns:    PointOfContactsColumns,
		PrimaryKey: []*schema.Column{PointOfContactsColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "point_of_contacts_source_names_source",
				Columns:    []*schema.Column{PointOfContactsColumns[8]},
				RefColumns: []*schema.Column{SourceNamesColumns[0]},
				OnDelete:   schema.SetNull,
			},
			{
				Symbol:     "point_of_contacts_package_versions_package_version",
				Columns:    []*schema.Column{PointOfContactsColumns[9]},
				RefColumns: []*schema.Column{PackageVersionsColumns[0]},
				OnDelete:   schema.SetNull,
			},
			{
				Symbol:     "point_of_contacts_package_names_all_versions",
				Columns:    []*schema.Column{PointOfContactsColumns[10]},
				RefColumns: []*schema.Column{PackageNamesColumns[0]},
				OnDelete:   schema.SetNull,
			},
			{
				Symbol:     "point_of_contacts_artifacts_artifact",
				Columns:    []*schema.Column{PointOfContactsColumns[11]},
				RefColumns: []*schema.Column{ArtifactsColumns[0]},
				OnDelete:   schema.SetNull,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "poc_source_id",
				Unique:  true,
				Columns: []*schema.Column{PointOfContactsColumns[3], PointOfContactsColumns[1], PointOfContactsColumns[2], PointOfContactsColumns[4], PointOfContactsColumns[5], PointOfContactsColumns[6], PointOfContactsColumns[7], PointOfContactsColumns[8]},
				Annotation: &entsql.IndexAnnotation{
					Where: "source_id IS NOT NULL AND package_version_id IS NULL AND package_name_id IS NULL AND artifact_id IS NULL",
				},
			},
			{
				Name:    "poc_package_version_id",
				Unique:  true,
				Columns: []*schema.Column{PointOfContactsColumns[3], PointOfContactsColumns[1], PointOfContactsColumns[2], PointOfContactsColumns[4], PointOfContactsColumns[5], PointOfContactsColumns[6], PointOfContactsColumns[7], PointOfContactsColumns[9]},
				Annotation: &entsql.IndexAnnotation{
					Where: "source_id IS NULL AND package_version_id IS NOT NULL AND package_name_id IS NULL AND artifact_id IS NULL",
				},
			},
			{
				Name:    "poc_package_name_id",
				Unique:  true,
				Columns: []*schema.Column{PointOfContactsColumns[3], PointOfContactsColumns[1], PointOfContactsColumns[2], PointOfContactsColumns[4], PointOfContactsColumns[5], PointOfContactsColumns[6], PointOfContactsColumns[7], PointOfContactsColumns[10]},
				Annotation: &entsql.IndexAnnotation{
					Where: "source_id IS NULL AND package_version_id IS NULL AND package_name_id IS NOT NULL AND artifact_id IS NULL",
				},
			},
			{
				Name:    "poc_artifact_id",
				Unique:  true,
				Columns: []*schema.Column{PointOfContactsColumns[3], PointOfContactsColumns[1], PointOfContactsColumns[2], PointOfContactsColumns[4], PointOfContactsColumns[5], PointOfContactsColumns[6], PointOfContactsColumns[7], PointOfContactsColumns[11]},
				Annotation: &entsql.IndexAnnotation{
					Where: "source_id IS NULL AND package_version_id IS NULL AND package_name_id IS NULL AND artifact_id IS NOT NULL",
				},
			},
		},
	}
	// SlsaAttestationsColumns holds the columns for the "slsa_attestations" table.
	SlsaAttestationsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUUID, Unique: true},
		{Name: "build_type", Type: field.TypeString},
		{Name: "slsa_predicate", Type: field.TypeJSON, Nullable: true},
		{Name: "slsa_version", Type: field.TypeString},
		{Name: "started_on", Type: field.TypeTime},
		{Name: "finished_on", Type: field.TypeTime},
		{Name: "origin", Type: field.TypeString},
		{Name: "collector", Type: field.TypeString},
		{Name: "document_ref", Type: field.TypeString},
		{Name: "built_from_hash", Type: field.TypeString},
		{Name: "built_by_id", Type: field.TypeUUID},
		{Name: "subject_id", Type: field.TypeUUID},
	}
	// SlsaAttestationsTable holds the schema information for the "slsa_attestations" table.
	SlsaAttestationsTable = &schema.Table{
		Name:       "slsa_attestations",
		Columns:    SlsaAttestationsColumns,
		PrimaryKey: []*schema.Column{SlsaAttestationsColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "slsa_attestations_builders_built_by",
				Columns:    []*schema.Column{SlsaAttestationsColumns[10]},
				RefColumns: []*schema.Column{BuildersColumns[0]},
				OnDelete:   schema.Cascade,
			},
			{
				Symbol:     "slsa_attestations_artifacts_subject",
				Columns:    []*schema.Column{SlsaAttestationsColumns[11]},
				RefColumns: []*schema.Column{ArtifactsColumns[0]},
				OnDelete:   schema.Cascade,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "slsaattestation_subject_id_origin_collector_document_ref_build_type_slsa_version_built_by_id_built_from_hash_started_on_finished_on",
				Unique:  true,
				Columns: []*schema.Column{SlsaAttestationsColumns[11], SlsaAttestationsColumns[6], SlsaAttestationsColumns[7], SlsaAttestationsColumns[8], SlsaAttestationsColumns[1], SlsaAttestationsColumns[3], SlsaAttestationsColumns[10], SlsaAttestationsColumns[9], SlsaAttestationsColumns[4], SlsaAttestationsColumns[5]},
			},
		},
	}
	// SourceNamesColumns holds the columns for the "source_names" table.
	SourceNamesColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUUID, Unique: true},
		{Name: "type", Type: field.TypeString},
		{Name: "namespace", Type: field.TypeString},
		{Name: "name", Type: field.TypeString},
		{Name: "commit", Type: field.TypeString, Nullable: true},
		{Name: "tag", Type: field.TypeString, Nullable: true},
	}
	// SourceNamesTable holds the schema information for the "source_names" table.
	SourceNamesTable = &schema.Table{
		Name:       "source_names",
		Columns:    SourceNamesColumns,
		PrimaryKey: []*schema.Column{SourceNamesColumns[0]},
		Indexes: []*schema.Index{
			{
				Name:    "sourcename_type_namespace_name_commit_tag",
				Unique:  true,
				Columns: []*schema.Column{SourceNamesColumns[1], SourceNamesColumns[2], SourceNamesColumns[3], SourceNamesColumns[4], SourceNamesColumns[5]},
			},
		},
	}
	// VulnEqualsColumns holds the columns for the "vuln_equals" table.
	VulnEqualsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUUID, Unique: true},
		{Name: "justification", Type: field.TypeString},
		{Name: "origin", Type: field.TypeString},
		{Name: "collector", Type: field.TypeString},
		{Name: "document_ref", Type: field.TypeString},
		{Name: "vulnerabilities_hash", Type: field.TypeString},
		{Name: "vuln_id", Type: field.TypeUUID},
		{Name: "equal_vuln_id", Type: field.TypeUUID},
	}
	// VulnEqualsTable holds the schema information for the "vuln_equals" table.
	VulnEqualsTable = &schema.Table{
		Name:       "vuln_equals",
		Columns:    VulnEqualsColumns,
		PrimaryKey: []*schema.Column{VulnEqualsColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "vuln_equals_vulnerability_ids_vulnerability_a",
				Columns:    []*schema.Column{VulnEqualsColumns[6]},
				RefColumns: []*schema.Column{VulnerabilityIdsColumns[0]},
				OnDelete:   schema.NoAction,
			},
			{
				Symbol:     "vuln_equals_vulnerability_ids_vulnerability_b",
				Columns:    []*schema.Column{VulnEqualsColumns[7]},
				RefColumns: []*schema.Column{VulnerabilityIdsColumns[0]},
				OnDelete:   schema.NoAction,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "vulnequal_vuln_id_equal_vuln_id_vulnerabilities_hash_justification_origin_collector_document_ref",
				Unique:  true,
				Columns: []*schema.Column{VulnEqualsColumns[6], VulnEqualsColumns[7], VulnEqualsColumns[5], VulnEqualsColumns[1], VulnEqualsColumns[2], VulnEqualsColumns[3], VulnEqualsColumns[4]},
			},
		},
	}
	// VulnerabilityIdsColumns holds the columns for the "vulnerability_ids" table.
	VulnerabilityIdsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUUID, Unique: true},
		{Name: "vulnerability_id", Type: field.TypeString},
		{Name: "type", Type: field.TypeString},
	}
	// VulnerabilityIdsTable holds the schema information for the "vulnerability_ids" table.
	VulnerabilityIdsTable = &schema.Table{
		Name:       "vulnerability_ids",
		Columns:    VulnerabilityIdsColumns,
		PrimaryKey: []*schema.Column{VulnerabilityIdsColumns[0]},
		Indexes: []*schema.Index{
			{
				Name:    "vulnerabilityid_vulnerability_id_type",
				Unique:  true,
				Columns: []*schema.Column{VulnerabilityIdsColumns[1], VulnerabilityIdsColumns[2]},
			},
			{
				Name:    "vulnerabilityid_type",
				Unique:  false,
				Columns: []*schema.Column{VulnerabilityIdsColumns[2]},
			},
		},
	}
	// VulnerabilityMetadataColumns holds the columns for the "vulnerability_metadata" table.
	VulnerabilityMetadataColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUUID, Unique: true},
		{Name: "score_type", Type: field.TypeEnum, Enums: []string{"CVSSv2", "CVSSv3", "EPSSv1", "EPSSv2", "CVSSv31", "CVSSv4", "OWASP", "SSVC"}},
		{Name: "score_value", Type: field.TypeFloat64},
		{Name: "timestamp", Type: field.TypeTime},
		{Name: "origin", Type: field.TypeString},
		{Name: "collector", Type: field.TypeString},
		{Name: "document_ref", Type: field.TypeString},
		{Name: "vulnerability_id_id", Type: field.TypeUUID},
	}
	// VulnerabilityMetadataTable holds the schema information for the "vulnerability_metadata" table.
	VulnerabilityMetadataTable = &schema.Table{
		Name:       "vulnerability_metadata",
		Columns:    VulnerabilityMetadataColumns,
		PrimaryKey: []*schema.Column{VulnerabilityMetadataColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "vulnerability_metadata_vulnerability_ids_vulnerability_id",
				Columns:    []*schema.Column{VulnerabilityMetadataColumns[7]},
				RefColumns: []*schema.Column{VulnerabilityIdsColumns[0]},
				OnDelete:   schema.NoAction,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "vulnerabilitymetadata_vulnerability_id_id_score_type_score_value_timestamp_origin_collector_document_ref",
				Unique:  true,
				Columns: []*schema.Column{VulnerabilityMetadataColumns[7], VulnerabilityMetadataColumns[1], VulnerabilityMetadataColumns[2], VulnerabilityMetadataColumns[3], VulnerabilityMetadataColumns[4], VulnerabilityMetadataColumns[5], VulnerabilityMetadataColumns[6]},
			},
		},
	}
	// BillOfMaterialsIncludedSoftwarePackagesColumns holds the columns for the "bill_of_materials_included_software_packages" table.
	BillOfMaterialsIncludedSoftwarePackagesColumns = []*schema.Column{
		{Name: "bill_of_materials_id", Type: field.TypeUUID},
		{Name: "package_version_id", Type: field.TypeUUID},
	}
	// BillOfMaterialsIncludedSoftwarePackagesTable holds the schema information for the "bill_of_materials_included_software_packages" table.
	BillOfMaterialsIncludedSoftwarePackagesTable = &schema.Table{
		Name:       "bill_of_materials_included_software_packages",
		Columns:    BillOfMaterialsIncludedSoftwarePackagesColumns,
		PrimaryKey: []*schema.Column{BillOfMaterialsIncludedSoftwarePackagesColumns[0], BillOfMaterialsIncludedSoftwarePackagesColumns[1]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "bill_of_materials_included_software_packages_bill_of_materials_id",
				Columns:    []*schema.Column{BillOfMaterialsIncludedSoftwarePackagesColumns[0]},
				RefColumns: []*schema.Column{BillOfMaterialsColumns[0]},
				OnDelete:   schema.Cascade,
			},
			{
				Symbol:     "bill_of_materials_included_software_packages_package_version_id",
				Columns:    []*schema.Column{BillOfMaterialsIncludedSoftwarePackagesColumns[1]},
				RefColumns: []*schema.Column{PackageVersionsColumns[0]},
				OnDelete:   schema.Cascade,
			},
		},
	}
	// BillOfMaterialsIncludedSoftwareArtifactsColumns holds the columns for the "bill_of_materials_included_software_artifacts" table.
	BillOfMaterialsIncludedSoftwareArtifactsColumns = []*schema.Column{
		{Name: "bill_of_materials_id", Type: field.TypeUUID},
		{Name: "artifact_id", Type: field.TypeUUID},
	}
	// BillOfMaterialsIncludedSoftwareArtifactsTable holds the schema information for the "bill_of_materials_included_software_artifacts" table.
	BillOfMaterialsIncludedSoftwareArtifactsTable = &schema.Table{
		Name:       "bill_of_materials_included_software_artifacts",
		Columns:    BillOfMaterialsIncludedSoftwareArtifactsColumns,
		PrimaryKey: []*schema.Column{BillOfMaterialsIncludedSoftwareArtifactsColumns[0], BillOfMaterialsIncludedSoftwareArtifactsColumns[1]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "bill_of_materials_included_software_artifacts_bill_of_materials_id",
				Columns:    []*schema.Column{BillOfMaterialsIncludedSoftwareArtifactsColumns[0]},
				RefColumns: []*schema.Column{BillOfMaterialsColumns[0]},
				OnDelete:   schema.Cascade,
			},
			{
				Symbol:     "bill_of_materials_included_software_artifacts_artifact_id",
				Columns:    []*schema.Column{BillOfMaterialsIncludedSoftwareArtifactsColumns[1]},
				RefColumns: []*schema.Column{ArtifactsColumns[0]},
				OnDelete:   schema.Cascade,
			},
		},
	}
	// BillOfMaterialsIncludedDependenciesColumns holds the columns for the "bill_of_materials_included_dependencies" table.
	BillOfMaterialsIncludedDependenciesColumns = []*schema.Column{
		{Name: "bill_of_materials_id", Type: field.TypeUUID},
		{Name: "dependency_id", Type: field.TypeUUID},
	}
	// BillOfMaterialsIncludedDependenciesTable holds the schema information for the "bill_of_materials_included_dependencies" table.
	BillOfMaterialsIncludedDependenciesTable = &schema.Table{
		Name:       "bill_of_materials_included_dependencies",
		Columns:    BillOfMaterialsIncludedDependenciesColumns,
		PrimaryKey: []*schema.Column{BillOfMaterialsIncludedDependenciesColumns[0], BillOfMaterialsIncludedDependenciesColumns[1]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "bill_of_materials_included_dependencies_bill_of_materials_id",
				Columns:    []*schema.Column{BillOfMaterialsIncludedDependenciesColumns[0]},
				RefColumns: []*schema.Column{BillOfMaterialsColumns[0]},
				OnDelete:   schema.Cascade,
			},
			{
				Symbol:     "bill_of_materials_included_dependencies_dependency_id",
				Columns:    []*schema.Column{BillOfMaterialsIncludedDependenciesColumns[1]},
				RefColumns: []*schema.Column{DependenciesColumns[0]},
				OnDelete:   schema.Cascade,
			},
		},
	}
	// BillOfMaterialsIncludedOccurrencesColumns holds the columns for the "bill_of_materials_included_occurrences" table.
	BillOfMaterialsIncludedOccurrencesColumns = []*schema.Column{
		{Name: "bill_of_materials_id", Type: field.TypeUUID},
		{Name: "occurrence_id", Type: field.TypeUUID},
	}
	// BillOfMaterialsIncludedOccurrencesTable holds the schema information for the "bill_of_materials_included_occurrences" table.
	BillOfMaterialsIncludedOccurrencesTable = &schema.Table{
		Name:       "bill_of_materials_included_occurrences",
		Columns:    BillOfMaterialsIncludedOccurrencesColumns,
		PrimaryKey: []*schema.Column{BillOfMaterialsIncludedOccurrencesColumns[0], BillOfMaterialsIncludedOccurrencesColumns[1]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "bill_of_materials_included_occurrences_bill_of_materials_id",
				Columns:    []*schema.Column{BillOfMaterialsIncludedOccurrencesColumns[0]},
				RefColumns: []*schema.Column{BillOfMaterialsColumns[0]},
				OnDelete:   schema.Cascade,
			},
			{
				Symbol:     "bill_of_materials_included_occurrences_occurrence_id",
				Columns:    []*schema.Column{BillOfMaterialsIncludedOccurrencesColumns[1]},
				RefColumns: []*schema.Column{OccurrencesColumns[0]},
				OnDelete:   schema.Cascade,
			},
		},
	}
	// CertifyLegalDeclaredLicensesColumns holds the columns for the "certify_legal_declared_licenses" table.
	CertifyLegalDeclaredLicensesColumns = []*schema.Column{
		{Name: "certify_legal_id", Type: field.TypeUUID},
		{Name: "license_id", Type: field.TypeUUID},
	}
	// CertifyLegalDeclaredLicensesTable holds the schema information for the "certify_legal_declared_licenses" table.
	CertifyLegalDeclaredLicensesTable = &schema.Table{
		Name:       "certify_legal_declared_licenses",
		Columns:    CertifyLegalDeclaredLicensesColumns,
		PrimaryKey: []*schema.Column{CertifyLegalDeclaredLicensesColumns[0], CertifyLegalDeclaredLicensesColumns[1]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "certify_legal_declared_licenses_certify_legal_id",
				Columns:    []*schema.Column{CertifyLegalDeclaredLicensesColumns[0]},
				RefColumns: []*schema.Column{CertifyLegalsColumns[0]},
				OnDelete:   schema.Cascade,
			},
			{
				Symbol:     "certify_legal_declared_licenses_license_id",
				Columns:    []*schema.Column{CertifyLegalDeclaredLicensesColumns[1]},
				RefColumns: []*schema.Column{LicensesColumns[0]},
				OnDelete:   schema.Cascade,
			},
		},
	}
	// CertifyLegalDiscoveredLicensesColumns holds the columns for the "certify_legal_discovered_licenses" table.
	CertifyLegalDiscoveredLicensesColumns = []*schema.Column{
		{Name: "certify_legal_id", Type: field.TypeUUID},
		{Name: "license_id", Type: field.TypeUUID},
	}
	// CertifyLegalDiscoveredLicensesTable holds the schema information for the "certify_legal_discovered_licenses" table.
	CertifyLegalDiscoveredLicensesTable = &schema.Table{
		Name:       "certify_legal_discovered_licenses",
		Columns:    CertifyLegalDiscoveredLicensesColumns,
		PrimaryKey: []*schema.Column{CertifyLegalDiscoveredLicensesColumns[0], CertifyLegalDiscoveredLicensesColumns[1]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "certify_legal_discovered_licenses_certify_legal_id",
				Columns:    []*schema.Column{CertifyLegalDiscoveredLicensesColumns[0]},
				RefColumns: []*schema.Column{CertifyLegalsColumns[0]},
				OnDelete:   schema.Cascade,
			},
			{
				Symbol:     "certify_legal_discovered_licenses_license_id",
				Columns:    []*schema.Column{CertifyLegalDiscoveredLicensesColumns[1]},
				RefColumns: []*schema.Column{LicensesColumns[0]},
				OnDelete:   schema.Cascade,
			},
		},
	}
	// SlsaAttestationBuiltFromColumns holds the columns for the "slsa_attestation_built_from" table.
	SlsaAttestationBuiltFromColumns = []*schema.Column{
		{Name: "slsa_attestation_id", Type: field.TypeUUID},
		{Name: "artifact_id", Type: field.TypeUUID},
	}
	// SlsaAttestationBuiltFromTable holds the schema information for the "slsa_attestation_built_from" table.
	SlsaAttestationBuiltFromTable = &schema.Table{
		Name:       "slsa_attestation_built_from",
		Columns:    SlsaAttestationBuiltFromColumns,
		PrimaryKey: []*schema.Column{SlsaAttestationBuiltFromColumns[0], SlsaAttestationBuiltFromColumns[1]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "slsa_attestation_built_from_slsa_attestation_id",
				Columns:    []*schema.Column{SlsaAttestationBuiltFromColumns[0]},
				RefColumns: []*schema.Column{SlsaAttestationsColumns[0]},
				OnDelete:   schema.Cascade,
			},
			{
				Symbol:     "slsa_attestation_built_from_artifact_id",
				Columns:    []*schema.Column{SlsaAttestationBuiltFromColumns[1]},
				RefColumns: []*schema.Column{ArtifactsColumns[0]},
				OnDelete:   schema.Cascade,
			},
		},
	}
	// Tables holds all the tables in the schema.
	Tables = []*schema.Table{
		ArtifactsTable,
		BillOfMaterialsTable,
		BuildersTable,
		CertificationsTable,
		CertifyLegalsTable,
		CertifyScorecardsTable,
		CertifyVexesTable,
		CertifyVulnsTable,
		DependenciesTable,
		HasMetadataTable,
		HasSourceAtsTable,
		HashEqualsTable,
		LicensesTable,
		OccurrencesTable,
		PackageNamesTable,
		PackageVersionsTable,
		PkgEqualsTable,
		PointOfContactsTable,
		SlsaAttestationsTable,
		SourceNamesTable,
		VulnEqualsTable,
		VulnerabilityIdsTable,
		VulnerabilityMetadataTable,
		BillOfMaterialsIncludedSoftwarePackagesTable,
		BillOfMaterialsIncludedSoftwareArtifactsTable,
		BillOfMaterialsIncludedDependenciesTable,
		BillOfMaterialsIncludedOccurrencesTable,
		CertifyLegalDeclaredLicensesTable,
		CertifyLegalDiscoveredLicensesTable,
		SlsaAttestationBuiltFromTable,
	}
)

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 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