From 5a0deddb58e044c29892d1a9ae41ed70ddb70593 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B3=B4=EA=B3=A4?= Date: Tue, 3 Mar 2026 14:20:33 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20[hr]=20=EC=82=AC=EC=97=85=EC=86=8C?= =?UTF-8?q?=EB=93=9D=EC=9E=90=20=EC=9E=84=EA=B8=88=EB=8C=80=EC=9E=A5=20dis?= =?UTF-8?q?play=5Fname/business=5Freg=5Fnumber=20=EC=BB=AC=EB=9F=BC=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - user_id nullable 변경 (직접 입력 대상자 지원) - display_name, business_reg_number 컬럼 추가 - 기존 데이터 earner 프로필에서 자동 채움 --- ...splay_name_to_business_income_payments.php | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 database/migrations/2026_03_03_100000_add_display_name_to_business_income_payments.php diff --git a/database/migrations/2026_03_03_100000_add_display_name_to_business_income_payments.php b/database/migrations/2026_03_03_100000_add_display_name_to_business_income_payments.php new file mode 100644 index 0000000..eacc9cb --- /dev/null +++ b/database/migrations/2026_03_03_100000_add_display_name_to_business_income_payments.php @@ -0,0 +1,47 @@ +unsignedBigInteger('user_id')->nullable()->change(); + $table->string('display_name', 100)->nullable()->after('user_id')->comment('상호/성명 (표시용)'); + $table->string('business_reg_number', 20)->nullable()->after('display_name')->comment('사업자등록번호'); + }); + + // 기존 데이터에 display_name/business_reg_number 채우기 + DB::statement(" + UPDATE business_income_payments bip + JOIN tenant_user_profiles tup ON tup.user_id = bip.user_id + AND tup.tenant_id = bip.tenant_id AND tup.worker_type = 'business_income' + SET bip.display_name = COALESCE( + JSON_UNQUOTE(JSON_EXTRACT(tup.json_extra, '$.business_name')), + (SELECT name FROM users WHERE id = bip.user_id) + ), + bip.business_reg_number = JSON_UNQUOTE(JSON_EXTRACT(tup.json_extra, '$.business_registration_number')) + WHERE bip.display_name IS NULL + "); + + // earner 프로필 없는 경우 users 테이블에서 이름만이라도 채우기 + DB::statement(" + UPDATE business_income_payments bip + JOIN users u ON u.id = bip.user_id + SET bip.display_name = u.name + WHERE bip.display_name IS NULL AND bip.user_id IS NOT NULL + "); + } + + public function down(): void + { + Schema::table('business_income_payments', function (Blueprint $table) { + $table->dropColumn(['display_name', 'business_reg_number']); + $table->unsignedBigInteger('user_id')->nullable(false)->change(); + }); + } +};