<?php
declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class UsuariosTable extends AbstractMigration
{
    public function change(): void
    {
        $table = $this->table('usuarios');
        $table
            ->addColumn('nombre', 'string', ['limit' => 150])
            ->addColumn('email', 'string', ['limit' => 150])
            ->addColumn('password_hash', 'string', ['limit' => 255])
            ->addColumn('rol', 'enum', ['values' => ['admin', 'tienda', 'repartidor', 'cliente']])
            ->addColumn('activo', 'boolean', ['default' => true])
            ->addColumn('created_at', 'timestamp', ['default' => 'CURRENT_TIMESTAMP'])
            ->addColumn('updated_at', 'timestamp', ['null' => true, 'update' => 'CURRENT_TIMESTAMP'])
            ->addIndex(['email'], ['unique' => true])
            ->create();
    }
}
