Open HermannKroll opened 4 months ago
PostgreSQL Foreign Keys update:|
DocumentMetadata
ALTER TABLE document_metadata
DROP CONSTRAINT document_metadata_document_id_document_collection_fkey
ALTER TABLE document_metadata
ADD CONSTRAINT document_metadata_document_id_document_collection_fkey
FOREIGN KEY (document_id, document_collection)
REFERENCES document(id, collection)
ON DELETE CASCADE;
DocTaggedBy
ALTER TABLE doc_tagged_by
DROP CONSTRAINT doc_tagged_by_document_id_document_collection_fkey
ALTER TABLE doc_tagged_by
ADD CONSTRAINT doc_tagged_by_document_id_document_collection_fkey
FOREIGN KEY (document_id, document_collection)
REFERENCES document(id, collection)
ON DELETE CASCADE;
Tag
ALTER TABLE tag
DROP CONSTRAINT tag_document_id_document_collection_fkey
ALTER TABLE tag
ADD CONSTRAINT tag_document_id_document_collection_fkey
FOREIGN KEY (document_id, document_collection)
REFERENCES document(id, collection)
ON DELETE CASCADE;
DocumentSection
ALTER TABLE document_section
DROP CONSTRAINT fkey_document
ALTER TABLE document_section
ADD CONSTRAINT fkey_document
FOREIGN KEY (document_id, document_collection)
REFERENCES document(id, collection)
ON DELETE CASCADE;
Predication
ALTER TABLE predication
DROP CONSTRAINT predication_document_id_document_collection_fkey
ALTER TABLE predication
ADD CONSTRAINT predication_document_id_document_collection_fkey
FOREIGN KEY (document_id, document_collection)
REFERENCES document(id, collection)
ON DELETE CASCADE;
DocProcessedByIE
ALTER TABLE doc_processed_by_ie
DROP CONSTRAINT doc_processed_by_ie_document_id_document_collection_fkey
ALTER TABLE doc_processed_by_ie
ADD CONSTRAINT doc_processed_by_ie_document_id_document_collection_fkey
FOREIGN KEY (document_id, document_collection)
REFERENCES document(id, collection)
ON DELETE CASCADE;
DocumentMetadataService
ALTER TABLE document_metadata_service
DROP CONSTRAINT document_metadata_service_document_id_document_collection_fkey
ALTER TABLE document_metadata_service
ADD CONSTRAINT document_metadata_service_document_id_document_collection_fkey
FOREIGN KEY (document_id, document_collection)
REFERENCES document(id, collection)
ON DELETE CASCADE;
DocumentClassification
ALTER TABLE document_classification
ADD CONSTRAINT document_classification_document_id_document_collection_fkey
FOREIGN KEY (document_id, document_collection)
REFERENCES document(id, collection)
ON DELETE CASCADE;
All
ALTER TABLE document_metadata
DROP CONSTRAINT document_metadata_document_id_document_collection_fkey;
ALTER TABLE document_metadata
ADD CONSTRAINT document_metadata_document_id_document_collection_fkey
FOREIGN KEY (document_id, document_collection)
REFERENCES document(id, collection)
ON DELETE CASCADE;
ALTER TABLE doc_tagged_by
DROP CONSTRAINT doc_tagged_by_document_id_document_collection_fkey;
ALTER TABLE doc_tagged_by
ADD CONSTRAINT doc_tagged_by_document_id_document_collection_fkey
FOREIGN KEY (document_id, document_collection)
REFERENCES document(id, collection)
ON DELETE CASCADE;
ALTER TABLE tag
DROP CONSTRAINT tag_document_id_document_collection_fkey;
ALTER TABLE tag
ADD CONSTRAINT tag_document_id_document_collection_fkey
FOREIGN KEY (document_id, document_collection)
REFERENCES document(id, collection)
ON DELETE CASCADE;
ALTER TABLE predication
DROP CONSTRAINT predication_document_id_document_collection_fkey;
ALTER TABLE predication
ADD CONSTRAINT predication_document_id_document_collection_fkey
FOREIGN KEY (document_id, document_collection)
REFERENCES document(id, collection)
ON DELETE CASCADE;
ALTER TABLE document_section
DROP CONSTRAINT fkey_document;
ALTER TABLE document_section
ADD CONSTRAINT fkey_document
FOREIGN KEY (document_id, document_collection)
REFERENCES document(id, collection)
ON DELETE CASCADE;
ALTER TABLE doc_processed_by_ie
DROP CONSTRAINT doc_processed_by_ie_document_id_document_collection_fkey;
ALTER TABLE doc_processed_by_ie
ADD CONSTRAINT doc_processed_by_ie_document_id_document_collection_fkey
FOREIGN KEY (document_id, document_collection)
REFERENCES document(id, collection)
ON DELETE CASCADE;
ALTER TABLE document_metadata_service
DROP CONSTRAINT document_metadata_service_document_id_document_collection_fkey;
ALTER TABLE document_metadata_service
ADD CONSTRAINT document_metadata_service_document_id_document_collection_fkey
FOREIGN KEY (document_id, document_collection)
REFERENCES document(id, collection)
ON DELETE CASCADE;
ALTER TABLE document_classification
ADD CONSTRAINT document_classification_document_id_document_collection_fkey
FOREIGN KEY (document_id, document_collection)
REFERENCES document(id, collection)
ON DELETE CASCADE;
At the moment, we just import new documents into our database. We never update documents if a document is already present but has a modified content for instance.
Parameter in Loading Script --replace_existing
Suggestions: