humzakt commented on issue #939: URL: https://github.com/apache/age/issues/939#issuecomment-1570674997
t seems like the foreign key constraints on your edges table are set to CASCADE DELETE. This means that when an edge is deleted, the corresponding vertices get deleted as well. What you need to do is to change these constraints so that the deletion of an edge doesn't lead to the deletion of its corresponding vertices. Here's how you can alter your foreign key constraint: First, you need to drop the existing constraints. Here's how you might do it (replace fk_edge_vertex1 and fk_edge_vertex2 with your actual constraint names, and edges with your actual table name): ``` ALTER TABLE edges DROP CONSTRAINT fk_edge_vertex1; ALTER TABLE edges DROP CONSTRAINT fk_edge_vertex2; ``` After dropping the existing constraints, you can add new foreign key constraints that don't cascade on delete. Here's how: ``` ALTER TABLE edges ADD CONSTRAINT fk_edge_vertex1 FOREIGN KEY (vertex1_id) REFERENCES vertices(id); ALTER TABLE edges ADD CONSTRAINT fk_edge_vertex2 FOREIGN KEY (vertex2_id) REFERENCES vertices(id); ``` In these statements, vertex1_id and vertex2_id are the foreign keys in the edges table, and id is the primary key in the vertices table. This will ensure that when an edge is deleted, the corresponding vertices will not be deleted. Please note: always be cautious when altering table structures in a production environment. It's a good practice to backup your database before making such changes. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
