<?php
declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

/**
 * Round out the asset row so we can drive:
 *   - Criticality-based PM frequency (A = weekly, B = monthly, C = quarterly)
 *   - Warranty-claim workflow (auto-flag WOs that fall inside the warranty window)
 *
 * parent_asset_id already exists — hierarchy is powered by that column.
 */
final class AssetCriticalityWarranty extends AbstractMigration
{
    public function change(): void
    {
        $this->table('assets')
            ->addColumn('criticality', 'string', [
                'limit' => 1, 'default' => 'C', 'after' => 'status',
                'comment' => 'A=critical, B=important, C=standard',
            ])
            ->addColumn('warranty_expires_at', 'date', [
                'null' => true, 'after' => 'installed_at',
            ])
            ->addIndex(['tenant_id', 'criticality'])
            ->update();
    }
}
