-- Migration: Add created-by / created-datetime tracking to all tables
-- Run: mysql -u root dms_db < dms_created_tracking_migration.sql

ALTER TABLE categories ADD COLUMN dtmCreated DATETIME DEFAULT CURRENT_TIMESTAMP;
ALTER TABLE currencies ADD COLUMN dtmCreated DATETIME DEFAULT CURRENT_TIMESTAMP;
ALTER TABLE deliveries ADD COLUMN dtmCreated DATETIME DEFAULT CURRENT_TIMESTAMP;
ALTER TABLE payments ADD COLUMN dtmCreated DATETIME DEFAULT CURRENT_TIMESTAMP;
ALTER TABLE products ADD COLUMN dtmCreated DATETIME DEFAULT CURRENT_TIMESTAMP;
ALTER TABLE purchase_orders ADD COLUMN dtmCreated DATETIME DEFAULT CURRENT_TIMESTAMP;
ALTER TABLE sales_orders ADD COLUMN dtmCreated DATETIME DEFAULT CURRENT_TIMESTAMP;
ALTER TABLE stock_transactions ADD COLUMN dtmCreated DATETIME DEFAULT CURRENT_TIMESTAMP;
ALTER TABLE units ADD COLUMN dtmCreated DATETIME DEFAULT CURRENT_TIMESTAMP;

ALTER TABLE cheques ADD COLUMN intCreatedBy INT DEFAULT NULL, ADD COLUMN dtmCreated DATETIME DEFAULT CURRENT_TIMESTAMP;
ALTER TABLE warehouses ADD COLUMN intCreatedBy INT DEFAULT NULL, ADD COLUMN dtmCreated DATETIME DEFAULT CURRENT_TIMESTAMP;
ALTER TABLE banks ADD COLUMN intCreatedBy INT DEFAULT NULL;
ALTER TABLE branches ADD COLUMN intCreatedBy INT DEFAULT NULL;
