Skip to content
Snippets Groups Projects
Commit 4e8801b8 authored by apriestman's avatar apriestman
Browse files

Delete merged objects when their target is deleted

parent 3b9280c2
No related branches found
No related tags found
No related merge requests found
...@@ -418,7 +418,7 @@ private void createHostTables(Statement stmt) throws SQLException { ...@@ -418,7 +418,7 @@ private void createHostTables(Statement stmt) throws SQLException {
+ "person_id INTEGER, " + "person_id INTEGER, "
+ "merged_into " + dbQueryHelper.getBigIntType() + ", " + "merged_into " + dbQueryHelper.getBigIntType() + ", "
+ "FOREIGN KEY(person_id) REFERENCES tsk_persons(id) ON DELETE SET NULL, " + "FOREIGN KEY(person_id) REFERENCES tsk_persons(id) ON DELETE SET NULL, "
+ "FOREIGN KEY(merged_into) REFERENCES tsk_hosts(id) ON DELETE SET NULL, " + "FOREIGN KEY(merged_into) REFERENCES tsk_hosts(id) ON DELETE CASCADE, "
+ "UNIQUE(name)) "); + "UNIQUE(name)) ");
stmt.execute("CREATE TABLE tsk_host_addresses (id " + dbQueryHelper.getPrimaryKey() + " PRIMARY KEY, " stmt.execute("CREATE TABLE tsk_host_addresses (id " + dbQueryHelper.getPrimaryKey() + " PRIMARY KEY, "
...@@ -492,7 +492,7 @@ private void createAccountTables(Statement stmt) throws SQLException { ...@@ -492,7 +492,7 @@ private void createAccountTables(Statement stmt) throws SQLException {
+ "merged_into " + dbQueryHelper.getBigIntType() + " DEFAULT NULL, " + "merged_into " + dbQueryHelper.getBigIntType() + " DEFAULT NULL, "
+ "UNIQUE(realm_signature), " + "UNIQUE(realm_signature), "
+ "FOREIGN KEY(scope_host_id) REFERENCES tsk_hosts(id) ON DELETE CASCADE," + "FOREIGN KEY(scope_host_id) REFERENCES tsk_hosts(id) ON DELETE CASCADE,"
+ "FOREIGN KEY(merged_into) REFERENCES tsk_os_account_realms(id) ON DELETE SET NULL )"); + "FOREIGN KEY(merged_into) REFERENCES tsk_os_account_realms(id) ON DELETE CASCADE )");
// References tsk_objects, tsk_os_account_realms, tsk_persons // References tsk_objects, tsk_os_account_realms, tsk_persons
stmt.execute("CREATE TABLE tsk_os_accounts (os_account_obj_id " + dbQueryHelper.getBigIntType() + " PRIMARY KEY, " stmt.execute("CREATE TABLE tsk_os_accounts (os_account_obj_id " + dbQueryHelper.getBigIntType() + " PRIMARY KEY, "
...@@ -509,7 +509,7 @@ private void createAccountTables(Statement stmt) throws SQLException { ...@@ -509,7 +509,7 @@ private void createAccountTables(Statement stmt) throws SQLException {
+ "UNIQUE(signature, realm_id), " + "UNIQUE(signature, realm_id), "
+ "FOREIGN KEY(os_account_obj_id) REFERENCES tsk_objects(obj_id) ON DELETE CASCADE, " + "FOREIGN KEY(os_account_obj_id) REFERENCES tsk_objects(obj_id) ON DELETE CASCADE, "
+ "FOREIGN KEY(realm_id) REFERENCES tsk_os_account_realms(id) ON DELETE CASCADE," + "FOREIGN KEY(realm_id) REFERENCES tsk_os_account_realms(id) ON DELETE CASCADE,"
+ "FOREIGN KEY(merged_into) REFERENCES tsk_os_accounts(os_account_obj_id) ON DELETE SET NULL )"); + "FOREIGN KEY(merged_into) REFERENCES tsk_os_accounts(os_account_obj_id) ON DELETE CASCADE )");
} }
// Must be called after createAccountTables() and blackboard_attribute_types, blackboard_artifacts creation. // Must be called after createAccountTables() and blackboard_attribute_types, blackboard_artifacts creation.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment