108 lines
4 KiB
PHP
108 lines
4 KiB
PHP
<?php
|
|
|
|
use Illuminate\Database\Migrations\Migration;
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
use Illuminate\Support\Facades\Schema;
|
|
|
|
return new class extends Migration
|
|
{
|
|
/**
|
|
* Run the migrations.
|
|
*/
|
|
public function up(): void
|
|
{
|
|
Schema::create('users', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->string('name');
|
|
$table->string('email')->unique();
|
|
$table->timestamp('email_verified_at')->nullable();
|
|
$table->string('password');
|
|
$table->rememberToken();
|
|
$table->timestamps();
|
|
});
|
|
|
|
Schema::create('password_reset_tokens', function (Blueprint $table) {
|
|
$table->string('email')->primary();
|
|
$table->string('token');
|
|
$table->timestamp('created_at')->nullable();
|
|
});
|
|
|
|
Schema::create('jobs', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->string('queue')->index();
|
|
$table->longText('payload');
|
|
$table->unsignedTinyInteger('attempts');
|
|
$table->unsignedInteger('reserved_at')->nullable();
|
|
$table->unsignedInteger('available_at');
|
|
$table->unsignedInteger('created_at');
|
|
});
|
|
|
|
Schema::create('job_batches', function (Blueprint $table) {
|
|
$table->string('id')->primary();
|
|
$table->string('name');
|
|
$table->integer('total_jobs');
|
|
$table->integer('pending_jobs');
|
|
$table->integer('failed_jobs');
|
|
$table->longText('failed_job_ids');
|
|
$table->mediumText('options')->nullable();
|
|
$table->integer('cancelled_at')->nullable();
|
|
$table->integer('created_at');
|
|
$table->integer('finished_at')->nullable();
|
|
});
|
|
|
|
Schema::create('failed_jobs', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->string('uuid')->unique();
|
|
$table->text('connection');
|
|
$table->text('queue');
|
|
$table->longText('payload');
|
|
$table->longText('exception');
|
|
$table->timestamp('failed_at')->useCurrent();
|
|
});
|
|
|
|
Schema::create('categories', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->foreignId('parent_id')->nullable()->constrained('categories')->nullOnDelete();
|
|
$table->string('name');
|
|
$table->string('slug')->unique();
|
|
$table->text('description')->nullable();
|
|
$table->boolean('active')->default(true);
|
|
$table->unsignedInteger('sort_order')->default(0);
|
|
$table->timestamps();
|
|
|
|
$table->index(['parent_id', 'active']);
|
|
});
|
|
|
|
Schema::create('brands', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->string('name');
|
|
$table->string('slug')->unique();
|
|
$table->text('description')->nullable();
|
|
$table->string('website_url')->nullable();
|
|
$table->boolean('active')->default(true);
|
|
$table->timestamps();
|
|
|
|
$table->index('active');
|
|
});
|
|
|
|
Schema::create('products', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->foreignId('category_id')->constrained()->cascadeOnDelete();
|
|
$table->foreignId('brand_id')->constrained()->cascadeOnDelete();
|
|
$table->string('name');
|
|
$table->string('slug')->unique();
|
|
$table->string('sku')->unique();
|
|
$table->text('short_description')->nullable();
|
|
$table->longText('description')->nullable();
|
|
$table->decimal('price', 12, 2);
|
|
$table->unsignedInteger('stock_quantity')->default(0);
|
|
$table->boolean('active')->default(true);
|
|
$table->timestamp('published_at')->nullable();
|
|
$table->timestamps();
|
|
|
|
$table->index(['category_id', 'brand_id']);
|
|
$table->index(['active', 'published_at']);
|
|
$table->index('price');
|
|
});
|
|
}
|
|
};
|