<?php

/**
 * Migration 0039 — estimate DVI photos + job status
 *
 * Two additions to the estimates table (0038), both customer-facing and both
 * matching what every auto-shop platform (Shopmonkey, Tekmetric, AutoLeap,
 * Mitchell 1, Shop-Ware) treats as table-stakes:
 *
 *  - photos:        JSON array of image URLs — a Digital Vehicle Inspection.
 *                   The shop attaches photos of the actual problem; the
 *                   customer sees them on the /estimate/{token} page before
 *                   approving. DVI is the single biggest driver of approval
 *                   rates in this category.
 *  - job_status:    where the job is once approved (received -> in_progress ->
 *                   ready -> completed), shown to the customer and texted to
 *                   them on change. NULL until the estimate is approved.
 *  - job_status_at: timestamp of the last status change.
 *
 * Additive and dormant: an estimate with no photos and no job_status behaves
 * exactly as before.
 */

if ( ! defined( 'ABSPATH' ) ) exit;

return [
    'description' => 'Add DVI photos + job status to estimates',

    'up' => [
        "ALTER TABLE {prefix}instinctor_estimates
            ADD COLUMN photos longtext NULL DEFAULT NULL AFTER note",
        "ALTER TABLE {prefix}instinctor_estimates
            ADD COLUMN job_status varchar(20) NULL DEFAULT NULL AFTER photos",
        "ALTER TABLE {prefix}instinctor_estimates
            ADD COLUMN job_status_at datetime NULL DEFAULT NULL AFTER job_status",
    ],

    'down' => [
        "ALTER TABLE {prefix}instinctor_estimates DROP COLUMN photos",
        "ALTER TABLE {prefix}instinctor_estimates DROP COLUMN job_status",
        "ALTER TABLE {prefix}instinctor_estimates DROP COLUMN job_status_at",
    ],
];
