add triggers on source_files insert/delete
This commit is contained in:
parent
b1e35f038a
commit
0ce73ac805
@ -23,4 +23,16 @@ CREATE TABLE destination_files (
|
|||||||
|
|
||||||
CREATE INDEX sourcefiles_by_name ON source_files (filename,id);
|
CREATE INDEX sourcefiles_by_name ON source_files (filename,id);
|
||||||
|
|
||||||
|
CREATE TRIGGER create_destinations AFTER INSERT ON source_files
|
||||||
|
BEGIN
|
||||||
|
INSERT INTO destination_files (source_file_id,destination_id)
|
||||||
|
SELECT source_files.id,destinations.id FROM source_files
|
||||||
|
INNER JOIN destinations
|
||||||
|
WHERE source_files.id=new.id;
|
||||||
|
END;
|
||||||
|
CREATE TRIGGER delete_destinations_files AFTER DELETE ON source_files
|
||||||
|
BEGIN
|
||||||
|
UPDATE destination_files SET source_file_id=NULL WHERE source_file_id=old.id;
|
||||||
|
END;
|
||||||
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user