From 47a6facb6b0d76bd6b4f53917a582b953c353bbd Mon Sep 17 00:00:00 2001 From: kent Date: Mon, 1 Dec 2025 00:40:17 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20[archived-records]=20archived=5Frecords?= =?UTF-8?q?=20=ED=85=8C=EC=9D=B4=EB=B8=94=EC=97=90=20tenant=5Fid=20?= =?UTF-8?q?=EC=BB=AC=EB=9F=BC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 테넌트별 아카이브 필터링을 위한 tenant_id 컬럼 추가 - FK 제약조건 없음 (삭제된 테넌트 참조 가능) - 기존 테넌트 레코드에 main_data.id로 tenant_id 업데이트 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- ...2115_add_tenant_id_to_archived_records.php | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 database/migrations/2025_12_01_002115_add_tenant_id_to_archived_records.php diff --git a/database/migrations/2025_12_01_002115_add_tenant_id_to_archived_records.php b/database/migrations/2025_12_01_002115_add_tenant_id_to_archived_records.php new file mode 100644 index 0000000..70f5f95 --- /dev/null +++ b/database/migrations/2025_12_01_002115_add_tenant_id_to_archived_records.php @@ -0,0 +1,43 @@ +unsignedBigInteger('tenant_id')->nullable()->after('record_type'); + $table->index('tenant_id'); + }); + + // 기존 데이터 처리: tenant 타입의 경우 main_data에서 id 추출 + DB::statement(" + UPDATE archived_records + SET tenant_id = JSON_UNQUOTE(JSON_EXTRACT(main_data, '$.id')) + WHERE record_type = 'tenant' AND tenant_id IS NULL + "); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('archived_records', function (Blueprint $table) { + $table->dropIndex(['tenant_id']); + $table->dropColumn('tenant_id'); + }); + } +}; \ No newline at end of file