
ALTER TABLE CustomerPayment 
ADD COLUMN mode_id TINYINT UNSIGNED NOT NULL,
ADD COLUMN status TINYINT UNSIGNED NOT NULL,
ADD COLUMN related_payment_id INTEGER UNSIGNED DEFAULT NULL,
ADD FOREIGN KEY (mode_id)
    REFERENCES PaymentModeMaster (id)
    ON DELETE NO ACTION
    ON UPDATE CASCADE,
ADD FOREIGN KEY (status)
    REFERENCES PaymentStatusMaster (id)
    ON DELETE NO ACTION
    ON UPDATE CASCADE,
ADD FOREIGN KEY (related_payment_id)
    REFERENCES CustomerPayment (id)
    ON DELETE NO ACTION
    ON UPDATE CASCADE,
ADD INDEX related_payment_id (related_payment_id ASC);


Update CustomerPayment SET mode_id = 1,status = 1;

ALTER TABLE CustomerDemand ADD COLUMN is_valid TINYINT(1) UNSIGNED NOT NULL DEFAULT 1  AFTER unpaid_amount;


