49 lines
1.6 KiB
PHP
49 lines
1.6 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
use Illuminate\Database\Migrations\Migration;
|
||
|
|
use Illuminate\Database\Schema\Blueprint;
|
||
|
|
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
|
||
|
|
{
|
||
|
|
// 1. items 테이블 데이터 삭제
|
||
|
|
if (Schema::hasTable('items')) {
|
||
|
|
$itemsCount = DB::table('items')->count();
|
||
|
|
echo "items 테이블 데이터 삭제: {$itemsCount}건\n";
|
||
|
|
DB::table('items')->truncate();
|
||
|
|
}
|
||
|
|
|
||
|
|
// 2. item_id_mappings 테이블 삭제
|
||
|
|
if (Schema::hasTable('item_id_mappings')) {
|
||
|
|
$mappingsCount = DB::table('item_id_mappings')->count();
|
||
|
|
echo "item_id_mappings 테이블 삭제: {$mappingsCount}건\n";
|
||
|
|
Schema::dropIfExists('item_id_mappings');
|
||
|
|
}
|
||
|
|
|
||
|
|
// 3. items 테이블 삭제
|
||
|
|
if (Schema::hasTable('items')) {
|
||
|
|
echo "items 테이블 삭제\n";
|
||
|
|
Schema::dropIfExists('items');
|
||
|
|
}
|
||
|
|
|
||
|
|
echo "✅ Items 관련 테이블 롤백 완료\n";
|
||
|
|
}
|
||
|
|
|
||
|
|
public function down(): void
|
||
|
|
{
|
||
|
|
// 롤백 시 아무 작업도 하지 않음
|
||
|
|
// items 테이블은 재설계 후 새로운 마이그레이션으로 생성 예정
|
||
|
|
echo "⚠️ 이 마이그레이션은 롤백되지 않습니다. items 테이블 재설계 후 새로운 마이그레이션을 사용하세요.\n";
|
||
|
|
}
|
||
|
|
};
|