v7.0.0-beta.1 release

This commit is contained in:
HeuJung committed 2026-04-01 10:30:52 +09:00
commit 6595fd0eb5
3967 files changed
+1875383

No files matched your search

@@ -0,0 +1,41 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* SEO 캐시 통계 테이블을 생성합니다.
*
* @return void
*/
public function up(): void
{
Schema::create('seo_cache_stats', function (Blueprint $table) {
$table->id()->comment('ID');
$table->string('url')->comment('요청 URL');
$table->string('locale', 5)->comment('로케일');
$table->string('layout_name')->nullable()->comment('사용된 레이아웃명');
$table->string('module_identifier')->nullable()->comment('레이아웃 소유 모듈 식별자');
$table->string('type')->comment('유형 (hit 또는 miss)');
$table->integer('response_time_ms')->nullable()->comment('렌더링 소요 시간 (ms)');
$table->timestamp('created_at')->useCurrent()->comment('생성 시각');
$table->index('url', 'idx_seo_cache_stats_url');
$table->index('type', 'idx_seo_cache_stats_type');
$table->index('created_at', 'idx_seo_cache_stats_created_at');
});
}
/**
* SEO 캐시 통계 테이블을 삭제합니다.
*
* @return void
*/
public function down(): void
{
Schema::dropIfExists('seo_cache_stats');
}
};
@@ -0,0 +1,58 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->string('name')->comment('사용자 이름');
$table->string('nickname', 50)->nullable()->comment('닉네임');
$table->string('email')->unique()->comment('이메일 주소');
$table->timestamp('email_verified_at')->nullable()->comment('이메일 인증 일시');
$table->string('password')->comment('비밀번호 해시');
$table->string('language', 5)->default('ko')->comment('사용자 언어 설정 (ko: 한국어, en: 영어)');
$table->boolean('is_super')->default(false)->index()->comment('슈퍼 관리자 여부 (삭제 불가, 권한 관리 가능)');
$table->string('timezone', 50)->nullable()->default('Asia/Seoul')->comment('사용자 시간대 (예: Asia/Seoul, UTC)');
$table->string('country', 2)->nullable()->index()->comment('국가 코드 (ISO 3166-1 alpha-2)');
$table->string('status', 20)->default('active')->index()->comment('계정 상태 (active: 활성, inactive: 비활성, blocked: 차단, withdrawn: 탈퇴)');
$table->string('homepage')->nullable()->comment('홈페이지 URL');
$table->string('mobile', 20)->nullable()->index()->comment('휴대폰 번호');
$table->string('phone', 20)->nullable()->index()->comment('전화번호');
$table->string('zipcode', 10)->nullable()->comment('우편번호');
$table->string('address')->nullable()->comment('기본 주소');
$table->string('address_detail')->nullable()->comment('상세 주소');
$table->text('signature')->nullable()->comment('서명');
$table->text('bio')->nullable()->comment('자기소개');
$table->text('admin_memo')->nullable()->comment('관리자 메모');
$table->string('ip_address', 45)->nullable()->index()->comment('마지막 접속 IP 주소');
$table->rememberToken();
$table->timestamps();
$table->timestamp('last_login_at')->nullable()->comment('마지막 로그인 일시');
$table->timestamp('withdrawn_at')->nullable()->comment('탈퇴 일시');
$table->timestamp('blocked_at')->nullable()->comment('차단 일시');
});
if (DB::getDriverName() == 'mysql') {
Schema::table('users', function (Blueprint $table) {
$table->comment('시스템 사용자 정보');
});
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('users');
}
};
@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('password_reset_tokens', function (Blueprint $table) {
$table->string('email')->primary()->comment('비밀번호 재설정 요청 이메일');
$table->string('token')->comment('비밀번호 재설정 토큰');
$table->timestamp('created_at')->nullable()->comment('생성일시');
});
if (DB::getDriverName() == 'mysql') {
Schema::table('password_reset_tokens', function (Blueprint $table) {
$table->comment('비밀번호 재설정 토큰 정보');
});
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('password_reset_tokens');
}
};
@@ -0,0 +1,38 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('sessions', function (Blueprint $table) {
$table->string('id')->primary()->comment('세션 ID');
$table->foreignId('user_id')->nullable()->index()->comment('사용자 ID');
$table->string('ip_address', 45)->nullable()->comment('IP 주소');
$table->text('user_agent')->nullable()->comment('사용자 에이전트');
$table->longText('payload')->comment('세션 데이터');
$table->integer('last_activity')->index()->comment('마지막 활동 시간');
});
if (DB::getDriverName() == 'mysql') {
Schema::table('sessions', function (Blueprint $table) {
$table->comment('사용자 세션 정보');
});
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('sessions');
}
};
@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('cache', function (Blueprint $table) {
$table->string('key')->primary()->comment('캐시 키');
$table->mediumText('value')->comment('캐시 값');
$table->integer('expiration')->comment('만료 시간');
});
if (DB::getDriverName() == 'mysql') {
Schema::table('cache', function (Blueprint $table) {
$table->comment('시스템 캐시 데이터');
});
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('cache');
}
};
@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('cache_locks', function (Blueprint $table) {
$table->string('key')->primary()->comment('락 키');
$table->string('owner')->comment('락 소유자');
$table->integer('expiration')->comment('만료 시간');
});
if (DB::getDriverName() == 'mysql') {
Schema::table('cache_locks', function (Blueprint $table) {
$table->comment('캐시 락 관리');
});
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('cache_locks');
}
};
@@ -0,0 +1,39 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('jobs', function (Blueprint $table) {
$table->id();
$table->string('queue')->index()->comment('큐 이름');
$table->longText('payload')->comment('작업 페이로드');
$table->unsignedTinyInteger('attempts')->comment('시도 횟수');
$table->unsignedInteger('reserved_at')->nullable()->comment('예약 시간');
$table->unsignedInteger('available_at')->comment('실행 가능 시간');
$table->unsignedInteger('created_at')->comment('생성 시간');
});
if (DB::getDriverName() == 'mysql') {
Schema::table('jobs', function (Blueprint $table) {
$table->comment('작업 큐 관리');
});
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('jobs');
}
};
@@ -0,0 +1,42 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('job_batches', function (Blueprint $table) {
$table->string('id')->primary()->comment('배치 ID');
$table->string('name')->comment('배치 이름');
$table->integer('total_jobs')->comment('전체 작업 수');
$table->integer('pending_jobs')->comment('대기 중인 작업 수');
$table->integer('failed_jobs')->comment('실패한 작업 수');
$table->longText('failed_job_ids')->comment('실패한 작업 ID 목록');
$table->mediumText('options')->nullable()->comment('배치 옵션');
$table->integer('cancelled_at')->nullable()->comment('취소 시간');
$table->integer('created_at')->comment('생성 시간');
$table->integer('finished_at')->nullable()->comment('완료 시간');
});
if (DB::getDriverName() == 'mysql') {
Schema::table('job_batches', function (Blueprint $table) {
$table->comment('작업 배치 관리');
});
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('job_batches');
}
};
@@ -0,0 +1,39 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('failed_jobs', function (Blueprint $table) {
$table->id();
$table->string('uuid')->unique()->comment('고유 식별자');
$table->text('connection')->comment('연결 정보');
$table->text('queue')->comment('큐 이름');
$table->longText('payload')->comment('작업 페이로드');
$table->longText('exception')->comment('예외 정보');
$table->timestamp('failed_at')->useCurrent()->comment('실패 시간');
});
if (DB::getDriverName() == 'mysql') {
Schema::table('failed_jobs', function (Blueprint $table) {
$table->comment('실패한 작업 로그');
});
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('failed_jobs');
}
};
@@ -0,0 +1,40 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('personal_access_tokens', function (Blueprint $table) {
$table->id();
$table->morphs('tokenable');
$table->text('name')->comment('토큰 이름');
$table->string('token', 64)->unique()->comment('액세스 토큰');
$table->text('abilities')->nullable()->comment('토큰 권한');
$table->timestamp('last_used_at')->nullable()->comment('마지막 사용 시간');
$table->timestamp('expires_at')->nullable()->index()->comment('만료 시간');
$table->timestamps();
});
if (DB::getDriverName() == 'mysql') {
Schema::table('personal_access_tokens', function (Blueprint $table) {
$table->comment('개인 액세스 토큰 관리');
});
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('personal_access_tokens');
}
};
@@ -0,0 +1,49 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('permissions', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('parent_id')->nullable()->comment('상위 권한 ID (계층 구조)');
$table->string('identifier')->unique()->comment('권한명 (예: users.create, menus.read)');
$table->text('name')->comment('권한 이름 (다국어 JSON)');
$table->mediumText('description')->nullable()->comment('권한 설명 (다국어 JSON)');
$table->string('extension_type', 20)->nullable()->comment('확장 소유 타입: core(코어), module(모듈), plugin(플러그인), NULL(사용자 정의)');
$table->string('extension_identifier', 255)->nullable()->comment('확장 식별자 (예: core, sirsoft-board, sirsoft-payment)');
$table->string('type', 20)->comment('권한 타입');
$table->string('resource_route_key', 50)->nullable()->comment('리소스 라우트 파라미터명 (예: user, menu, product)');
$table->string('owner_key', 50)->nullable()->comment('소유자 식별 컬럼명 (예: id, created_by, user_id)');
$table->integer('order')->default(0)->comment('정렬 순서');
$table->timestamps();
$table->index('parent_id');
$table->index('type');
$table->index(['extension_type', 'extension_identifier'], 'idx_permissions_extension');
$table->foreign('parent_id')->references('id')->on('permissions')->cascadeOnDelete();
});
if (DB::getDriverName() == 'mysql') {
Schema::table('permissions', function (Blueprint $table) {
$table->comment('시스템 권한 정보');
});
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('permissions');
}
};
@@ -0,0 +1,38 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('permission_hooks', function (Blueprint $table) {
$table->id();
$table->foreignId('permission_id')->constrained('permissions')->cascadeOnDelete();
$table->string('hook_name')->index()->comment('훅 이름 (예: core.attachment.download)');
$table->timestamps();
$table->unique(['permission_id', 'hook_name']);
});
if (DB::getDriverName() == 'mysql') {
Schema::table('permission_hooks', function (Blueprint $table) {
$table->comment('권한-훅 매핑 정보');
});
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('permission_hooks');
}
};
@@ -0,0 +1,43 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('roles', function (Blueprint $table) {
$table->id();
$table->string('identifier')->unique()->comment('역할명 (예: admin, user, manager)');
$table->text('name')->comment('역할 이름 (다국어 JSON)');
$table->mediumText('description')->nullable()->comment('역할 설명 (다국어 JSON)');
$table->string('extension_type', 20)->nullable()->comment('확장 소유 타입: core(코어), module(모듈), plugin(플러그인), NULL(사용자 정의)');
$table->string('extension_identifier', 255)->nullable()->comment('확장 식별자 (예: core, sirsoft-board, sirsoft-payment)');
$table->text('user_overrides')->nullable()->comment('유저가 수정한 필드명 목록 (예: ["name", "permissions"])');
$table->boolean('is_active')->default(true)->comment('활성화 상태 (1: 활성, 0: 비활성)');
$table->timestamps();
$table->index(['extension_type', 'extension_identifier'], 'idx_roles_extension');
});
if (DB::getDriverName() == 'mysql') {
Schema::table('roles', function (Blueprint $table) {
$table->comment('사용자 역할 정보');
});
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('roles');
}
};
@@ -0,0 +1,41 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('role_permissions', function (Blueprint $table) {
$table->id();
$table->foreignId('role_id')->constrained('roles')->cascadeOnDelete();
$table->foreignId('permission_id')->constrained('permissions')->cascadeOnDelete();
$table->enum('scope_type', ['self', 'role'])->nullable()->comment('접근 스코프 (null: 전체, self: 본인, role: 소유역할)');
$table->timestamp('granted_at')->useCurrent()->comment('권한 부여 일시');
$table->foreignId('granted_by')->nullable()->constrained('users')->nullOnDelete();
$table->timestamps();
$table->unique(['role_id', 'permission_id']);
});
if (DB::getDriverName() == 'mysql') {
Schema::table('role_permissions', function (Blueprint $table) {
$table->comment('역할-권한 관계 정보');
});
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('role_permissions');
}
};
@@ -0,0 +1,50 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('menus', function (Blueprint $table) {
$table->id();
$table->text('name')->comment('메뉴 이름 (다국어 JSON)');
$table->string('slug')->unique()->comment('메뉴 슬러그');
$table->string('url')->nullable()->comment('메뉴 URL');
$table->string('icon')->nullable()->comment('메뉴 아이콘');
$table->unsignedBigInteger('parent_id')->nullable()->comment('상위 메뉴 ID');
$table->integer('order')->default(0)->comment('메뉴 순서');
$table->boolean('is_active')->default(true)->comment('활성 상태 (1: 활성, 0: 비활성)');
$table->string('extension_type', 20)->nullable()->comment('확장 소유 타입: core(코어), module(모듈), plugin(플러그인), NULL(사용자 정의)');
$table->string('extension_identifier', 255)->nullable()->comment('확장 식별자 (예: core, sirsoft-board, sirsoft-payment)');
$table->text('user_overrides')->nullable()->comment('유저가 수정한 필드명 목록 (예: ["name", "icon", "order"])');
$table->foreignId('created_by')->nullable()->constrained('users')->nullOnDelete()->comment('등록자 ID');
$table->timestamps();
$table->index(['parent_id', 'order']);
$table->index(['is_active', 'order']);
$table->index(['extension_type', 'extension_identifier'], 'idx_menus_extension');
$table->foreign('parent_id')->references('id')->on('menus')->cascadeOnDelete();
});
if (DB::getDriverName() == 'mysql') {
Schema::table('menus', function (Blueprint $table) {
$table->comment('시스템 메뉴 관리');
});
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('menus');
}
};
@@ -0,0 +1,44 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('menu_permissions', function (Blueprint $table) {
$table->id();
$table->foreignId('menu_id')->constrained('menus')->cascadeOnDelete();
$table->foreignId('role_id')->nullable()->constrained('roles')->cascadeOnDelete();
$table->foreignId('user_id')->nullable()->constrained('users')->cascadeOnDelete();
$table->enum('permission_type', ['read', 'write', 'delete'])->default('read')->comment('권한 유형 (read: 읽기, write: 쓰기, delete: 삭제)');
$table->boolean('is_allowed')->default(true)->comment('허용 여부 (1: 허용, 0: 거부)');
$table->timestamp('granted_at')->useCurrent()->comment('권한 부여 일시');
$table->foreignId('granted_by')->nullable()->constrained('users')->nullOnDelete();
$table->timestamps();
$table->index(['menu_id', 'role_id']);
$table->index(['menu_id', 'user_id']);
});
if (DB::getDriverName() == 'mysql') {
Schema::table('menu_permissions', function (Blueprint $table) {
$table->comment('메뉴별 접근 권한 정보');
});
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('menu_permissions');
}
};
@@ -0,0 +1,39 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('role_menus', function (Blueprint $table) {
$table->id();
$table->foreignId('role_id')->constrained('roles')->cascadeOnDelete();
$table->foreignId('menu_id')->constrained('menus')->cascadeOnDelete();
$table->enum('permission_type', ['read', 'write', 'delete'])->default('read')->comment('권한 타입 (read: 읽기/접근, write: 수정, delete: 삭제)');
$table->timestamps();
$table->unique(['role_id', 'menu_id', 'permission_type'], 'uk_role_menu_permission');
});
if (DB::getDriverName() == 'mysql') {
Schema::table('role_menus', function (Blueprint $table) {
$table->comment('역할별 메뉴 접근 권한 (피벗 테이블)');
});
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('role_menus');
}
};
@@ -0,0 +1,40 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('user_roles', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained('users')->cascadeOnDelete();
$table->foreignId('role_id')->constrained('roles')->cascadeOnDelete();
$table->timestamp('assigned_at')->useCurrent()->comment('역할 할당 일시');
$table->foreignId('assigned_by')->nullable()->constrained('users')->nullOnDelete();
$table->timestamps();
$table->unique(['user_id', 'role_id']);
});
if (DB::getDriverName() == 'mysql') {
Schema::table('user_roles', function (Blueprint $table) {
$table->comment('사용자-역할 관계 정보');
});
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('user_roles');
}
};
@@ -0,0 +1,41 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('user_consents', function (Blueprint $table) {
$table->id()->comment('동의 이력 ID');
$table->foreignId('user_id')->constrained('users')->cascadeOnDelete()->comment('사용자 ID');
$table->string('consent_type', 30)->comment('동의 유형: terms, privacy');
$table->timestamp('agreed_at')->comment('동의 일시');
$table->timestamp('revoked_at')->nullable()->comment('철회 일시 (향후 플러그인 확장용)');
$table->string('ip_address', 45)->nullable()->comment('동의 시 IP 주소 (IPv6 대응)');
$table->timestamp('created_at')->nullable()->comment('생성 일시');
$table->index(['user_id', 'consent_type'], 'user_consents_user_type_index');
});
if (DB::getDriverName() == 'mysql') {
Schema::table('user_consents', function (Blueprint $table) {
$table->comment('사용자 약관 동의 이력');
});
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('user_consents');
}
};
@@ -0,0 +1,49 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('modules', function (Blueprint $table) {
$table->id();
$table->string('identifier')->unique()->comment('모듈 고유 식별자 (vendor-module 형식)');
$table->string('vendor')->index()->comment('벤더/개발자명');
$table->text('name')->comment('모듈 이름 (다국어 JSON)');
$table->mediumText('description')->nullable()->comment('모듈 설명 (다국어 JSON)');
$table->string('github_url', 512)->nullable()->comment('GitHub 저장소 URL');
$table->string('github_changelog_url', 512)->nullable()->comment('GitHub 변경 내역 URL');
$table->mediumText('metadata')->nullable()->comment('추가 메타데이터');
$table->unsignedBigInteger('updated_by')->nullable()->comment('수정자 ID');
$table->string('version')->comment('모듈 버전');
$table->string('latest_version', 50)->nullable()->comment('마켓플레이스 최신 버전');
$table->enum('status', ['active', 'inactive', 'installing', 'uninstalling', 'updating'])->default('inactive')->index()->comment('상태 (active: 활성화, inactive: 비활성화, installing: 설치 중, uninstalling: 제거 중, updating: 업데이트 중)');
$table->boolean('update_available')->default(false)->comment('업데이트 가능 여부');
$table->string('update_source', 20)->nullable()->comment('업데이트 출처 (github, pending, bundled)');
$table->mediumText('config')->nullable()->comment('모듈 설정 정보');
$table->foreignId('created_by')->nullable()->constrained('users')->nullOnDelete()->comment('모듈 생성자 ID');
$table->timestamps();
});
if (DB::getDriverName() == 'mysql') {
Schema::table('modules', function (Blueprint $table) {
$table->comment('시스템 모듈 관리');
});
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('modules');
}
};
@@ -0,0 +1,49 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('plugins', function (Blueprint $table) {
$table->id();
$table->string('identifier')->unique()->comment('플러그인 고유 식별자 (vendor-plugin 형식)');
$table->string('vendor')->index()->comment('벤더/개발자명');
$table->text('name')->comment('플러그인 이름 (다국어 JSON)');
$table->mediumText('description')->nullable()->comment('플러그인 설명 (다국어 JSON)');
$table->string('github_url', 512)->nullable()->comment('GitHub 저장소 URL');
$table->mediumText('metadata')->nullable()->comment('추가 메타데이터');
$table->unsignedBigInteger('updated_by')->nullable()->comment('수정자 ID');
$table->string('version')->comment('플러그인 버전');
$table->string('latest_version', 50)->nullable()->comment('마켓플레이스 최신 버전');
$table->boolean('update_available')->default(false)->comment('업데이트 가능 여부');
$table->string('update_source', 20)->nullable()->comment('업데이트 출처 (github, pending, bundled)');
$table->string('github_changelog_url', 512)->nullable()->comment('GitHub 변경 내역 URL');
$table->enum('status', ['active', 'inactive', 'installing', 'uninstalling', 'updating'])->default('inactive')->index()->comment('상태 (active: 활성화, inactive: 비활성화, installing: 설치 중, uninstalling: 제거 중, updating: 업데이트 중)');
$table->mediumText('hooks')->nullable()->comment('훅 설정 정보');
$table->foreignId('created_by')->nullable()->constrained('users')->nullOnDelete()->comment('플러그인 생성자 ID');
$table->timestamps();
});
if (DB::getDriverName() == 'mysql') {
Schema::table('plugins', function (Blueprint $table) {
$table->comment('시스템 플러그인 관리');
});
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('plugins');
}
};
@@ -0,0 +1,53 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('templates', function (Blueprint $table) {
$table->id()->comment('템플릿 ID');
$table->string('identifier')->unique()->comment('템플릿 고유 식별자 (vendor-name 형식, 예: sirsoft-admin_basic)');
$table->string('vendor')->index()->comment('벤더/개발자명 (예: sirsoft)');
$table->text('name')->nullable()->comment('템플릿 이름 (다국어 JSON)');
$table->string('version')->comment('템플릿 버전 (예: 1.0.0)');
$table->string('latest_version', 50)->nullable()->comment('마켓플레이스 최신 버전');
$table->boolean('update_available')->default(false)->comment('업데이트 가능 여부');
$table->string('update_source', 20)->nullable()->comment('업데이트 출처 (github, pending, bundled)');
$table->enum('type', ['admin', 'user'])->comment('템플릿 타입 (admin: 관리자용, user: 사용자용)');
$table->enum('status', ['active', 'inactive', 'installing', 'uninstalling', 'updating'])->default('inactive')->comment('상태 (active: 활성화, inactive: 비활성화, installing: 설치 중, uninstalling: 제거 중, updating: 업데이트 중)');
$table->mediumText('description')->nullable()->comment('템플릿 설명 (다국어 JSON)');
$table->timestamp('user_modified_at')->nullable()->comment('사용자가 레이아웃을 마지막으로 수정한 시각');
$table->string('github_url')->nullable()->comment('GitHub 저장소 URL');
$table->string('github_changelog_url', 512)->nullable()->comment('GitHub 변경 내역 URL');
$table->mediumText('metadata')->nullable()->comment('추가 메타데이터 (JSON 형식)');
$table->unsignedBigInteger('created_by')->nullable()->comment('생성자 ID');
$table->unsignedBigInteger('updated_by')->nullable()->comment('수정자 ID');
$table->timestamps();
$table->index('type');
$table->index('status');
});
if (DB::getDriverName() == 'mysql') {
Schema::table('templates', function (Blueprint $table) {
$table->comment('시스템 템플릿 정보');
});
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('templates');
}
};
@@ -0,0 +1,47 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('template_layouts', function (Blueprint $table) {
$table->id()->comment('레이아웃 ID');
$table->foreignId('template_id')->constrained('templates')->cascadeOnDelete()->comment('템플릿 ID');
$table->string('name')->comment('레이아웃 이름 (예: dashboard, users, user_edit)');
$table->longText('content')->comment('레이아웃 JSON 내용');
$table->string('extends')->nullable()->index()->comment('부모 레이아웃 이름 (예: layouts/_admin_base)');
$table->enum('source_type', ['template', 'module', 'plugin'])->default('template')->comment('레이아웃 소스 타입 (template: 템플릿 자체/오버라이드, module: 모듈 기본, plugin: 플러그인 기본)');
$table->string('source_identifier', 255)->nullable()->comment('모듈/플러그인 식별자 (source_type이 module/plugin일 때 사용)');
$table->unsignedBigInteger('created_by')->nullable()->comment('생성자 ID');
$table->unsignedBigInteger('updated_by')->nullable()->comment('수정자 ID');
$table->timestamps();
$table->softDeletes();
$table->unique(['template_id', 'name', 'source_type'], 'uk_template_layout_source');
$table->index(['source_type', 'source_identifier'], 'idx_source');
$table->index('deleted_at');
});
if (DB::getDriverName() == 'mysql') {
Schema::table('template_layouts', function (Blueprint $table) {
$table->comment('템플릿 레이아웃 정보');
});
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('template_layouts');
}
};
@@ -0,0 +1,42 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('template_layout_versions', function (Blueprint $table) {
$table->id()->comment('버전 ID');
$table->foreignId('layout_id')->constrained('template_layouts')->cascadeOnDelete()->comment('레이아웃 ID');
$table->unsignedInteger('version')->comment('버전 번호 (자동 증가)');
$table->longText('content')->comment('레이아웃 JSON 스냅샷');
$table->text('changes_summary')->nullable()->comment('변경 요약 JSON: {"added": 3, "removed": 2, "is_restored": false, "restored_from": null}');
$table->unsignedBigInteger('created_by')->nullable()->comment('저장자 ID');
$table->timestamp('created_at')->nullable()->comment('생성 일시');
$table->unique(['layout_id', 'version'], 'uk_layout_version');
$table->index(['layout_id', 'created_at'], 'idx_layout_versions');
});
if (DB::getDriverName() == 'mysql') {
Schema::table('template_layout_versions', function (Blueprint $table) {
$table->comment('템플릿 레이아웃 버전 이력');
});
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('template_layout_versions');
}
};
@@ -0,0 +1,48 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('template_layout_extensions', function (Blueprint $table) {
$table->id()->comment('확장 ID');
$table->foreignId('template_id')->constrained('templates')->cascadeOnDelete()->comment('템플릿 ID (g7_templates 참조)');
$table->string('extension_type', 50)->comment('확장 타입: extension_point=확장점 방식, overlay=ID 기반 오버레이 방식');
$table->string('target_name')->comment('타겟 이름 (extension_point: 확장점명, overlay: 레이아웃명)');
$table->string('source_type', 50)->comment('출처 타입: template=템플릿(오버라이드용), module=모듈, plugin=플러그인');
$table->string('source_identifier', 255)->comment('출처 식별자 (예: sirsoft-ecommerce). 템플릿 오버라이드의 경우 오버라이드 대상 모듈/플러그인 식별자');
$table->string('override_target', 255)->nullable()->comment('오버라이드 대상 (source_type=template일 때만 사용). 모듈/플러그인 식별자');
$table->longText('content')->comment('확장 정의 JSON (components, injections, data_sources 포함)');
$table->integer('priority')->default(100)->comment('우선순위 (낮을수록 먼저 적용, 기본값: 100)');
$table->boolean('is_active')->default(true)->comment('활성 상태 (true=활성, false=비활성)');
$table->timestamps();
$table->softDeletes()->comment('삭제 일시 (soft delete)');
$table->index(['template_id', 'extension_type', 'target_name', 'is_active'], 'idx_target');
$table->index(['source_type', 'source_identifier'], 'idx_source');
$table->index(['override_target', 'template_id', 'extension_type', 'target_name'], 'idx_override');
});
if (DB::getDriverName() == 'mysql') {
Schema::table('template_layout_extensions', function (Blueprint $table) {
$table->comment('템플릿 레이아웃 확장 정보');
});
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('template_layout_extensions');
}
};
@@ -0,0 +1,55 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('attachments', function (Blueprint $table) {
$table->id()->comment('첨부파일 ID');
$table->string('attachmentable_type', 255)->nullable()->comment('첨부 대상 모델 타입 (예: App\\Models\\Post)');
$table->unsignedBigInteger('attachmentable_id')->nullable()->comment('첨부 대상 모델 ID');
$table->enum('source_type', ['core', 'module', 'plugin'])->default('core')->comment('소스 타입: core(코어), module(모듈), plugin(플러그인)');
$table->string('source_identifier', 255)->nullable()->comment('모듈/플러그인 식별자 (예: sirsoft-board)');
$table->string('hash', 12)->unique()->comment('URL용 고유 해시 (12자)');
$table->string('original_filename', 255)->comment('원본 파일명');
$table->string('stored_filename', 255)->comment('저장된 파일명 (UUID 기반)');
$table->string('disk', 50)->default('local')->comment('스토리지 디스크 (local, s3 등)');
$table->string('path', 500)->comment('저장 경로 (디스크 기준 상대 경로)');
$table->string('mime_type', 100)->comment('MIME 타입 (예: image/jpeg, application/pdf)');
$table->unsignedBigInteger('size')->comment('파일 크기 (바이트)');
$table->string('collection', 100)->default('default')->comment('첨부파일 컬렉션/그룹명');
$table->unsignedInteger('order')->default(0)->comment('정렬 순서');
$table->text('meta')->nullable()->comment('추가 메타데이터 JSON');
$table->foreignId('created_by')->nullable()->constrained('users')->nullOnDelete();
$table->timestamps();
$table->softDeletes();
$table->index(['attachmentable_type', 'attachmentable_id'], 'idx_attachmentable');
$table->index(['source_type', 'source_identifier'], 'idx_source');
$table->index('collection', 'idx_collection');
$table->index('deleted_at', 'idx_deleted_at');
});
if (DB::getDriverName() == 'mysql') {
Schema::table('attachments', function (Blueprint $table) {
$table->comment('첨부파일 정보');
});
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('attachments');
}
};
@@ -0,0 +1,57 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('schedules', function (Blueprint $table) {
$table->id()->comment('스케줄 ID');
$table->string('name', 255)->comment('작업명');
$table->text('description')->nullable()->comment('설명');
$table->enum('type', ['artisan', 'shell', 'url'])->comment('작업 유형: artisan(Artisan 커맨드), shell(쉘 명령), url(URL 호출)');
$table->text('command')->comment('명령어 또는 URL');
$table->string('expression', 100)->comment('Cron 표현식');
$table->enum('frequency', ['everyMinute', 'hourly', 'daily', 'weekly', 'monthly', 'custom'])->default('custom')->comment('실행 주기: everyMinute(매분), hourly(매시간), daily(매일), weekly(매주), monthly(매월), custom(사용자 정의)');
$table->boolean('without_overlapping')->default(false)->comment('중복 실행 방지 여부: 0(허용), 1(방지)');
$table->boolean('run_in_maintenance')->default(false)->comment('점검 모드 실행 여부: 0(비실행), 1(실행)');
$table->unsignedInteger('timeout')->nullable()->comment('실행 제한 시간 (초)');
$table->boolean('is_active')->default(true)->comment('활성화 여부: 0(비활성), 1(활성)');
$table->enum('last_result', ['success', 'failed', 'running', 'never'])->default('never')->comment('마지막 실행 결과: success(성공), failed(실패), running(실행중), never(미실행)');
$table->timestamp('last_run_at')->nullable()->comment('마지막 실행 시간');
$table->timestamp('next_run_at')->nullable()->comment('다음 실행 예정 시간');
$table->string('extension_type', 20)->nullable()->comment('확장 소유 타입: core(코어), module(모듈), plugin(플러그인), NULL(사용자 정의)');
$table->string('extension_identifier', 255)->nullable()->comment('확장 식별자 (예: core, sirsoft-board, sirsoft-payment)');
$table->foreignId('created_by')->nullable()->constrained('users')->nullOnDelete();
$table->timestamps();
$table->index('type', 'idx_type');
$table->index('frequency', 'idx_frequency');
$table->index('is_active', 'idx_is_active');
$table->index('last_result', 'idx_last_result');
$table->index('next_run_at', 'idx_next_run_at');
$table->index(['extension_type', 'extension_identifier'], 'idx_schedules_extension');
});
if (DB::getDriverName() == 'mysql') {
Schema::table('schedules', function (Blueprint $table) {
$table->comment('스케줄 작업 관리');
});
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('schedules');
}
};
@@ -0,0 +1,49 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('schedule_histories', function (Blueprint $table) {
$table->id()->comment('이력 ID');
$table->foreignId('schedule_id')->constrained('schedules')->cascadeOnDelete();
$table->timestamp('started_at')->comment('실행 시작 시간');
$table->timestamp('ended_at')->nullable()->comment('실행 종료 시간');
$table->unsignedInteger('duration')->nullable()->comment('실행 시간 (초)');
$table->enum('status', ['success', 'failed', 'running'])->default('running')->comment('실행 상태: success(성공), failed(실패), running(실행중)');
$table->tinyInteger('exit_code')->nullable()->comment('종료 코드 (0: 성공)');
$table->unsignedInteger('memory_usage')->nullable()->comment('메모리 사용량 (bytes)');
$table->longText('output')->nullable()->comment('표준 출력');
$table->longText('error_output')->nullable()->comment('에러 출력');
$table->enum('trigger_type', ['scheduled', 'manual'])->default('scheduled')->comment('트리거 유형: scheduled(예약 실행), manual(수동 실행)');
$table->foreignId('triggered_by')->nullable()->constrained('users')->nullOnDelete();
$table->timestamps();
$table->index('started_at', 'idx_started_at');
$table->index('status', 'idx_status');
$table->index('trigger_type', 'idx_trigger_type');
});
if (DB::getDriverName() == 'mysql') {
Schema::table('schedule_histories', function (Blueprint $table) {
$table->comment('스케줄 실행 이력');
});
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('schedule_histories');
}
};
@@ -0,0 +1,35 @@
<?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('activity_logs', function (Blueprint $table) {
$table->id()->comment('활동 로그 ID');
$table->string('log_type', 20)->index()->comment('로그 유형 (admin: 관리자, user: 사용자, system: 시스템)');
$table->nullableMorphs('loggable');
$table->foreignId('user_id')->nullable()->index()->constrained('users')->nullOnDelete()->comment('사용자 ID');
$table->string('action', 50)->index()->comment('액션 유형 (created, updated, deleted, login, export 등)');
$table->text('description')->comment('액션 상세 설명');
$table->mediumText('properties')->nullable()->comment('변경 상세 데이터 (old/new 값)');
$table->string('ip_address', 45)->nullable()->comment('IP 주소 (IPv6 대응)');
$table->string('user_agent', 500)->nullable()->comment('User Agent');
$table->timestamp('created_at')->useCurrent()->index()->comment('생성일시');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('activity_logs');
}
};
@@ -0,0 +1,42 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('mail_templates', function (Blueprint $table) {
$table->id()->comment('ID');
$table->string('type', 100)->unique()->comment('템플릿 유형 (welcome, reset_password 등)');
$table->text('subject')->comment('다국어 제목 ({"ko": "...", "en": "..."})');
$table->mediumText('body')->comment('다국어 HTML 본문 ({"ko": "...", "en": "..."})');
$table->text('variables')->nullable()->comment('사용 가능 변수 메타데이터 ([{key, description}])');
$table->boolean('is_active')->default(true)->comment('활성 여부 (false = 해당 유형 메일 발송 중단)');
$table->boolean('is_default')->default(true)->comment('시더 생성 항목 여부');
$table->text('user_overrides')->nullable()->comment('사용자가 수정한 필드명 목록 (코어 업데이트 시 보존)');
$table->foreignId('updated_by')->nullable()->constrained('users')->nullOnDelete();
$table->timestamps();
});
if (DB::getDriverName() == 'mysql') {
Schema::table('mail_templates', function (Blueprint $table) {
$table->comment('코어 메일 템플릿');
});
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('mail_templates');
}
};
@@ -0,0 +1,45 @@
<?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('mail_send_logs', function (Blueprint $table) {
$table->id()->comment('ID');
$table->string('extension_type', 20)->default('core')->comment('확장 타입 (core, module, plugin)');
$table->string('extension_identifier', 100)->default('core')->comment('확장 식별자');
$table->string('sender_email', 255)->nullable()->comment('발송자 이메일');
$table->string('sender_name', 255)->nullable()->comment('발송자 이름');
$table->string('recipient_email', 255)->comment('수신자 이메일');
$table->string('recipient_name', 255)->nullable()->comment('수신자 이름');
$table->string('subject', 500)->nullable()->comment('이메일 제목');
$table->longText('body')->nullable()->comment('이메일 본문 (HTML)');
$table->string('template_type', 100)->nullable()->comment('템플릿 유형 (welcome, new_comment 등)');
$table->string('source', 100)->nullable()->comment('발송 출처 (notification, test_mail 등)');
$table->string('status', 20)->default('sent')->comment('발송 상태 (sent, failed)');
$table->text('error_message')->nullable()->comment('실패 시 에러 메시지');
$table->timestamp('sent_at')->useCurrent()->comment('발송 시각');
$table->timestamps();
$table->index('recipient_email', 'idx_mail_send_logs_recipient');
$table->index('template_type', 'idx_mail_send_logs_template');
$table->index('sent_at', 'idx_mail_send_logs_sent_at');
$table->index(['extension_type', 'extension_identifier'], 'idx_mail_send_logs_extension');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('mail_send_logs');
}
};
@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* 사용자 테이블에 UUID 컬럼을 추가합니다.
*
* 외부 API 응답에서 정수 ID 노출을 방지하기 위해
* UUID v7 기반 고유 식별자를 추가합니다.
*
* - 신규 설치: User 모델 boot() creating 이벤트에서 UUID 자동 생성
* - 버전 업그레이드: 업그레이드 스크립트에서 기존 레코드 백필 + NOT NULL 변환
*/
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->uuid('uuid')->nullable()->after('id')->unique()->comment('외부 노출용 UUID v7');
});
}
/**
* UUID 컬럼을 제거합니다.
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropUnique(['uuid']);
$table->dropColumn('uuid');
});
}
};
@@ -0,0 +1,56 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
/**
* activity_logs 테이블 i18n 필드 변경.
*
* - description 컬럼 삭제 (번역된 텍스트 저장 → i18n 키 기반으로 전환)
* - description_key, description_params 컬럼 추가 (실시간 다국어 번역)
* - changes 컬럼 추가 (구조화된 변경 이력)
* - 복합 인덱스 추가 (loggable + created_at, log_type + action + created_at)
*/
return new class extends Migration
{
public function up(): void
{
// SQLite 호환: 컬럼 삭제와 추가를 별도 블록으로 분리
Schema::table('activity_logs', function (Blueprint $table) {
$table->dropColumn('description');
});
Schema::table('activity_logs', function (Blueprint $table) {
$table->string('description_key', 150)->nullable()->after('action')
->comment('다국어 번역 키 (예: activity_log.description.user_create)');
$table->text('description_params')->nullable()->after('description_key')
->comment('다국어 번역 파라미터 (예: {"user_id": "abc-123"})');
$table->mediumText('changes')->nullable()->after('properties')
->comment('구조화된 변경 이력 (필드별 label_key, old, new, type)');
$table->index(
['loggable_type', 'loggable_id', 'created_at'],
'idx_activity_logs_loggable'
);
$table->index(
['log_type', 'action', 'created_at'],
'idx_activity_logs_type_action_date'
);
});
}
public function down(): void
{
Schema::table('activity_logs', function (Blueprint $table) {
$table->dropIndex('idx_activity_logs_loggable');
$table->dropIndex('idx_activity_logs_type_action_date');
$table->dropColumn(['description_key', 'description_params', 'changes']);
});
Schema::table('activity_logs', function (Blueprint $table) {
$table->text('description')->nullable()->after('action')
->comment('활동 설명');
});
}
};
@@ -0,0 +1,36 @@
<?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('template_layout_previews', function (Blueprint $table) {
$table->id()->comment('ID');
$table->char('token', 36)->unique()->comment('미리보기 URL 토큰 (UUID)');
$table->foreignId('template_id')->constrained('templates')->cascadeOnDelete()->comment('템플릿 ID');
$table->string('layout_name', 255)->comment('미리보기 대상 레이아웃 이름');
$table->longText('content')->comment('편집 중인 레이아웃 JSON');
$table->unsignedBigInteger('admin_id')->comment('미리보기 생성 관리자 ID');
$table->timestamp('expires_at')->comment('만료 시각');
$table->timestamp('created_at')->useCurrent()->comment('생성 시각');
$table->index('expires_at', 'idx_layout_previews_expires_at');
$table->index(['template_id', 'layout_name', 'admin_id'], 'idx_layout_previews_template_layout_admin');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('template_layout_previews');
}
};
@@ -0,0 +1,39 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
/**
* activity_logs 테이블 인덱스 추가.
*
* - description_key: WhereIn 기반 다국어 검색
*/
return new class extends Migration
{
public function up(): void
{
$existingIndexes = array_column(Schema::getIndexes('activity_logs'), 'name');
if (! in_array('idx_activity_logs_description_key', $existingIndexes)) {
Schema::table('activity_logs', function (Blueprint $table) {
$table->index('description_key', 'idx_activity_logs_description_key');
});
}
}
public function down(): void
{
if (! Schema::hasTable('activity_logs')) {
return;
}
$existingIndexes = array_column(Schema::getIndexes('activity_logs'), 'name');
if (in_array('idx_activity_logs_description_key', $existingIndexes)) {
Schema::table('activity_logs', function (Blueprint $table) {
$table->dropIndex('idx_activity_logs_description_key');
});
}
}
};
@@ -0,0 +1,39 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
/**
* users 테이블 인덱스 추가.
*
* - created_at: 날짜 범위 필터, 통계, 정렬
*/
return new class extends Migration
{
public function up(): void
{
$existingIndexes = array_column(Schema::getIndexes('users'), 'name');
if (! in_array('idx_users_created_at', $existingIndexes)) {
Schema::table('users', function (Blueprint $table) {
$table->index('created_at', 'idx_users_created_at');
});
}
}
public function down(): void
{
if (! Schema::hasTable('users')) {
return;
}
$existingIndexes = array_column(Schema::getIndexes('users'), 'name');
if (in_array('idx_users_created_at', $existingIndexes)) {
Schema::table('users', function (Blueprint $table) {
$table->dropIndex('idx_users_created_at');
});
}
}
};
@@ -0,0 +1,39 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
/**
* mail_send_logs 테이블 인덱스 추가.
*
* - status: sent/failed 상태 필터
*/
return new class extends Migration
{
public function up(): void
{
$existingIndexes = array_column(Schema::getIndexes('mail_send_logs'), 'name');
if (! in_array('idx_mail_send_logs_status', $existingIndexes)) {
Schema::table('mail_send_logs', function (Blueprint $table) {
$table->index('status', 'idx_mail_send_logs_status');
});
}
}
public function down(): void
{
if (! Schema::hasTable('mail_send_logs')) {
return;
}
$existingIndexes = array_column(Schema::getIndexes('mail_send_logs'), 'name');
if (in_array('idx_mail_send_logs_status', $existingIndexes)) {
Schema::table('mail_send_logs', function (Blueprint $table) {
$table->dropIndex('idx_mail_send_logs_status');
});
}
}
};
@@ -0,0 +1,39 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
/**
* template_layouts 테이블 인덱스 추가.
*
* - template_id: 템플릿별 레이아웃 조회
*/
return new class extends Migration
{
public function up(): void
{
$existingIndexes = array_column(Schema::getIndexes('template_layouts'), 'name');
if (! in_array('idx_template_layouts_template_id', $existingIndexes)) {
Schema::table('template_layouts', function (Blueprint $table) {
$table->index('template_id', 'idx_template_layouts_template_id');
});
}
}
public function down(): void
{
if (! Schema::hasTable('template_layouts')) {
return;
}
$existingIndexes = array_column(Schema::getIndexes('template_layouts'), 'name');
if (in_array('idx_template_layouts_template_id', $existingIndexes)) {
Schema::table('template_layouts', function (Blueprint $table) {
$table->dropIndex('idx_template_layouts_template_id');
});
}
}
};
@@ -0,0 +1,39 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
/**
* schedules 테이블 인덱스 추가.
*
* - created_at: 날짜 범위 필터, 정렬
*/
return new class extends Migration
{
public function up(): void
{
$existingIndexes = array_column(Schema::getIndexes('schedules'), 'name');
if (! in_array('idx_schedules_created_at', $existingIndexes)) {
Schema::table('schedules', function (Blueprint $table) {
$table->index('created_at', 'idx_schedules_created_at');
});
}
}
public function down(): void
{
if (! Schema::hasTable('schedules')) {
return;
}
$existingIndexes = array_column(Schema::getIndexes('schedules'), 'name');
if (in_array('idx_schedules_created_at', $existingIndexes)) {
Schema::table('schedules', function (Blueprint $table) {
$table->dropIndex('idx_schedules_created_at');
});
}
}
};
@@ -0,0 +1,56 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('template_layouts', function (Blueprint $table) {
$table->string('original_content_hash', 64)
->nullable()
->after('content')
->comment('원본 레이아웃 콘텐츠 SHA-256 해시 (수정 감지용)');
$table->unsignedInteger('original_content_size')
->nullable()
->after('original_content_hash')
->comment('원본 레이아웃 콘텐츠 바이트 크기 (변화량 표시용)');
});
// 기존 데이터 hash 백필 (현재 content = 원본으로 간주)
DB::table('template_layouts')
->whereNull('original_content_hash')
->orderBy('id')
->chunk(100, function ($layouts) {
foreach ($layouts as $layout) {
$content = json_decode($layout->content, true);
$normalized = json_encode($content, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
$hash = hash('sha256', $normalized);
$size = strlen($normalized);
DB::table('template_layouts')
->where('id', $layout->id)
->update([
'original_content_hash' => $hash,
'original_content_size' => $size,
]);
}
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('template_layouts', function (Blueprint $table) {
$table->dropColumn(['original_content_hash', 'original_content_size']);
});
}
};