- popups 테이블 마이그레이션 생성 - Popup 모델 (BelongsToTenant, SoftDeletes) - PopupService CRUD 구현 - FormRequest 검증 (Store/Update) - PopupController 6개 엔드포인트 - Swagger 문서 (PopupApi.php) - PROJECT_DEVELOPMENT_POLICY.md 정책 준수
52 lines
1.8 KiB
PHP
52 lines
1.8 KiB
PHP
<?php
|
|
|
|
use Illuminate\Database\Migrations\Migration;
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
use Illuminate\Support\Facades\Schema;
|
|
|
|
return new class extends Migration
|
|
{
|
|
/**
|
|
* Run the migrations.
|
|
*/
|
|
public function up(): void
|
|
{
|
|
Schema::create('popups', function (Blueprint $table) {
|
|
$table->id();
|
|
|
|
// 🔴 필수 컬럼 (조인/인덱싱)
|
|
$table->foreignId('tenant_id')->constrained()->cascadeOnDelete();
|
|
$table->string('target_type', 20)->default('all')->comment('대상 유형: all, department');
|
|
$table->unsignedBigInteger('target_id')->nullable()->comment('대상 ID (부서 ID)');
|
|
$table->string('title', 200)->comment('제목');
|
|
$table->text('content')->comment('내용');
|
|
$table->string('status', 20)->default('inactive')->index()->comment('상태: active, inactive');
|
|
$table->dateTime('started_at')->nullable()->index()->comment('노출 시작일');
|
|
$table->dateTime('ended_at')->nullable()->index()->comment('노출 종료일');
|
|
|
|
// 🟢 가변 컬럼 (JSON)
|
|
$table->json('options')->nullable()->comment('확장 옵션');
|
|
|
|
// 감사 컬럼
|
|
$table->unsignedBigInteger('created_by')->nullable()->comment('작성자');
|
|
$table->unsignedBigInteger('updated_by')->nullable()->comment('수정자');
|
|
$table->unsignedBigInteger('deleted_by')->nullable()->comment('삭제자');
|
|
|
|
$table->timestamps();
|
|
$table->softDeletes();
|
|
|
|
// 인덱스
|
|
$table->index('target_type');
|
|
$table->index(['tenant_id', 'status', 'started_at', 'ended_at']);
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Reverse the migrations.
|
|
*/
|
|
public function down(): void
|
|
{
|
|
Schema::dropIfExists('popups');
|
|
}
|
|
};
|