@@ 61-82 (lines=22) @@ | ||
58 | $dbalTableDiffService->createOrUpdateTable($localDelete); |
|
59 | } |
|
60 | ||
61 | public function createInsertTrigger(Table $table) |
|
62 | { |
|
63 | $triggerName = sprintf("TRG_%s_ONINSERT", $table->getName()); |
|
64 | ||
65 | $sql = sprintf(' |
|
66 | DROP TRIGGER IF EXISTS %s; |
|
67 | ||
68 | CREATE TRIGGER %s AFTER INSERT ON `%s` |
|
69 | FOR EACH ROW |
|
70 | BEGIN |
|
71 | IF (NEW.lastActivityTime IS NULL) THEN |
|
72 | INSERT INTO local_insert VALUES (%s, NEW.id); |
|
73 | DELETE FROM local_delete WHERE table_name = %s AND id = NEW.id; |
|
74 | DELETE FROM local_update WHERE table_name = %s AND id = NEW.id; |
|
75 | END IF; |
|
76 | END; |
|
77 | ||
78 | ', $triggerName, $triggerName, $table->getName(), $this->connection->quote($table->getName()), $this->connection->quote($table->getName()), $this->connection->quote($table->getName())); |
|
79 | ||
80 | ||
81 | $this->connection->exec($sql); |
|
82 | } |
|
83 | ||
84 | public function createDeleteTrigger(Table $table) |
|
85 | { |
|
@@ 84-103 (lines=20) @@ | ||
81 | $this->connection->exec($sql); |
|
82 | } |
|
83 | ||
84 | public function createDeleteTrigger(Table $table) |
|
85 | { |
|
86 | $triggerName = sprintf("TRG_%s_ONDELETE", $table->getName()); |
|
87 | ||
88 | $sql = sprintf(' |
|
89 | DROP TRIGGER IF EXISTS %s; |
|
90 | ||
91 | CREATE TRIGGER %s BEFORE DELETE ON `%s` |
|
92 | FOR EACH ROW |
|
93 | BEGIN |
|
94 | INSERT INTO local_delete VALUES (%s, OLD.id); |
|
95 | DELETE FROM local_insert WHERE table_name = %s AND id = OLD.id; |
|
96 | DELETE FROM local_update WHERE table_name = %s AND id = OLD.id; |
|
97 | END; |
|
98 | ||
99 | ', $triggerName, $triggerName, $table->getName(), $this->connection->quote($table->getName()), $this->connection->quote($table->getName()), $this->connection->quote($table->getName())); |
|
100 | ||
101 | ||
102 | $this->connection->exec($sql); |
|
103 | } |
|
104 | ||
105 | public function createUpdateTrigger(Table $table) |
|
106 | { |