2025-12-12 09:45:37 +09:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
use Illuminate\Database\Migrations\Migration;
|
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
|
use Illuminate\Support\Facades\Schema;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Items 테이블 이관 롤백
|
|
|
|
|
*
|
|
|
|
|
* 이전 마이그레이션(2025_12_11_220200)에서 이관된 데이터를 정리하고
|
|
|
|
|
* items, item_id_mappings 테이블을 삭제합니다.
|
|
|
|
|
*
|
|
|
|
|
* 추후 items 테이블 정책 정리 후 재작업 예정
|
|
|
|
|
*/
|
|
|
|
|
return new class extends Migration
|
|
|
|
|
{
|
|
|
|
|
public function up(): void
|
|
|
|
|
{
|
2025-12-12 18:29:14 +09:00
|
|
|
// FK 제약 조건 비활성화
|
|
|
|
|
DB::statement('SET FOREIGN_KEY_CHECKS=0');
|
2025-12-12 09:45:37 +09:00
|
|
|
|
2025-12-12 18:29:14 +09:00
|
|
|
// 1. item_id_mappings 테이블 먼저 삭제 (FK 참조)
|
2025-12-12 09:45:37 +09:00
|
|
|
if (Schema::hasTable('item_id_mappings')) {
|
|
|
|
|
$mappingsCount = DB::table('item_id_mappings')->count();
|
|
|
|
|
echo "item_id_mappings 테이블 삭제: {$mappingsCount}건\n";
|
|
|
|
|
Schema::dropIfExists('item_id_mappings');
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-12 18:29:14 +09:00
|
|
|
// 2. items 테이블 삭제
|
2025-12-12 09:45:37 +09:00
|
|
|
if (Schema::hasTable('items')) {
|
2025-12-12 18:29:14 +09:00
|
|
|
$itemsCount = DB::table('items')->count();
|
|
|
|
|
echo "items 테이블 삭제: {$itemsCount}건\n";
|
2025-12-12 09:45:37 +09:00
|
|
|
Schema::dropIfExists('items');
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-12 18:29:14 +09:00
|
|
|
// FK 제약 조건 재활성화
|
|
|
|
|
DB::statement('SET FOREIGN_KEY_CHECKS=1');
|
|
|
|
|
|
2025-12-12 09:45:37 +09:00
|
|
|
echo "✅ Items 관련 테이블 롤백 완료\n";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function down(): void
|
|
|
|
|
{
|
|
|
|
|
// 롤백 시 아무 작업도 하지 않음
|
|
|
|
|
// items 테이블은 재설계 후 새로운 마이그레이션으로 생성 예정
|
|
|
|
|
echo "⚠️ 이 마이그레이션은 롤백되지 않습니다. items 테이블 재설계 후 새로운 마이그레이션을 사용하세요.\n";
|
|
|
|
|
}
|
2025-12-18 11:40:49 +09:00
|
|
|
};
|