<?php

namespace App\OldDataMigrations;

class CuttingMigration extends BaseOldDataMigration
{
    public function priority(): int
    {
        return 10;
    }

    public function migrate(): array
    {
        $results = [];

        $results['cuttings'] = $this->migrateTableWithoutColumns('cuttings', ['other_cost', 'sewing_cost', 'submitted_by_id']);
        $results['cutting_material_combinations'] = $this->migrateTable('cutting_material_combinations');
        $results['cutting_materials'] = $this->migrateTable('cutting_materials', function ($row) {
            if (isset($row['material_usage']) && is_string($row['material_usage'])) {
                $row['material_usage'] = (int) round($row['material_usage']);
            }

            return $row;
        });
        $results['cutting_results'] = $this->migrateTable('cutting_results');

        return $results;
    }
}
