diff --git a/database/migrations/2025_11_27_165658_add_tenant_type_to_tenants_table.php b/database/migrations/2025_11_27_165658_add_tenant_type_to_tenants_table.php new file mode 100644 index 0000000..3e7b955 --- /dev/null +++ b/database/migrations/2025_11_27_165658_add_tenant_type_to_tenants_table.php @@ -0,0 +1,41 @@ +enum('tenant_type', ['STD', 'TPL', 'HQ']) + ->default('STD') + ->after('tenant_st_code') + ->comment('테넌트 유형: STD=일반, TPL=템플릿, HQ=본사'); + $table->unsignedBigInteger('template_id') + ->nullable() + ->after('tenant_type') + ->comment('복사된 템플릿 테넌트 ID'); + + $table->foreign('template_id') + ->references('id') + ->on('tenants') + ->nullOnDelete(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('tenants', function (Blueprint $table) { + $table->dropForeign(['template_id']); + $table->dropColumn(['tenant_type', 'template_id']); + }); + } +}; diff --git a/database/migrations/2025_11_27_220000_create_admin_pm_tables.php b/database/migrations/2025_11_27_220000_create_admin_pm_tables.php new file mode 100644 index 0000000..9247947 --- /dev/null +++ b/database/migrations/2025_11_27_220000_create_admin_pm_tables.php @@ -0,0 +1,101 @@ +id()->comment('ID'); + $table->string('name', 100)->comment('프로젝트 이름'); + $table->text('description')->nullable()->comment('설명'); + $table->string('status', 20)->default('active')->comment('상태: active, completed, on_hold'); + $table->date('start_date')->nullable()->comment('시작일'); + $table->date('end_date')->nullable()->comment('종료일'); + $table->foreignId('created_by')->nullable()->comment('생성자 ID'); + $table->foreignId('updated_by')->nullable()->comment('수정자 ID'); + $table->foreignId('deleted_by')->nullable()->comment('삭제자 ID'); + $table->timestamps(); + $table->softDeletes(); + + // 인덱스 + $table->index('status', 'idx_admin_pm_projects_status'); + $table->index('name', 'idx_admin_pm_projects_name'); + }); + + // admin_pm_tasks: 작업(할일) 테이블 + Schema::create('admin_pm_tasks', function (Blueprint $table) { + $table->id()->comment('ID'); + $table->foreignId('project_id')->comment('프로젝트 ID') + ->constrained('admin_pm_projects') + ->onDelete('cascade'); + $table->string('title', 255)->comment('작업 제목'); + $table->text('description')->nullable()->comment('작업 설명'); + $table->string('status', 20)->default('todo')->comment('상태: todo, in_progress, done'); + $table->string('priority', 10)->default('medium')->comment('우선순위: low, medium, high'); + $table->date('due_date')->nullable()->comment('마감일'); + $table->unsignedInteger('sort_order')->default(0)->comment('정렬 순서'); + $table->foreignId('assignee_id')->nullable()->comment('담당자 ID'); + $table->foreignId('created_by')->nullable()->comment('생성자 ID'); + $table->foreignId('updated_by')->nullable()->comment('수정자 ID'); + $table->foreignId('deleted_by')->nullable()->comment('삭제자 ID'); + $table->timestamps(); + $table->softDeletes(); + + // 인덱스 + $table->index('project_id', 'idx_admin_pm_tasks_project_id'); + $table->index('status', 'idx_admin_pm_tasks_status'); + $table->index('priority', 'idx_admin_pm_tasks_priority'); + $table->index('due_date', 'idx_admin_pm_tasks_due_date'); + $table->index('sort_order', 'idx_admin_pm_tasks_sort_order'); + }); + + // admin_pm_issues: 이슈 테이블 + Schema::create('admin_pm_issues', function (Blueprint $table) { + $table->id()->comment('ID'); + $table->foreignId('project_id')->comment('프로젝트 ID') + ->constrained('admin_pm_projects') + ->onDelete('cascade'); + $table->foreignId('task_id')->nullable()->comment('연결된 작업 ID') + ->constrained('admin_pm_tasks') + ->onDelete('set null'); + $table->string('title', 255)->comment('이슈 제목'); + $table->text('description')->nullable()->comment('이슈 설명'); + $table->string('type', 20)->default('bug')->comment('타입: bug, feature, improvement'); + $table->string('status', 20)->default('open')->comment('상태: open, in_progress, resolved, closed'); + $table->foreignId('created_by')->nullable()->comment('생성자 ID'); + $table->foreignId('updated_by')->nullable()->comment('수정자 ID'); + $table->foreignId('deleted_by')->nullable()->comment('삭제자 ID'); + $table->timestamps(); + $table->softDeletes(); + + // 인덱스 + $table->index('project_id', 'idx_admin_pm_issues_project_id'); + $table->index('task_id', 'idx_admin_pm_issues_task_id'); + $table->index('type', 'idx_admin_pm_issues_type'); + $table->index('status', 'idx_admin_pm_issues_status'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('admin_pm_issues'); + Schema::dropIfExists('admin_pm_tasks'); + Schema::dropIfExists('admin_pm_projects'); + } +}; \ No newline at end of file