From 079f4b0ffb163e1822cbaaa1bb4b87fb6c448c8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B6=8C=ED=98=81=EC=84=B1?= Date: Tue, 10 Mar 2026 23:01:12 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20[=EB=AC=B8=EC=84=9C]=20document=5Fdata,?= =?UTF-8?q?=20document=5Fapprovals,=20document=5Fattachments=EC=97=90=20te?= =?UTF-8?q?nant=5Fid=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 3개 테이블에 tenant_id 컬럼 + 인덱스 추가 - 기존 데이터는 부모 테이블(documents)에서 tenant_id 자동 채움 - 멀티테넌시 일관성 확보 및 데이터 동기화 지원 Co-Authored-By: Claude Opus 4.6 --- ...dd_tenant_id_to_document_detail_tables.php | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 database/migrations/2026_03_10_224806_add_tenant_id_to_document_detail_tables.php diff --git a/database/migrations/2026_03_10_224806_add_tenant_id_to_document_detail_tables.php b/database/migrations/2026_03_10_224806_add_tenant_id_to_document_detail_tables.php new file mode 100644 index 0000000..b34858e --- /dev/null +++ b/database/migrations/2026_03_10_224806_add_tenant_id_to_document_detail_tables.php @@ -0,0 +1,46 @@ +unsignedBigInteger('tenant_id')->nullable()->after('id')->comment('테넌트 ID'); + $table->index('tenant_id'); + }); + + // 부모 테이블(documents)에서 tenant_id 채우기 + DB::statement(" + UPDATE {$table} t + JOIN documents d ON t.document_id = d.id + SET t.tenant_id = d.tenant_id + "); + } + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + $tables = ['document_data', 'document_approvals', 'document_attachments']; + + foreach ($tables as $table) { + Schema::table($table, function (Blueprint $table) { + $table->dropIndex(['tenant_id']); + $table->dropColumn('tenant_id'); + }); + } + } +}; \ No newline at end of file