ALTER TABLE farm_depreciation_manual_inputs
    ADD COLUMN IF NOT EXISTS cutover_date DATE;

UPDATE farm_depreciation_manual_inputs
SET cutover_date = COALESCE(cutover_date, DATE(created_at))
WHERE cutover_date IS NULL;

ALTER TABLE farm_depreciation_manual_inputs
    ALTER COLUMN cutover_date SET NOT NULL;

CREATE INDEX IF NOT EXISTS idx_farm_depreciation_manual_inputs_cutover_date
    ON farm_depreciation_manual_inputs (cutover_date);
