fix: is_active 마이그레이션에 컬럼 존재 여부 체크 추가
- Schema::hasColumn()으로 컬럼 존재 여부 확인 - 개발 서버와 로컬 환경의 스키마 차이 대응 - 중복 컬럼 추가 오류 방지
This commit is contained in:
@@ -11,20 +11,24 @@
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
// products 테이블에 is_active 추가
|
||||
// products 테이블에 is_active 추가 (컬럼이 없을 때만)
|
||||
Schema::table('products', function (Blueprint $table) {
|
||||
$table->tinyInteger('is_active')
|
||||
->default(1)
|
||||
->after('updated_by')
|
||||
->comment('활성 상태 (1: 활성, 0: 비활성)');
|
||||
if (! Schema::hasColumn('products', 'is_active')) {
|
||||
$table->tinyInteger('is_active')
|
||||
->default(1)
|
||||
->after('updated_by')
|
||||
->comment('활성 상태 (1: 활성, 0: 비활성)');
|
||||
}
|
||||
});
|
||||
|
||||
// materials 테이블에 is_active 추가
|
||||
// materials 테이블에 is_active 추가 (컬럼이 없을 때만)
|
||||
Schema::table('materials', function (Blueprint $table) {
|
||||
$table->tinyInteger('is_active')
|
||||
->default(1)
|
||||
->after('updated_by')
|
||||
->comment('활성 상태 (1: 활성, 0: 비활성)');
|
||||
if (! Schema::hasColumn('materials', 'is_active')) {
|
||||
$table->tinyInteger('is_active')
|
||||
->default(1)
|
||||
->after('updated_by')
|
||||
->comment('활성 상태 (1: 활성, 0: 비활성)');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user