<?php
declare(strict_types=1);

use Celena\Core\Database\Blueprint;
use Celena\Core\Database\Connection;
use Celena\Core\Database\Schema;

return function (Schema $schema, Connection $conn): void {
    $schema->create('shop_categories', function (Blueprint $t) {
        $t->id();
        $t->string('slug', 191);
        $t->string('title', 255);
        $t->text('description')->nullable();
        $t->bigInteger('parent_id')->nullable();
        $t->integer('sort_order')->default(0);
        $t->datetime('created_at')->nullable();
        $t->unique('slug');
        $t->index('parent_id');
    });

    $schema->create('shop_products', function (Blueprint $t) {
        $t->id();
        $t->string('slug', 191);
        $t->string('title', 255);
        $t->text('short')->nullable();
        $t->text('body')->nullable();
        $t->decimal('price', 12, 2)->default(0);
        $t->decimal('old_price', 12, 2)->nullable();
        $t->string('sku', 64)->nullable();
        $t->integer('stock')->default(0);
        $t->boolean('is_active')->default(true);
        $t->bigInteger('category_id')->nullable();
        $t->string('cover', 500)->nullable();
        $t->json('images')->nullable();
        $t->json('attributes')->nullable();
        $t->string('seo_title', 255)->nullable();
        $t->text('seo_description')->nullable();
        $t->datetime('created_at')->nullable();
        $t->datetime('updated_at')->nullable();
        $t->unique('slug');
        $t->index('category_id');
        $t->index('is_active');
    });
};
