<?php
// app/schemas/products.php

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

/**
 * Schema definition for the 'products' table.
 * Define your table structure using Doctrine DBAL's fluent API.
 *
 * Available types (case-insensitive):
 * string, text, integer, smallint, bigint, float, decimal, boolean,
 * datetime, datetime_immutable, date, date_immutable, time, time_immutable,
 * guid, binary, blob, json, array (for serializing PHP arrays)
 */
return function (Schema $schema, Table $table) {
    // $table->setName('products');

    $table->addColumn("id", "integer", ["autoincrement" => true, "notnull" => true]);
    $table->addColumn("name", "string", ["length" => 255, "notnull" => true]);
    $table->addColumn("slug", "string", ["length" => 255, "notnull" => true]);
    $table->addColumn("description", "text", ["notnull" => false]);
    $table->addColumn("short_description", "string", ["length" => 500, "notnull" => false]);
    $table->addColumn("sku", "string", ["length" => 100, "notnull" => true]);
    $table->addColumn("price", "decimal", ["precision" => 10, "scale" => 2, "notnull" => true]);
    $table->addColumn("discount_price", "decimal", ["precision" => 10, "scale" => 2, "notnull" => false]);
    $table->addColumn("weight", "decimal", ["precision" => 10, "scale" => 2, "notnull" => false]);
    $table->addColumn("status", "string", ["length" => 20, "default" => "active", "notnull" => true]);
    $table->addColumn("category_id", "integer", ["notnull" => false]);
    $table->addColumn("created_at", "datetime_immutable", ["default" => "CURRENT_TIMESTAMP", "notnull" => true]);
    $table->addColumn("updated_at", "datetime_immutable", ["default" => "CURRENT_TIMESTAMP", "notnull" => true]);

    $table->setPrimaryKey(["id"]);
    $table->addUniqueIndex(["sku"], "UNIQ_PRODUCT_SKU");
    $table->addIndex(["name"], "IDX_PRODUCT_NAME");
    $table->addIndex(["category_id"], "IDX_PRODUCT_CATEGORY");
};
