Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ private void createInsertTrigger(final String tableName, final String auditTable
final LinkedHashMap<String, String> columnNames) throws SQLException {

StringBuilder trigger = new StringBuilder(
format("CREATE TRIGGER '%s_insert' AFTER INSERT ON '%s'\n", auditTable, tableName));
format("CREATE TRIGGER IF NOT EXISTS '%s_insert' AFTER INSERT ON '%s'\n", auditTable, tableName));
trigger.append("BEGIN\n");
trigger.append(format(" INSERT INTO '%s' (", auditTable));
for (String colName : columnNames.keySet()) {
Expand All @@ -347,7 +347,7 @@ private void createUpdateTrigger(final String tableName, final String auditTable
final LinkedHashMap<String, String> columnNames) throws SQLException {

StringBuilder trigger = new StringBuilder(
format("CREATE TRIGGER '%s_update' AFTER UPDATE ON '%s'\n", auditTable, tableName));
format("CREATE TRIGGER IF NOT EXISTS '%s_update' AFTER UPDATE ON '%s'\n", auditTable, tableName));
trigger.append("BEGIN\n");
trigger.append(format(" INSERT INTO '%s' (", auditTable));
for (String colName : columnNames.keySet()) {
Expand All @@ -370,7 +370,7 @@ private void createDeleteTrigger(final String tableName, final String auditTable
final LinkedHashMap<String, String> columnNames) throws SQLException {

StringBuilder trigger = new StringBuilder(
format("CREATE TRIGGER '%s_delete' AFTER DELETE ON '%s'\n", auditTable, tableName));
format("CREATE TRIGGER IF NOT EXISTS '%s_delete' AFTER DELETE ON '%s'\n", auditTable, tableName));
trigger.append("BEGIN\n");

final String insert = format(" INSERT INTO '%s' ('fid', audit_op) VALUES (OLD.fid, %s);\n",
Expand Down