-- Migration 013: soft delete (trash) for the records an owner may want back.
-- Deleting now stamps deleted_at instead of removing the row; the admin Trash
-- page lists stamped rows per type with restore and permanent delete. Renters
-- especially need this because a hard delete cascades their payment history.
-- MySQL syntax (not MariaDB).

ALTER TABLE applications
    ADD COLUMN deleted_at DATETIME NULL,
    ADD KEY idx_applications_deleted (deleted_at);

ALTER TABLE payments
    ADD COLUMN deleted_at DATETIME NULL,
    ADD KEY idx_payments_deleted (deleted_at);

ALTER TABLE maintenance_tickets
    ADD COLUMN deleted_at DATETIME NULL,
    ADD KEY idx_tickets_deleted (deleted_at);

ALTER TABLE inspections
    ADD COLUMN deleted_at DATETIME NULL,
    ADD KEY idx_inspections_deleted (deleted_at);

ALTER TABLE renters
    ADD COLUMN deleted_at DATETIME NULL,
    ADD KEY idx_renters_deleted (deleted_at);
