fix: is_active 마이그레이션에 컬럼 존재 여부 체크 추가

- Schema::hasColumn()으로 컬럼 존재 여부 확인
- 개발 서버와 로컬 환경의 스키마 차이 대응
- 중복 컬럼 추가 오류 방지
This commit is contained in:
2025-11-17 16:41:57 +09:00
parent 517d5940e9
commit 8ce8a35f30

View File

@@ -11,20 +11,24 @@
*/ */
public function up(): void public function up(): void
{ {
// products 테이블에 is_active 추가 // products 테이블에 is_active 추가 (컬럼이 없을 때만)
Schema::table('products', function (Blueprint $table) { Schema::table('products', function (Blueprint $table) {
$table->tinyInteger('is_active') if (! Schema::hasColumn('products', 'is_active')) {
->default(1) $table->tinyInteger('is_active')
->after('updated_by') ->default(1)
->comment('활성 상태 (1: 활성, 0: 비활성)'); ->after('updated_by')
->comment('활성 상태 (1: 활성, 0: 비활성)');
}
}); });
// materials 테이블에 is_active 추가 // materials 테이블에 is_active 추가 (컬럼이 없을 때만)
Schema::table('materials', function (Blueprint $table) { Schema::table('materials', function (Blueprint $table) {
$table->tinyInteger('is_active') if (! Schema::hasColumn('materials', 'is_active')) {
->default(1) $table->tinyInteger('is_active')
->after('updated_by') ->default(1)
->comment('활성 상태 (1: 활성, 0: 비활성)'); ->after('updated_by')
->comment('활성 상태 (1: 활성, 0: 비활성)');
}
}); });
} }