unsignedBigInteger('tenant_id')->after('id')->comment('FK: 테넌트 ID')->default(1); // default 값은 마이그레이션 중 기존 데이터 보호용 // 2. 컬럼별 주석 보강 $table->string('name', 255)->comment('회원 이름')->change(); $table->string('email', 255)->comment('이메일')->change(); $table->string('password', 255)->comment('비밀번호')->change(); $table->string('profile_photo_path', 2048)->nullable()->comment('프로필 사진 경로')->change(); $table->string('remember_token', 100)->nullable()->comment('자동로그인 토큰')->change(); // 3. soft delete 추가 $table->softDeletes()->comment('삭제일시(소프트삭제)'); // 4. 유니크키 변경: (tenant_id, email)로 $table->dropUnique(['email']); $table->unique(['tenant_id', 'email'], 'uk_users_tenant_email'); }); // FK 추가 (이미 tenants 테이블이 있어야 함) Schema::table('users', function (Blueprint $table) { $table->foreign('tenant_id')->references('id')->on('tenants'); }); } public function down(): void { Schema::table('users', function (Blueprint $table) { // 롤백: FK/유니크/컬럼 제거 $table->dropForeign(['tenant_id']); $table->dropUnique('uk_users_tenant_email'); $table->dropColumn('tenant_id'); $table->dropSoftDeletes(); }); // 기존 유니크 복구 Schema::table('users', function (Blueprint $table) { $table->unique('email'); }); } };