54 lines
1.8 KiB
PHP
54 lines
1.8 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('folders', function (Blueprint $table) {
|
||
|
|
$table->id();
|
||
|
|
$table->unsignedBigInteger('tenant_id')->comment('테넌트 ID');
|
||
|
|
|
||
|
|
// 폴더 정보
|
||
|
|
$table->string('folder_key', 50)->comment('폴더 키 (product, quality, accounting)');
|
||
|
|
$table->string('folder_name', 100)->comment('폴더명 (생산관리, 품질관리, 회계)');
|
||
|
|
$table->text('description')->nullable()->comment('설명');
|
||
|
|
|
||
|
|
// 순서 및 표시
|
||
|
|
$table->integer('display_order')->default(0)->comment('표시 순서');
|
||
|
|
$table->boolean('is_active')->default(true)->comment('활성 여부');
|
||
|
|
|
||
|
|
// UI 커스터마이징 (선택)
|
||
|
|
$table->string('icon', 50)->nullable()->comment('아이콘 (icon-production, icon-quality)');
|
||
|
|
$table->string('color', 20)->nullable()->comment('색상 (#3B82F6)');
|
||
|
|
|
||
|
|
// 감사 컬럼
|
||
|
|
$table->unsignedBigInteger('created_by')->nullable();
|
||
|
|
$table->unsignedBigInteger('updated_by')->nullable();
|
||
|
|
$table->timestamps();
|
||
|
|
|
||
|
|
// 인덱스
|
||
|
|
$table->unique(['tenant_id', 'folder_key'], 'uq_tenant_folder_key');
|
||
|
|
$table->index(['tenant_id', 'is_active'], 'idx_active');
|
||
|
|
$table->index(['tenant_id', 'display_order'], 'idx_display_order');
|
||
|
|
|
||
|
|
// 외래키
|
||
|
|
$table->foreign('tenant_id')->references('id')->on('tenants')->onDelete('cascade');
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Reverse the migrations.
|
||
|
|
*/
|
||
|
|
public function down(): void
|
||
|
|
{
|
||
|
|
Schema::dropIfExists('folders');
|
||
|
|
}
|
||
|
|
};
|