diff --git a/src/db/postgres/lrsql/postgres/record.clj b/src/db/postgres/lrsql/postgres/record.clj index 326ece47a..2a75750fa 100644 --- a/src/db/postgres/lrsql/postgres/record.clj +++ b/src/db/postgres/lrsql/postgres/record.clj @@ -101,13 +101,7 @@ (-update-actor! [_ tx input] (update-actor! tx input)) (-delete-actor! [_ tx input] - (delete-actor-st2st tx input) - (delete-actor-st2activ tx input) - (delete-actor-attachments tx input) - (delete-actor-statements tx input) - (delete-actor-agent-profile tx input) - (delete-actor-state-document tx input) - (delete-actor-actor tx input)) + (delete-actor-and-dependents! tx input)) (-query-actor [_ tx input] (query-actor tx input)) diff --git a/src/db/postgres/lrsql/postgres/sql/ddl.sql b/src/db/postgres/lrsql/postgres/sql/ddl.sql index c8be52960..81d677060 100644 --- a/src/db/postgres/lrsql/postgres/sql/ddl.sql +++ b/src/db/postgres/lrsql/postgres/sql/ddl.sql @@ -108,11 +108,9 @@ CREATE TABLE IF NOT EXISTS statement_to_actor ( actor_ifi VARCHAR(255) NOT NULL, actor_type actor_type_enum NOT NULL, CONSTRAINT statement_fk - FOREIGN KEY (statement_id) REFERENCES xapi_statement(statement_id) - ON DELETE CASCADE, + FOREIGN KEY (statement_id) REFERENCES xapi_statement(statement_id), CONSTRAINT actor_fk FOREIGN KEY (actor_ifi, actor_type) REFERENCES actor(actor_ifi, actor_type) - ON DELETE CASCADE ); CREATE INDEX IF NOT EXISTS stmt_actor_stmt_fk ON statement_to_actor(statement_id); CREATE INDEX IF NOT EXISTS stmt_actor_actor_fk ON statement_to_actor(actor_ifi, actor_type); diff --git a/src/db/postgres/lrsql/postgres/sql/delete.sql b/src/db/postgres/lrsql/postgres/sql/delete.sql index 77bb1ae46..5d44c0984 100644 --- a/src/db/postgres/lrsql/postgres/sql/delete.sql +++ b/src/db/postgres/lrsql/postgres/sql/delete.sql @@ -63,44 +63,28 @@ AND secret_key = :secret-key AND scope = :scope::scope_enum; ----------------------begin components of delete-actor----- --- :name delete-actor-st2st +-- :name delete-actor-and-dependents! -- :command :execute -- :result :affected DELETE FROM statement_to_statement WHERE ancestor_id IN (SELECT statement_id FROM statement_to_actor WHERE actor_ifi = :actor-ifi) OR descendant_id IN (SELECT statement_id FROM statement_to_actor -WHERE actor_ifi = :actor-ifi) +WHERE actor_ifi = :actor-ifi); --- :name delete-actor-st2activ --- :command :execute --- :result :affected DELETE FROM statement_to_activity WHERE statement_id IN (SELECT statement_id FROM statement_to_actor -WHERE actor_ifi = :actor-ifi) +WHERE actor_ifi = :actor-ifi); --- :name delete-actor-attachments --- :command :execute --- :result :affected DELETE FROM attachment WHERE statement_id IN (SELECT statement_id FROM statement_to_actor -WHERE actor_ifi = :actor-ifi) +WHERE actor_ifi = :actor-ifi); --- :name delete-actor-statements --- :command :execute --- :result :affected DELETE FROM xapi_statement WHERE statement_id IN (SELECT statement_id FROM statement_to_actor -WHERE actor_ifi = :actor-ifi) +WHERE actor_ifi = :actor-ifi); --- :name delete-actor-agent-profile --- :command :execute --- :result :affected -DELETE FROM agent_profile_document WHERE agent_ifi = :actor-ifi --- :name delete-actor-state-document --- :command :execute --- :result :affected -DELETE FROM state_document WHERE agent_ifi = :actor-ifi +DELETE FROM agent_profile_document WHERE agent_ifi = :actor-ifi; --- :name delete-actor-actor --- :command :execute --- :result :affected -DELETE FROM actor where actor_ifi = :actor-ifi +DELETE FROM state_document WHERE agent_ifi = :actor-ifi; + +DELETE FROM actor where actor_ifi = :actor-ifi; +------------------end delete-actor--------------------