<?php
declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class NotificacionesPushTokensTable extends AbstractMigration
{
    public function change(): void
    {
        $table = $this->table('notificaciones_push_tokens');
        $table
            ->addColumn('usuario_id', 'integer', ['signed' => false])
            ->addColumn('token', 'string', ['limit' => 255])
            ->addColumn('plataforma', 'enum', ['values' => ['android', 'ios', 'web'], 'default' => 'android'])
            ->addColumn('created_at', 'timestamp', ['default' => 'CURRENT_TIMESTAMP'])
            ->addColumn('updated_at', 'timestamp', ['null' => true, 'update' => 'CURRENT_TIMESTAMP'])
            ->addForeignKey('usuario_id', 'usuarios', 'id', ['delete' => 'CASCADE', 'update' => 'CASCADE'])
            ->addIndex(['token'], ['unique' => true])
            ->create();
    }
}
