Documentation
¶
Index ¶
- Variables
- func Create(ctx context.Context, s *Schema, tables []*schema.Table, ...) error
- func Diff(ctx context.Context, url string, opts ...schema.MigrateOption) error
- func NamedDiff(ctx context.Context, url, name string, opts ...schema.MigrateOption) error
- type Schema
- func (s *Schema) Create(ctx context.Context, opts ...schema.MigrateOption) error
- func (s *Schema) Diff(ctx context.Context, opts ...schema.MigrateOption) error
- func (s *Schema) NamedDiff(ctx context.Context, name string, opts ...schema.MigrateOption) error
- func (s *Schema) WriteTo(ctx context.Context, w io.Writer, opts ...schema.MigrateOption) error
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // WithGlobalUniqueID sets the universal ids options to the migration. // If this option is enabled, ent migration will allocate a 1<<32 range // for the ids of each entity (table). // Note that this option cannot be applied on tables that already exist. WithGlobalUniqueID = schema.WithGlobalUniqueID // WithDropColumn sets the drop column option to the migration. // If this option is enabled, ent migration will drop old columns // that were used for both fields and edges. This defaults to false. WithDropColumn = schema.WithDropColumn // WithDropIndex sets the drop index option to the migration. // If this option is enabled, ent migration will drop old indexes // that were defined in the schema. This defaults to false. // Note that unique constraints are defined using `UNIQUE INDEX`, // and therefore, it's recommended to enable this option to get more // flexibility in the schema changes. WithDropIndex = schema.WithDropIndex // WithForeignKeys enables creating foreign-key in schema DDL. This defaults to true. WithForeignKeys = schema.WithForeignKeys )
View Source
var ( // AnnotationsColumns holds the columns for the "annotations" table. AnnotationsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "name", Type: field.TypeString}, {Name: "value", Type: field.TypeString}, {Name: "is_unique", Type: field.TypeBool, Default: false}, {Name: "document_id", Type: field.TypeUUID, Nullable: true}, {Name: "node_id", Type: field.TypeUUID, Nullable: true}, } // AnnotationsTable holds the schema information for the "annotations" table. AnnotationsTable = &schema.Table{ Name: "annotations", Columns: AnnotationsColumns, PrimaryKey: []*schema.Column{AnnotationsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "annotations_documents_annotations", Columns: []*schema.Column{AnnotationsColumns[4]}, RefColumns: []*schema.Column{DocumentsColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "annotations_nodes_annotations", Columns: []*schema.Column{AnnotationsColumns[5]}, RefColumns: []*schema.Column{NodesColumns[0]}, OnDelete: schema.Cascade, }, }, Indexes: []*schema.Index{ { Name: "idx_annotations_node_id", Unique: false, Columns: []*schema.Column{AnnotationsColumns[5]}, }, { Name: "idx_annotations_document_id", Unique: false, Columns: []*schema.Column{AnnotationsColumns[4]}, }, { Name: "idx_node_annotations", Unique: true, Columns: []*schema.Column{AnnotationsColumns[5], AnnotationsColumns[1], AnnotationsColumns[2]}, Annotation: &entsql.IndexAnnotation{ Where: "node_id IS NOT NULL AND TRIM(node_id) != ''", }, }, { Name: "idx_node_unique_annotations", Unique: true, Columns: []*schema.Column{AnnotationsColumns[5], AnnotationsColumns[1]}, Annotation: &entsql.IndexAnnotation{ Where: "node_id IS NOT NULL AND TRIM(node_id) != '' AND is_unique", }, }, { Name: "idx_document_annotations", Unique: true, Columns: []*schema.Column{AnnotationsColumns[4], AnnotationsColumns[1], AnnotationsColumns[2]}, Annotation: &entsql.IndexAnnotation{ Where: "document_id IS NOT NULL AND TRIM(document_id) != ''", }, }, { Name: "idx_document_unique_annotations", Unique: true, Columns: []*schema.Column{AnnotationsColumns[4], AnnotationsColumns[1]}, Annotation: &entsql.IndexAnnotation{ Where: "document_id IS NOT NULL AND TRIM(document_id) != '' AND is_unique", }, }, }, } // DocumentsColumns holds the columns for the "documents" table. DocumentsColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID, Unique: true}, {Name: "metadata_id", Type: field.TypeUUID, Nullable: true}, {Name: "node_list_id", Type: field.TypeUUID, Nullable: true}, } // DocumentsTable holds the schema information for the "documents" table. DocumentsTable = &schema.Table{ Name: "documents", Columns: DocumentsColumns, PrimaryKey: []*schema.Column{DocumentsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "documents_metadata_metadata", Columns: []*schema.Column{DocumentsColumns[1]}, RefColumns: []*schema.Column{MetadataColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "documents_node_lists_node_list", Columns: []*schema.Column{DocumentsColumns[2]}, RefColumns: []*schema.Column{NodeListsColumns[0]}, OnDelete: schema.Cascade, }, }, Indexes: []*schema.Index{ { Name: "idx_documents_metadata_id", Unique: false, Columns: []*schema.Column{DocumentsColumns[1]}, }, { Name: "idx_documents_node_list_id", Unique: false, Columns: []*schema.Column{DocumentsColumns[2]}, }, }, } // DocumentTypesColumns holds the columns for the "document_types" table. DocumentTypesColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID, Unique: true}, {Name: "proto_message", Type: field.TypeBytes, Unique: true}, {Name: "type", Type: field.TypeEnum, Nullable: true, Enums: []string{"OTHER", "DESIGN", "SOURCE", "BUILD", "ANALYZED", "DEPLOYED", "RUNTIME", "DISCOVERY", "DECOMISSION"}}, {Name: "name", Type: field.TypeString, Nullable: true}, {Name: "description", Type: field.TypeString, Nullable: true}, } // DocumentTypesTable holds the schema information for the "document_types" table. DocumentTypesTable = &schema.Table{ Name: "document_types", Columns: DocumentTypesColumns, PrimaryKey: []*schema.Column{DocumentTypesColumns[0]}, Indexes: []*schema.Index{ { Name: "idx_document_types", Unique: true, Columns: []*schema.Column{DocumentTypesColumns[2], DocumentTypesColumns[3], DocumentTypesColumns[4]}, }, }, } // EdgeTypesColumns holds the columns for the "edge_types" table. EdgeTypesColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID, Unique: true}, {Name: "proto_message", Type: field.TypeBytes, Unique: true}, {Name: "type", Type: field.TypeEnum, Enums: []string{"UNKNOWN", "amends", "ancestor", "buildDependency", "buildTool", "contains", "contained_by", "copy", "dataFile", "dependencyManifest", "dependsOn", "dependencyOf", "descendant", "describes", "describedBy", "devDependency", "devTool", "distributionArtifact", "documentation", "dynamicLink", "example", "expandedFromArchive", "fileAdded", "fileDeleted", "fileModified", "generates", "generatedFrom", "metafile", "optionalComponent", "optionalDependency", "other", "packages", "patch", "prerequisite", "prerequisiteFor", "providedDependency", "requirementFor", "runtimeDependency", "specificationFor", "staticLink", "test", "testCase", "testDependency", "testTool", "variant"}}, {Name: "node_id", Type: field.TypeUUID}, {Name: "to_node_id", Type: field.TypeUUID}, } // EdgeTypesTable holds the schema information for the "edge_types" table. EdgeTypesTable = &schema.Table{ Name: "edge_types", Columns: EdgeTypesColumns, PrimaryKey: []*schema.Column{EdgeTypesColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "edge_types_nodes_from", Columns: []*schema.Column{EdgeTypesColumns[3]}, RefColumns: []*schema.Column{NodesColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "edge_types_nodes_to", Columns: []*schema.Column{EdgeTypesColumns[4]}, RefColumns: []*schema.Column{NodesColumns[0]}, OnDelete: schema.Cascade, }, }, Indexes: []*schema.Index{ { Name: "idx_edge_types", Unique: true, Columns: []*schema.Column{EdgeTypesColumns[2], EdgeTypesColumns[3], EdgeTypesColumns[4]}, }, { Name: "edgetype_node_id_to_node_id", Unique: true, Columns: []*schema.Column{EdgeTypesColumns[3], EdgeTypesColumns[4]}, }, }, } // ExternalReferencesColumns holds the columns for the "external_references" table. ExternalReferencesColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID, Unique: true}, {Name: "proto_message", Type: field.TypeBytes, Unique: true}, {Name: "url", Type: field.TypeString}, {Name: "comment", Type: field.TypeString}, {Name: "authority", Type: field.TypeString, Nullable: true}, {Name: "type", Type: field.TypeEnum, Enums: []string{"UNKNOWN", "ATTESTATION", "BINARY", "BOM", "BOWER", "BUILD_META", "BUILD_SYSTEM", "CERTIFICATION_REPORT", "CHAT", "CODIFIED_INFRASTRUCTURE", "COMPONENT_ANALYSIS_REPORT", "CONFIGURATION", "DISTRIBUTION_INTAKE", "DOCUMENTATION", "DOWNLOAD", "DYNAMIC_ANALYSIS_REPORT", "EOL_NOTICE", "EVIDENCE", "EXPORT_CONTROL_ASSESSMENT", "FORMULATION", "FUNDING", "ISSUE_TRACKER", "LICENSE", "LOG", "MAILING_LIST", "MATURITY_REPORT", "MAVEN_CENTRAL", "METRICS", "MODEL_CARD", "NPM", "NUGET", "OTHER", "POAM", "PRIVACY_ASSESSMENT", "PRODUCT_METADATA", "PURCHASE_ORDER", "QUALITY_ASSESSMENT_REPORT", "QUALITY_METRICS", "RELEASE_HISTORY", "RELEASE_NOTES", "RISK_ASSESSMENT", "RUNTIME_ANALYSIS_REPORT", "SECURE_SOFTWARE_ATTESTATION", "SECURITY_ADVERSARY_MODEL", "SECURITY_ADVISORY", "SECURITY_CONTACT", "SECURITY_FIX", "SECURITY_OTHER", "SECURITY_PENTEST_REPORT", "SECURITY_POLICY", "SECURITY_SWID", "SECURITY_THREAT_MODEL", "SOCIAL", "SOURCE_ARTIFACT", "STATIC_ANALYSIS_REPORT", "SUPPORT", "VCS", "VULNERABILITY_ASSERTION", "VULNERABILITY_DISCLOSURE_REPORT", "VULNERABILITY_EXPLOITABILITY_ASSESSMENT", "WEBSITE"}}, } // ExternalReferencesTable holds the schema information for the "external_references" table. ExternalReferencesTable = &schema.Table{ Name: "external_references", Columns: ExternalReferencesColumns, PrimaryKey: []*schema.Column{ExternalReferencesColumns[0]}, } // HashesEntriesColumns holds the columns for the "hashes_entries" table. HashesEntriesColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID, Unique: true}, {Name: "hash_algorithm", Type: field.TypeEnum, Enums: []string{"UNKNOWN", "MD5", "SHA1", "SHA256", "SHA384", "SHA512", "SHA3_256", "SHA3_384", "SHA3_512", "BLAKE2B_256", "BLAKE2B_384", "BLAKE2B_512", "BLAKE3", "MD2", "ADLER32", "MD4", "MD6", "SHA224"}}, {Name: "hash_data", Type: field.TypeString}, } // HashesEntriesTable holds the schema information for the "hashes_entries" table. HashesEntriesTable = &schema.Table{ Name: "hashes_entries", Columns: HashesEntriesColumns, PrimaryKey: []*schema.Column{HashesEntriesColumns[0]}, Indexes: []*schema.Index{ { Name: "idx_hashes", Unique: true, Columns: []*schema.Column{HashesEntriesColumns[1], HashesEntriesColumns[2]}, }, }, } // IdentifiersEntriesColumns holds the columns for the "identifiers_entries" table. IdentifiersEntriesColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID, Unique: true}, {Name: "type", Type: field.TypeEnum, Enums: []string{"UNKNOWN_IDENTIFIER_TYPE", "PURL", "CPE22", "CPE23", "GITOID"}}, {Name: "value", Type: field.TypeString}, } // IdentifiersEntriesTable holds the schema information for the "identifiers_entries" table. IdentifiersEntriesTable = &schema.Table{ Name: "identifiers_entries", Columns: IdentifiersEntriesColumns, PrimaryKey: []*schema.Column{IdentifiersEntriesColumns[0]}, Indexes: []*schema.Index{ { Name: "idx_identifiers", Unique: true, Columns: []*schema.Column{IdentifiersEntriesColumns[1], IdentifiersEntriesColumns[2]}, }, }, } // MetadataColumns holds the columns for the "metadata" table. MetadataColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID, Unique: true}, {Name: "proto_message", Type: field.TypeBytes, Unique: true}, {Name: "native_id", Type: field.TypeString}, {Name: "version", Type: field.TypeString}, {Name: "name", Type: field.TypeString}, {Name: "date", Type: field.TypeTime}, {Name: "comment", Type: field.TypeString}, {Name: "source_data_id", Type: field.TypeUUID, Nullable: true}, } // MetadataTable holds the schema information for the "metadata" table. MetadataTable = &schema.Table{ Name: "metadata", Columns: MetadataColumns, PrimaryKey: []*schema.Column{MetadataColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "metadata_source_data_source_data", Columns: []*schema.Column{MetadataColumns[7]}, RefColumns: []*schema.Column{SourceDataColumns[0]}, OnDelete: schema.Cascade, }, }, } // NodesColumns holds the columns for the "nodes" table. NodesColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID, Unique: true}, {Name: "proto_message", Type: field.TypeBytes, Unique: true}, {Name: "native_id", Type: field.TypeString}, {Name: "type", Type: field.TypeEnum, Enums: []string{"PACKAGE", "FILE"}}, {Name: "name", Type: field.TypeString}, {Name: "version", Type: field.TypeString}, {Name: "file_name", Type: field.TypeString}, {Name: "url_home", Type: field.TypeString}, {Name: "url_download", Type: field.TypeString}, {Name: "licenses", Type: field.TypeJSON}, {Name: "license_concluded", Type: field.TypeString}, {Name: "license_comments", Type: field.TypeString}, {Name: "copyright", Type: field.TypeString}, {Name: "source_info", Type: field.TypeString}, {Name: "comment", Type: field.TypeString}, {Name: "summary", Type: field.TypeString}, {Name: "description", Type: field.TypeString}, {Name: "release_date", Type: field.TypeTime}, {Name: "build_date", Type: field.TypeTime}, {Name: "valid_until_date", Type: field.TypeTime}, {Name: "attribution", Type: field.TypeJSON}, {Name: "file_types", Type: field.TypeJSON}, } // NodesTable holds the schema information for the "nodes" table. NodesTable = &schema.Table{ Name: "nodes", Columns: NodesColumns, PrimaryKey: []*schema.Column{NodesColumns[0]}, } // NodeListsColumns holds the columns for the "node_lists" table. NodeListsColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID, Unique: true}, {Name: "proto_message", Type: field.TypeBytes, Unique: true}, {Name: "root_elements", Type: field.TypeJSON}, } // NodeListsTable holds the schema information for the "node_lists" table. NodeListsTable = &schema.Table{ Name: "node_lists", Columns: NodeListsColumns, PrimaryKey: []*schema.Column{NodeListsColumns[0]}, } // PersonsColumns holds the columns for the "persons" table. PersonsColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID, Unique: true}, {Name: "proto_message", Type: field.TypeBytes, Unique: true}, {Name: "name", Type: field.TypeString}, {Name: "is_org", Type: field.TypeBool}, {Name: "email", Type: field.TypeString}, {Name: "url", Type: field.TypeString}, {Name: "phone", Type: field.TypeString}, } // PersonsTable holds the schema information for the "persons" table. PersonsTable = &schema.Table{ Name: "persons", Columns: PersonsColumns, PrimaryKey: []*schema.Column{PersonsColumns[0]}, Indexes: []*schema.Index{ { Name: "idx_persons", Unique: true, Columns: []*schema.Column{PersonsColumns[2], PersonsColumns[3], PersonsColumns[4], PersonsColumns[5], PersonsColumns[6]}, }, }, } // PropertiesColumns holds the columns for the "properties" table. PropertiesColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID, Unique: true}, {Name: "proto_message", Type: field.TypeBytes, Unique: true}, {Name: "name", Type: field.TypeString}, {Name: "data", Type: field.TypeString}, } // PropertiesTable holds the schema information for the "properties" table. PropertiesTable = &schema.Table{ Name: "properties", Columns: PropertiesColumns, PrimaryKey: []*schema.Column{PropertiesColumns[0]}, Indexes: []*schema.Index{ { Name: "idx_property", Unique: true, Columns: []*schema.Column{PropertiesColumns[2], PropertiesColumns[3]}, }, }, } // PurposesColumns holds the columns for the "purposes" table. PurposesColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "primary_purpose", Type: field.TypeEnum, Enums: []string{"UNKNOWN_PURPOSE", "APPLICATION", "ARCHIVE", "BOM", "CONFIGURATION", "CONTAINER", "DATA", "DEVICE", "DEVICE_DRIVER", "DOCUMENTATION", "EVIDENCE", "EXECUTABLE", "FILE", "FIRMWARE", "FRAMEWORK", "INSTALL", "LIBRARY", "MACHINE_LEARNING_MODEL", "MANIFEST", "MODEL", "MODULE", "OPERATING_SYSTEM", "OTHER", "PATCH", "PLATFORM", "REQUIREMENT", "SOURCE", "SPECIFICATION", "TEST"}}, } // PurposesTable holds the schema information for the "purposes" table. PurposesTable = &schema.Table{ Name: "purposes", Columns: PurposesColumns, PrimaryKey: []*schema.Column{PurposesColumns[0]}, } // SourceDataColumns holds the columns for the "source_data" table. SourceDataColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID, Unique: true}, {Name: "proto_message", Type: field.TypeBytes, Unique: true}, {Name: "format", Type: field.TypeString}, {Name: "size", Type: field.TypeInt64}, {Name: "uri", Type: field.TypeString, Nullable: true}, } // SourceDataTable holds the schema information for the "source_data" table. SourceDataTable = &schema.Table{ Name: "source_data", Columns: SourceDataColumns, PrimaryKey: []*schema.Column{SourceDataColumns[0]}, Indexes: []*schema.Index{ { Name: "idx_source_data", Unique: true, Columns: []*schema.Column{SourceDataColumns[2], SourceDataColumns[3], SourceDataColumns[4]}, }, }, } // ToolsColumns holds the columns for the "tools" table. ToolsColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID, Unique: true}, {Name: "proto_message", Type: field.TypeBytes, Unique: true}, {Name: "name", Type: field.TypeString}, {Name: "version", Type: field.TypeString}, {Name: "vendor", Type: field.TypeString}, } // ToolsTable holds the schema information for the "tools" table. ToolsTable = &schema.Table{ Name: "tools", Columns: ToolsColumns, PrimaryKey: []*schema.Column{ToolsColumns[0]}, Indexes: []*schema.Index{ { Name: "idx_tools", Unique: true, Columns: []*schema.Column{ToolsColumns[2], ToolsColumns[3], ToolsColumns[4]}, }, }, } // DocumentDocumentTypesColumns holds the columns for the "document_document_types" table. DocumentDocumentTypesColumns = []*schema.Column{ {Name: "document_id", Type: field.TypeUUID}, {Name: "document_type_id", Type: field.TypeUUID}, } // DocumentDocumentTypesTable holds the schema information for the "document_document_types" table. DocumentDocumentTypesTable = &schema.Table{ Name: "document_document_types", Columns: DocumentDocumentTypesColumns, PrimaryKey: []*schema.Column{DocumentDocumentTypesColumns[0], DocumentDocumentTypesColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "document_document_types_document_id", Columns: []*schema.Column{DocumentDocumentTypesColumns[0]}, RefColumns: []*schema.Column{DocumentsColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "document_document_types_document_type_id", Columns: []*schema.Column{DocumentDocumentTypesColumns[1]}, RefColumns: []*schema.Column{DocumentTypesColumns[0]}, OnDelete: schema.Cascade, }, }, } // DocumentEdgeTypesColumns holds the columns for the "document_edge_types" table. DocumentEdgeTypesColumns = []*schema.Column{ {Name: "document_id", Type: field.TypeUUID}, {Name: "edge_type_id", Type: field.TypeUUID}, } // DocumentEdgeTypesTable holds the schema information for the "document_edge_types" table. DocumentEdgeTypesTable = &schema.Table{ Name: "document_edge_types", Columns: DocumentEdgeTypesColumns, PrimaryKey: []*schema.Column{DocumentEdgeTypesColumns[0], DocumentEdgeTypesColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "document_edge_types_document_id", Columns: []*schema.Column{DocumentEdgeTypesColumns[0]}, RefColumns: []*schema.Column{DocumentsColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "document_edge_types_edge_type_id", Columns: []*schema.Column{DocumentEdgeTypesColumns[1]}, RefColumns: []*schema.Column{EdgeTypesColumns[0]}, OnDelete: schema.Cascade, }, }, } // DocumentExternalReferencesColumns holds the columns for the "document_external_references" table. DocumentExternalReferencesColumns = []*schema.Column{ {Name: "document_id", Type: field.TypeUUID}, {Name: "external_reference_id", Type: field.TypeUUID}, } // DocumentExternalReferencesTable holds the schema information for the "document_external_references" table. DocumentExternalReferencesTable = &schema.Table{ Name: "document_external_references", Columns: DocumentExternalReferencesColumns, PrimaryKey: []*schema.Column{DocumentExternalReferencesColumns[0], DocumentExternalReferencesColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "document_external_references_document_id", Columns: []*schema.Column{DocumentExternalReferencesColumns[0]}, RefColumns: []*schema.Column{DocumentsColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "document_external_references_external_reference_id", Columns: []*schema.Column{DocumentExternalReferencesColumns[1]}, RefColumns: []*schema.Column{ExternalReferencesColumns[0]}, OnDelete: schema.Cascade, }, }, } // DocumentHashesColumns holds the columns for the "document_hashes" table. DocumentHashesColumns = []*schema.Column{ {Name: "document_id", Type: field.TypeUUID}, {Name: "hashes_entry_id", Type: field.TypeUUID}, } // DocumentHashesTable holds the schema information for the "document_hashes" table. DocumentHashesTable = &schema.Table{ Name: "document_hashes", Columns: DocumentHashesColumns, PrimaryKey: []*schema.Column{DocumentHashesColumns[0], DocumentHashesColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "document_hashes_document_id", Columns: []*schema.Column{DocumentHashesColumns[0]}, RefColumns: []*schema.Column{DocumentsColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "document_hashes_hashes_entry_id", Columns: []*schema.Column{DocumentHashesColumns[1]}, RefColumns: []*schema.Column{HashesEntriesColumns[0]}, OnDelete: schema.Cascade, }, }, } // DocumentIdentifiersColumns holds the columns for the "document_identifiers" table. DocumentIdentifiersColumns = []*schema.Column{ {Name: "document_id", Type: field.TypeUUID}, {Name: "identifiers_entry_id", Type: field.TypeUUID}, } // DocumentIdentifiersTable holds the schema information for the "document_identifiers" table. DocumentIdentifiersTable = &schema.Table{ Name: "document_identifiers", Columns: DocumentIdentifiersColumns, PrimaryKey: []*schema.Column{DocumentIdentifiersColumns[0], DocumentIdentifiersColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "document_identifiers_document_id", Columns: []*schema.Column{DocumentIdentifiersColumns[0]}, RefColumns: []*schema.Column{DocumentsColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "document_identifiers_identifiers_entry_id", Columns: []*schema.Column{DocumentIdentifiersColumns[1]}, RefColumns: []*schema.Column{IdentifiersEntriesColumns[0]}, OnDelete: schema.Cascade, }, }, } // DocumentNodesColumns holds the columns for the "document_nodes" table. DocumentNodesColumns = []*schema.Column{ {Name: "document_id", Type: field.TypeUUID}, {Name: "node_id", Type: field.TypeUUID}, } // DocumentNodesTable holds the schema information for the "document_nodes" table. DocumentNodesTable = &schema.Table{ Name: "document_nodes", Columns: DocumentNodesColumns, PrimaryKey: []*schema.Column{DocumentNodesColumns[0], DocumentNodesColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "document_nodes_document_id", Columns: []*schema.Column{DocumentNodesColumns[0]}, RefColumns: []*schema.Column{DocumentsColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "document_nodes_node_id", Columns: []*schema.Column{DocumentNodesColumns[1]}, RefColumns: []*schema.Column{NodesColumns[0]}, OnDelete: schema.Cascade, }, }, } // DocumentPersonsColumns holds the columns for the "document_persons" table. DocumentPersonsColumns = []*schema.Column{ {Name: "document_id", Type: field.TypeUUID}, {Name: "person_id", Type: field.TypeUUID}, } // DocumentPersonsTable holds the schema information for the "document_persons" table. DocumentPersonsTable = &schema.Table{ Name: "document_persons", Columns: DocumentPersonsColumns, PrimaryKey: []*schema.Column{DocumentPersonsColumns[0], DocumentPersonsColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "document_persons_document_id", Columns: []*schema.Column{DocumentPersonsColumns[0]}, RefColumns: []*schema.Column{DocumentsColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "document_persons_person_id", Columns: []*schema.Column{DocumentPersonsColumns[1]}, RefColumns: []*schema.Column{PersonsColumns[0]}, OnDelete: schema.Cascade, }, }, } // DocumentPropertiesColumns holds the columns for the "document_properties" table. DocumentPropertiesColumns = []*schema.Column{ {Name: "document_id", Type: field.TypeUUID}, {Name: "property_id", Type: field.TypeUUID}, } // DocumentPropertiesTable holds the schema information for the "document_properties" table. DocumentPropertiesTable = &schema.Table{ Name: "document_properties", Columns: DocumentPropertiesColumns, PrimaryKey: []*schema.Column{DocumentPropertiesColumns[0], DocumentPropertiesColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "document_properties_document_id", Columns: []*schema.Column{DocumentPropertiesColumns[0]}, RefColumns: []*schema.Column{DocumentsColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "document_properties_property_id", Columns: []*schema.Column{DocumentPropertiesColumns[1]}, RefColumns: []*schema.Column{PropertiesColumns[0]}, OnDelete: schema.Cascade, }, }, } // DocumentPurposesColumns holds the columns for the "document_purposes" table. DocumentPurposesColumns = []*schema.Column{ {Name: "document_id", Type: field.TypeUUID}, {Name: "purpose_id", Type: field.TypeInt}, } // DocumentPurposesTable holds the schema information for the "document_purposes" table. DocumentPurposesTable = &schema.Table{ Name: "document_purposes", Columns: DocumentPurposesColumns, PrimaryKey: []*schema.Column{DocumentPurposesColumns[0], DocumentPurposesColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "document_purposes_document_id", Columns: []*schema.Column{DocumentPurposesColumns[0]}, RefColumns: []*schema.Column{DocumentsColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "document_purposes_purpose_id", Columns: []*schema.Column{DocumentPurposesColumns[1]}, RefColumns: []*schema.Column{PurposesColumns[0]}, OnDelete: schema.Cascade, }, }, } // DocumentSourceDataColumns holds the columns for the "document_source_data" table. DocumentSourceDataColumns = []*schema.Column{ {Name: "document_id", Type: field.TypeUUID}, {Name: "source_data_id", Type: field.TypeUUID}, } // DocumentSourceDataTable holds the schema information for the "document_source_data" table. DocumentSourceDataTable = &schema.Table{ Name: "document_source_data", Columns: DocumentSourceDataColumns, PrimaryKey: []*schema.Column{DocumentSourceDataColumns[0], DocumentSourceDataColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "document_source_data_document_id", Columns: []*schema.Column{DocumentSourceDataColumns[0]}, RefColumns: []*schema.Column{DocumentsColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "document_source_data_source_data_id", Columns: []*schema.Column{DocumentSourceDataColumns[1]}, RefColumns: []*schema.Column{SourceDataColumns[0]}, OnDelete: schema.Cascade, }, }, } // DocumentToolsColumns holds the columns for the "document_tools" table. DocumentToolsColumns = []*schema.Column{ {Name: "document_id", Type: field.TypeUUID}, {Name: "tool_id", Type: field.TypeUUID}, } // DocumentToolsTable holds the schema information for the "document_tools" table. DocumentToolsTable = &schema.Table{ Name: "document_tools", Columns: DocumentToolsColumns, PrimaryKey: []*schema.Column{DocumentToolsColumns[0], DocumentToolsColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "document_tools_document_id", Columns: []*schema.Column{DocumentToolsColumns[0]}, RefColumns: []*schema.Column{DocumentsColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "document_tools_tool_id", Columns: []*schema.Column{DocumentToolsColumns[1]}, RefColumns: []*schema.Column{ToolsColumns[0]}, OnDelete: schema.Cascade, }, }, } // ExtRefHashesColumns holds the columns for the "ext_ref_hashes" table. ExtRefHashesColumns = []*schema.Column{ {Name: "ext_ref_id", Type: field.TypeUUID}, {Name: "hash_entry_id", Type: field.TypeUUID}, } // ExtRefHashesTable holds the schema information for the "ext_ref_hashes" table. ExtRefHashesTable = &schema.Table{ Name: "ext_ref_hashes", Columns: ExtRefHashesColumns, PrimaryKey: []*schema.Column{ExtRefHashesColumns[0], ExtRefHashesColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "ext_ref_hashes_ext_ref_id", Columns: []*schema.Column{ExtRefHashesColumns[0]}, RefColumns: []*schema.Column{ExternalReferencesColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "ext_ref_hashes_hash_entry_id", Columns: []*schema.Column{ExtRefHashesColumns[1]}, RefColumns: []*schema.Column{HashesEntriesColumns[0]}, OnDelete: schema.Cascade, }, }, } // MetadataToolsColumns holds the columns for the "metadata_tools" table. MetadataToolsColumns = []*schema.Column{ {Name: "metadata_id", Type: field.TypeUUID}, {Name: "tool_id", Type: field.TypeUUID}, } // MetadataToolsTable holds the schema information for the "metadata_tools" table. MetadataToolsTable = &schema.Table{ Name: "metadata_tools", Columns: MetadataToolsColumns, PrimaryKey: []*schema.Column{MetadataToolsColumns[0], MetadataToolsColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "metadata_tools_metadata_id", Columns: []*schema.Column{MetadataToolsColumns[0]}, RefColumns: []*schema.Column{MetadataColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "metadata_tools_tool_id", Columns: []*schema.Column{MetadataToolsColumns[1]}, RefColumns: []*schema.Column{ToolsColumns[0]}, OnDelete: schema.Cascade, }, }, } // MetadataAuthorsColumns holds the columns for the "metadata_authors" table. MetadataAuthorsColumns = []*schema.Column{ {Name: "metadata_id", Type: field.TypeUUID}, {Name: "person_id", Type: field.TypeUUID}, } // MetadataAuthorsTable holds the schema information for the "metadata_authors" table. MetadataAuthorsTable = &schema.Table{ Name: "metadata_authors", Columns: MetadataAuthorsColumns, PrimaryKey: []*schema.Column{MetadataAuthorsColumns[0], MetadataAuthorsColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "metadata_authors_metadata_id", Columns: []*schema.Column{MetadataAuthorsColumns[0]}, RefColumns: []*schema.Column{MetadataColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "metadata_authors_person_id", Columns: []*schema.Column{MetadataAuthorsColumns[1]}, RefColumns: []*schema.Column{PersonsColumns[0]}, OnDelete: schema.Cascade, }, }, } // MetadataDocumentTypesColumns holds the columns for the "metadata_document_types" table. MetadataDocumentTypesColumns = []*schema.Column{ {Name: "metadata_id", Type: field.TypeUUID}, {Name: "document_type_id", Type: field.TypeUUID}, } // MetadataDocumentTypesTable holds the schema information for the "metadata_document_types" table. MetadataDocumentTypesTable = &schema.Table{ Name: "metadata_document_types", Columns: MetadataDocumentTypesColumns, PrimaryKey: []*schema.Column{MetadataDocumentTypesColumns[0], MetadataDocumentTypesColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "metadata_document_types_metadata_id", Columns: []*schema.Column{MetadataDocumentTypesColumns[0]}, RefColumns: []*schema.Column{MetadataColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "metadata_document_types_document_type_id", Columns: []*schema.Column{MetadataDocumentTypesColumns[1]}, RefColumns: []*schema.Column{DocumentTypesColumns[0]}, OnDelete: schema.Cascade, }, }, } // NodeSuppliersColumns holds the columns for the "node_suppliers" table. NodeSuppliersColumns = []*schema.Column{ {Name: "node_id", Type: field.TypeUUID}, {Name: "person_id", Type: field.TypeUUID}, } // NodeSuppliersTable holds the schema information for the "node_suppliers" table. NodeSuppliersTable = &schema.Table{ Name: "node_suppliers", Columns: NodeSuppliersColumns, PrimaryKey: []*schema.Column{NodeSuppliersColumns[0], NodeSuppliersColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "node_suppliers_node_id", Columns: []*schema.Column{NodeSuppliersColumns[0]}, RefColumns: []*schema.Column{NodesColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "node_suppliers_person_id", Columns: []*schema.Column{NodeSuppliersColumns[1]}, RefColumns: []*schema.Column{PersonsColumns[0]}, OnDelete: schema.Cascade, }, }, } // NodeOriginatorsColumns holds the columns for the "node_originators" table. NodeOriginatorsColumns = []*schema.Column{ {Name: "node_id", Type: field.TypeUUID}, {Name: "person_id", Type: field.TypeUUID}, } // NodeOriginatorsTable holds the schema information for the "node_originators" table. NodeOriginatorsTable = &schema.Table{ Name: "node_originators", Columns: NodeOriginatorsColumns, PrimaryKey: []*schema.Column{NodeOriginatorsColumns[0], NodeOriginatorsColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "node_originators_node_id", Columns: []*schema.Column{NodeOriginatorsColumns[0]}, RefColumns: []*schema.Column{NodesColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "node_originators_person_id", Columns: []*schema.Column{NodeOriginatorsColumns[1]}, RefColumns: []*schema.Column{PersonsColumns[0]}, OnDelete: schema.Cascade, }, }, } // NodeExternalReferencesColumns holds the columns for the "node_external_references" table. NodeExternalReferencesColumns = []*schema.Column{ {Name: "node_id", Type: field.TypeUUID}, {Name: "external_reference_id", Type: field.TypeUUID}, } // NodeExternalReferencesTable holds the schema information for the "node_external_references" table. NodeExternalReferencesTable = &schema.Table{ Name: "node_external_references", Columns: NodeExternalReferencesColumns, PrimaryKey: []*schema.Column{NodeExternalReferencesColumns[0], NodeExternalReferencesColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "node_external_references_node_id", Columns: []*schema.Column{NodeExternalReferencesColumns[0]}, RefColumns: []*schema.Column{NodesColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "node_external_references_external_reference_id", Columns: []*schema.Column{NodeExternalReferencesColumns[1]}, RefColumns: []*schema.Column{ExternalReferencesColumns[0]}, OnDelete: schema.Cascade, }, }, } // NodePrimaryPurposesColumns holds the columns for the "node_primary_purposes" table. NodePrimaryPurposesColumns = []*schema.Column{ {Name: "node_id", Type: field.TypeUUID}, {Name: "purpose_id", Type: field.TypeInt}, } // NodePrimaryPurposesTable holds the schema information for the "node_primary_purposes" table. NodePrimaryPurposesTable = &schema.Table{ Name: "node_primary_purposes", Columns: NodePrimaryPurposesColumns, PrimaryKey: []*schema.Column{NodePrimaryPurposesColumns[0], NodePrimaryPurposesColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "node_primary_purposes_node_id", Columns: []*schema.Column{NodePrimaryPurposesColumns[0]}, RefColumns: []*schema.Column{NodesColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "node_primary_purposes_purpose_id", Columns: []*schema.Column{NodePrimaryPurposesColumns[1]}, RefColumns: []*schema.Column{PurposesColumns[0]}, OnDelete: schema.Cascade, }, }, } // NodeHashesColumns holds the columns for the "node_hashes" table. NodeHashesColumns = []*schema.Column{ {Name: "node_id", Type: field.TypeUUID}, {Name: "hash_entry_id", Type: field.TypeUUID}, } // NodeHashesTable holds the schema information for the "node_hashes" table. NodeHashesTable = &schema.Table{ Name: "node_hashes", Columns: NodeHashesColumns, PrimaryKey: []*schema.Column{NodeHashesColumns[0], NodeHashesColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "node_hashes_node_id", Columns: []*schema.Column{NodeHashesColumns[0]}, RefColumns: []*schema.Column{NodesColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "node_hashes_hash_entry_id", Columns: []*schema.Column{NodeHashesColumns[1]}, RefColumns: []*schema.Column{HashesEntriesColumns[0]}, OnDelete: schema.Cascade, }, }, } // NodeIdentifiersColumns holds the columns for the "node_identifiers" table. NodeIdentifiersColumns = []*schema.Column{ {Name: "node_id", Type: field.TypeUUID}, {Name: "identifier_entry_id", Type: field.TypeUUID}, } // NodeIdentifiersTable holds the schema information for the "node_identifiers" table. NodeIdentifiersTable = &schema.Table{ Name: "node_identifiers", Columns: NodeIdentifiersColumns, PrimaryKey: []*schema.Column{NodeIdentifiersColumns[0], NodeIdentifiersColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "node_identifiers_node_id", Columns: []*schema.Column{NodeIdentifiersColumns[0]}, RefColumns: []*schema.Column{NodesColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "node_identifiers_identifier_entry_id", Columns: []*schema.Column{NodeIdentifiersColumns[1]}, RefColumns: []*schema.Column{IdentifiersEntriesColumns[0]}, OnDelete: schema.Cascade, }, }, } // NodePropertiesColumns holds the columns for the "node_properties" table. NodePropertiesColumns = []*schema.Column{ {Name: "node_id", Type: field.TypeUUID}, {Name: "property_id", Type: field.TypeUUID}, } // NodePropertiesTable holds the schema information for the "node_properties" table. NodePropertiesTable = &schema.Table{ Name: "node_properties", Columns: NodePropertiesColumns, PrimaryKey: []*schema.Column{NodePropertiesColumns[0], NodePropertiesColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "node_properties_node_id", Columns: []*schema.Column{NodePropertiesColumns[0]}, RefColumns: []*schema.Column{NodesColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "node_properties_property_id", Columns: []*schema.Column{NodePropertiesColumns[1]}, RefColumns: []*schema.Column{PropertiesColumns[0]}, OnDelete: schema.Cascade, }, }, } // NodeListEdgesColumns holds the columns for the "node_list_edges" table. NodeListEdgesColumns = []*schema.Column{ {Name: "node_list_id", Type: field.TypeUUID}, {Name: "edge_type_id", Type: field.TypeUUID}, } // NodeListEdgesTable holds the schema information for the "node_list_edges" table. NodeListEdgesTable = &schema.Table{ Name: "node_list_edges", Columns: NodeListEdgesColumns, PrimaryKey: []*schema.Column{NodeListEdgesColumns[0], NodeListEdgesColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "node_list_edges_node_list_id", Columns: []*schema.Column{NodeListEdgesColumns[0]}, RefColumns: []*schema.Column{NodeListsColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "node_list_edges_edge_type_id", Columns: []*schema.Column{NodeListEdgesColumns[1]}, RefColumns: []*schema.Column{EdgeTypesColumns[0]}, OnDelete: schema.Cascade, }, }, } // NodeListNodesColumns holds the columns for the "node_list_nodes" table. NodeListNodesColumns = []*schema.Column{ {Name: "node_list_id", Type: field.TypeUUID}, {Name: "node_id", Type: field.TypeUUID}, } // NodeListNodesTable holds the schema information for the "node_list_nodes" table. NodeListNodesTable = &schema.Table{ Name: "node_list_nodes", Columns: NodeListNodesColumns, PrimaryKey: []*schema.Column{NodeListNodesColumns[0], NodeListNodesColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "node_list_nodes_node_list_id", Columns: []*schema.Column{NodeListNodesColumns[0]}, RefColumns: []*schema.Column{NodeListsColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "node_list_nodes_node_id", Columns: []*schema.Column{NodeListNodesColumns[1]}, RefColumns: []*schema.Column{NodesColumns[0]}, OnDelete: schema.Cascade, }, }, } // PersonContactsColumns holds the columns for the "person_contacts" table. PersonContactsColumns = []*schema.Column{ {Name: "person_id", Type: field.TypeUUID}, {Name: "contact_owner_id", Type: field.TypeUUID}, } // PersonContactsTable holds the schema information for the "person_contacts" table. PersonContactsTable = &schema.Table{ Name: "person_contacts", Columns: PersonContactsColumns, PrimaryKey: []*schema.Column{PersonContactsColumns[0], PersonContactsColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "person_contacts_person_id", Columns: []*schema.Column{PersonContactsColumns[0]}, RefColumns: []*schema.Column{PersonsColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "person_contacts_contact_owner_id", Columns: []*schema.Column{PersonContactsColumns[1]}, RefColumns: []*schema.Column{PersonsColumns[0]}, OnDelete: schema.Cascade, }, }, } // SourceDataHashesColumns holds the columns for the "source_data_hashes" table. SourceDataHashesColumns = []*schema.Column{ {Name: "source_data_id", Type: field.TypeUUID}, {Name: "hash_entry_id", Type: field.TypeUUID}, } // SourceDataHashesTable holds the schema information for the "source_data_hashes" table. SourceDataHashesTable = &schema.Table{ Name: "source_data_hashes", Columns: SourceDataHashesColumns, PrimaryKey: []*schema.Column{SourceDataHashesColumns[0], SourceDataHashesColumns[1]}, ForeignKeys: []*schema.ForeignKey{ { Symbol: "source_data_hashes_source_data_id", Columns: []*schema.Column{SourceDataHashesColumns[0]}, RefColumns: []*schema.Column{SourceDataColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "source_data_hashes_hash_entry_id", Columns: []*schema.Column{SourceDataHashesColumns[1]}, RefColumns: []*schema.Column{HashesEntriesColumns[0]}, OnDelete: schema.Cascade, }, }, } // Tables holds all the tables in the schema. Tables = []*schema.Table{ AnnotationsTable, DocumentsTable, DocumentTypesTable, EdgeTypesTable, ExternalReferencesTable, HashesEntriesTable, IdentifiersEntriesTable, MetadataTable, NodesTable, NodeListsTable, PersonsTable, PropertiesTable, PurposesTable, SourceDataTable, ToolsTable, DocumentDocumentTypesTable, DocumentEdgeTypesTable, DocumentExternalReferencesTable, DocumentHashesTable, DocumentIdentifiersTable, DocumentNodesTable, DocumentPersonsTable, DocumentPropertiesTable, DocumentPurposesTable, DocumentSourceDataTable, DocumentToolsTable, ExtRefHashesTable, MetadataToolsTable, MetadataAuthorsTable, MetadataDocumentTypesTable, NodeSuppliersTable, NodeOriginatorsTable, NodeExternalReferencesTable, NodePrimaryPurposesTable, NodeHashesTable, NodeIdentifiersTable, NodePropertiesTable, NodeListEdgesTable, NodeListNodesTable, PersonContactsTable, SourceDataHashesTable, } )
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.
func Diff ¶ added in v0.2.0
Diff compares the state read from a database connection or migration directory with the state defined by the Ent schema. Changes will be written to new migration files.
Types ¶
type Schema ¶
type Schema struct {
// contains filtered or unexported fields
}
Schema is the API for creating, migrating and dropping a schema.
func (*Schema) Diff ¶ added in v0.2.0
Diff creates a migration file containing the statements to resolve the diff between the Ent schema and the connected database.
func (*Schema) NamedDiff ¶ added in v0.2.0
NamedDiff creates a named migration file containing the statements to resolve the diff between the Ent schema and the connected database.
Click to show internal directories.
Click to hide internal directories.