<?php
// CoreFlux/app/schemas/users.php

use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Schema\Table;

return function (Schema $schema, Table $table) {
    // $table->setName('users');

    $table->addColumn("id", "integer", ["autoincrement" => true, "notnull" => true]);
    $table->addColumn("name", "string", ["length" => 255, "notnull" => true]);
    $table->addColumn("email", "string", ["length" => 255, "notnull" => true]);
    $table->addColumn("password", "string", ["length" => 255, "notnull" => true]);
    $table->addColumn("created_at", "datetime_immutable", ["default" => "CURRENT_TIMESTAMP", "notnull" => true]);
    // --- CRITICAL FIX: Remove 'onUpdate' option ---
    $table->addColumn("updated_at", "datetime_immutable", ["default" => "CURRENT_TIMESTAMP", "notnull" => true]);
    // --- END CRITICAL FIX ---

    $table->setPrimaryKey(["id"]);
    $table->addUniqueIndex(["email"], "UNIQ_USER_EMAIL");
    $table->addIndex(["name"], "IDX_USER_NAME");
};