added wss tools 5

This commit is contained in:
2026-06-18 17:01:52 +03:30
parent f44063dbd2
commit dc440abf61
4 changed files with 111 additions and 2 deletions
@@ -0,0 +1,46 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
/**
* اگر migration قدیمی در جدول migrations ثبت شده ولی جدول categories ساخته نشده
* (Nothing to migrate + Table doesn't exist) — این فایل idempotent جدول را درست می‌کند.
*/
return new class extends Migration
{
public function up(): void
{
if (! Schema::hasTable('categories')) {
Schema::create('categories', function (Blueprint $table) {
$table->id();
$table->string('name')->unique();
$table->boolean('active')->default(true);
$table->boolean('show_in_filter')->default(true);
$table->boolean('show_in_select')->default(true);
$table->unsignedSmallInteger('sort_order')->default(0);
$table->timestamp('created_at')->nullable();
});
return;
}
Schema::table('categories', function (Blueprint $table) {
if (! Schema::hasColumn('categories', 'show_in_filter')) {
$table->boolean('show_in_filter')->default(true);
}
if (! Schema::hasColumn('categories', 'show_in_select')) {
$table->boolean('show_in_select')->default(true);
}
if (! Schema::hasColumn('categories', 'sort_order')) {
$table->unsignedSmallInteger('sort_order')->default(0);
}
});
}
public function down(): void
{
// عمداً خالی — rollback جدول را حذف نمی‌کند
}
};