This commit is contained in:
parent
1a1e7742d3
commit
3c038a060c
|
@ -0,0 +1,12 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`supplierDms_afterDelete`
|
||||
AFTER DELETE ON `supplierDms`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
INSERT INTO clientLog
|
||||
SET `action` = 'delete',
|
||||
`changedModel` = 'supplierDms',
|
||||
`changedModelId` = OLD.dmsFk,
|
||||
`userFk` = account.myUser_getId();
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -0,0 +1,8 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=root@localhost TRIGGER vn.supplierDms_beforeInsert
|
||||
BEFORE INSERT ON supplierDms
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
SET NEW.editorFk = account.myUser_getId();
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -0,0 +1,8 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=root@localhost TRIGGER vn.supplierDms_beforeUpdate
|
||||
BEFORE UPDATE ON supplierDms
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
SET NEW.editorFk = account.myUser_getId();
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -4,7 +4,14 @@ CREATE TABLE IF NOT EXISTS vn.supplierDms(
|
|||
dmsFk int(11) NOT NULL,
|
||||
editorFk int(10) unsigned DEFAULT NULL,
|
||||
PRIMARY KEY (id),
|
||||
CONSTRAINT clientDms_fk_editor FOREIGN KEY (editorFk) REFERENCES account.user(id),
|
||||
CONSTRAINT supplierDms_fk_editor FOREIGN KEY (editorFk) REFERENCES account.user(id),
|
||||
CONSTRAINT dmsFk FOREIGN KEY (dmsFk) REFERENCES dms(id) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT supplierFk FOREIGN KEY (supplierFk) REFERENCES supplier(id) ON UPDATE CASCADE
|
||||
);
|
||||
|
||||
ALTER TABLE `supplierLog`
|
||||
MODIFY COLUMN `changedModel` ENUM('Supplier','SupplierAddress','SupplierAccount','SupplierContact','SupplierDms') NOT NULL DEFAULT 'Supplier';
|
||||
|
||||
ALTER TABLE `vn`.`supplierDms`
|
||||
ADD IF NOT EXISTS editorFk INT UNSIGNED NULL,
|
||||
ADD CONSTRAINT supplierDms_fk_editor FOREIGN KEY IF NOT EXISTS (editorFk) REFERENCES account.`user`(id);
|
Loading…
Reference in New Issue