<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class FixDeletedAtToDatetime extends Migration
{
    public function up()
    {
        // Cambia los tipos de deleted_at a DATETIME NULL si existen
        $tablas = ['albaranes', 'albaranes_lineas', 'envios', 'envios_lineas'];

        foreach ($tablas as $tabla) {
            $this->db->query("ALTER TABLE {$tabla} MODIFY COLUMN deleted_at DATETIME NULL");
        }
    }

    public function down()
    {
        // Opcional: puedes restaurar como TIMESTAMP NULL si lo deseas
        $tablas = ['albaranes', 'albaranes_lineas', 'envios', 'envios_lineas'];

        foreach ($tablas as $tabla) {
            $this->db->query("ALTER TABLE {$tabla} MODIFY COLUMN deleted_at TIMESTAMP NULL");
        }
    }
}
