revert: [attendance] MNG 마이그레이션 정책 변경 되돌림
- MNG 마이그레이션 파일 삭제 (API에서 관리) - CLAUDE.md DB 아키텍처 규칙 원래대로 복원 - 마이그레이션은 API 프로젝트에서만 관리
This commit is contained in:
58
CLAUDE.md
58
CLAUDE.md
@@ -128,52 +128,42 @@ ### Tailwind 기본 클래스는 그대로 사용
|
||||
|
||||
## 데이터베이스 아키텍처 (필수 규칙)
|
||||
|
||||
> **2026-02-27 정책 변경**: API/React 운영 배포 중지 기간 동안 MNG에서 마이그레이션 생성 및 실행을 허용한다.
|
||||
> **경고: MNG 프로젝트에서는 마이그레이션 파일을 생성하지 않습니다!**
|
||||
|
||||
### 핵심 원칙
|
||||
|
||||
| 작업 | MNG에서 | 비고 |
|
||||
|------|---------|------|
|
||||
| 마이그레이션 생성 | ✅ 허용 | 운영 배포에 필요한 테이블 |
|
||||
| 마이그레이션 실행 | ✅ 허용 | `php artisan migrate` |
|
||||
| 모델 작성 | ✅ 허용 | |
|
||||
| 시더 | ⚠️ MNG 전용만 | MngMenuSeeder 등 |
|
||||
| 팩토리 | ❌ 금지 | |
|
||||
| 작업 | 올바른 위치 | MNG에서 |
|
||||
|------|------------|---------|
|
||||
| 마이그레이션 생성 | `/home/aweso/sam/api/database/migrations/` | ❌ 금지 |
|
||||
| 마이그레이션 실행 | `docker exec sam-api-1 php artisan migrate` | ❌ 금지 |
|
||||
| 테이블 생성/수정 | API 프로젝트에서만 | ❌ 금지 |
|
||||
|
||||
### MNG 마이그레이션 작성 규칙
|
||||
### MNG database 폴더 상태
|
||||
|
||||
1. API develop에 동일 마이그레이션이 있으면 **파일명을 동일하게** 유지
|
||||
2. `Schema::hasTable()` 가드 **필수** — 중복 실행 방지
|
||||
|
||||
```php
|
||||
public function up(): void
|
||||
{
|
||||
if (Schema::hasTable('table_name')) {
|
||||
return;
|
||||
}
|
||||
Schema::create('table_name', function (Blueprint $table) {
|
||||
// ...
|
||||
});
|
||||
}
|
||||
```
|
||||
/home/aweso/sam/mng/database/
|
||||
├── migrations/ ← 비어있음 (파일 생성 금지!)
|
||||
├── seeders/ ← MNG 전용 시더만 허용 (예: MngMenuSeeder)
|
||||
└── factories/ ← 사용 안 함
|
||||
```
|
||||
|
||||
### 마이그레이션 실행
|
||||
### MNG에서 허용되는 것
|
||||
|
||||
```bash
|
||||
# 로컬 (Docker)
|
||||
docker exec sam-mng-1 php artisan migrate
|
||||
- ✅ 컨트롤러, 뷰, 라우트 작성
|
||||
- ✅ 모델 작성 (API의 테이블 사용)
|
||||
- ✅ MNG 전용 시더 (MngMenuSeeder 등)
|
||||
|
||||
# 개발 서버
|
||||
cd /home/webservice/mng && php artisan migrate
|
||||
### MNG에서 금지되는 것
|
||||
|
||||
# 운영 서버 (--force 필수)
|
||||
cd /home/webservice/mng && php artisan migrate --force
|
||||
```
|
||||
- ❌ `database/migrations/` 에 파일 생성
|
||||
- ❌ `docker exec sam-mng-1 php artisan migrate` 실행
|
||||
- ❌ 테이블 구조 변경 관련 작업
|
||||
|
||||
### 향후 정리
|
||||
### 새 테이블이 필요할 때
|
||||
|
||||
- API 운영 배포 재개 시 MNG 마이그레이션을 API로 통합 정리
|
||||
- 동일 파일명 + `Schema::hasTable()` 가드로 충돌 없음
|
||||
1. API 프로젝트에서 마이그레이션 생성
|
||||
2. `docker exec sam-api-1 php artisan migrate` 실행
|
||||
3. MNG에서 해당 테이블의 모델만 작성
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
if (Schema::hasTable('attendance_requests')) {
|
||||
return;
|
||||
}
|
||||
|
||||
Schema::create('attendance_requests', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('tenant_id');
|
||||
$table->unsignedBigInteger('user_id')->comment('신청자');
|
||||
$table->enum('request_type', ['vacation', 'businessTrip', 'remote', 'fieldWork'])->comment('신청 유형');
|
||||
$table->date('start_date');
|
||||
$table->date('end_date');
|
||||
$table->text('reason')->nullable()->comment('사유');
|
||||
$table->enum('status', ['pending', 'approved', 'rejected'])->default('pending');
|
||||
$table->unsignedBigInteger('approved_by')->nullable()->comment('승인자');
|
||||
$table->timestamp('approved_at')->nullable();
|
||||
$table->text('reject_reason')->nullable()->comment('반려 사유');
|
||||
$table->json('json_details')->nullable()->comment('반차 구분 등 추가 정보');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->foreign('tenant_id')->references('id')->on('tenants')->cascadeOnDelete();
|
||||
$table->foreign('user_id')->references('id')->on('users')->cascadeOnDelete();
|
||||
|
||||
$table->index(['tenant_id', 'status']);
|
||||
$table->index(['tenant_id', 'user_id']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('attendance_requests');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user