Browse Source

Added triggers to update last_modification fields

Erik Winn 7 years ago
parent
commit
e74917565a
2 changed files with 15 additions and 0 deletions
  1. 8
    0
      database/quinta-with-data.sql
  2. 7
    0
      database/quinta.sql

+ 8
- 0
database/quinta-with-data.sql View File

@@ -1835,3 +1835,11 @@ ALTER TABLE `tracking_number`
1835 1835
 ALTER TABLE `zone_type`
1836 1836
   ADD CONSTRAINT `zone_type_ibfk_1` FOREIGN KEY (`country_id`) REFERENCES `country_type` (`id`) ON DELETE CASCADE;
1837 1837
 SET FOREIGN_KEY_CHECKS=1;
1838
+
1839
+-- auto update last_modification fields ..
1840
+CREATE TRIGGER content_item_last_mod BEFORE UPDATE ON content_item FOR EACH ROW SET NEW.last_modification = NOW();
1841
+CREATE TRIGGER address_last_mod BEFORE UPDATE ON address FOR EACH ROW SET NEW.last_modification = NOW();
1842
+CREATE TRIGGER order_address_last_mod BEFORE UPDATE ON order_address FOR EACH ROW SET NEW.last_modification = NOW();
1843
+CREATE TRIGGER order_last_mod BEFORE UPDATE ON `order` FOR EACH ROW SET NEW.last_modification = NOW();
1844
+CREATE TRIGGER shopping_cart_last_mod BEFORE UPDATE ON shopping_cart FOR EACH ROW SET NEW.last_modification = NOW();
1845
+CREATE TRIGGER page_last_mod BEFORE UPDATE ON page FOR EACH ROW SET NEW.last_modification = NOW();

+ 7
- 0
database/quinta.sql View File

@@ -1739,6 +1739,13 @@ INSERT INTO `zone_type` (`id`, `country_id`, `code`, `name`) VALUES
1739 1739
 (188, 13, 'VIC', 'Victoria'),
1740 1740
 (189, 13, 'WA', 'Western Australia');
1741 1741
 
1742
+-- auto update last_modification fields ..
1743
+CREATE TRIGGER content_item_last_mod BEFORE UPDATE ON content_item FOR EACH ROW SET NEW.last_modification = NOW();
1744
+CREATE TRIGGER address_last_mod BEFORE UPDATE ON address FOR EACH ROW SET NEW.last_modification = NOW();
1745
+CREATE TRIGGER order_address_last_mod BEFORE UPDATE ON order_address FOR EACH ROW SET NEW.last_modification = NOW();
1746
+CREATE TRIGGER order_last_mod BEFORE UPDATE ON `order` FOR EACH ROW SET NEW.last_modification = NOW();
1747
+CREATE TRIGGER shopping_cart_last_mod BEFORE UPDATE ON shopping_cart FOR EACH ROW SET NEW.last_modification = NOW();
1748
+CREATE TRIGGER page_last_mod BEFORE UPDATE ON page FOR EACH ROW SET NEW.last_modification = NOW();
1742 1749
 
1743 1750
 -- now we need some views for order totals, shipping, tax etc ..
1744 1751
 /*