fix : 테이블 추가 및 수정 신규로 작성 (generator 설치)
composer require --dev kitloong/laravel-migrations-generator php artisan migrate:generate
This commit is contained in:
@@ -1,51 +0,0 @@
|
||||
<?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('users', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('email')->unique();
|
||||
$table->timestamp('email_verified_at')->nullable();
|
||||
$table->string('password');
|
||||
$table->rememberToken();
|
||||
$table->foreignId('current_team_id')->nullable();
|
||||
$table->string('profile_photo_path', 2048)->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('password_reset_tokens', function (Blueprint $table) {
|
||||
$table->string('email')->primary();
|
||||
$table->string('token');
|
||||
$table->timestamp('created_at')->nullable();
|
||||
});
|
||||
|
||||
Schema::create('sessions', function (Blueprint $table) {
|
||||
$table->string('id')->primary();
|
||||
$table->foreignId('user_id')->nullable()->index();
|
||||
$table->string('ip_address', 45)->nullable();
|
||||
$table->text('user_agent')->nullable();
|
||||
$table->longText('payload');
|
||||
$table->integer('last_activity')->index();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('users');
|
||||
Schema::dropIfExists('password_reset_tokens');
|
||||
Schema::dropIfExists('sessions');
|
||||
}
|
||||
};
|
||||
@@ -1,42 +0,0 @@
|
||||
<?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::table('users', function (Blueprint $table) {
|
||||
$table->text('two_factor_secret')
|
||||
->after('password')
|
||||
->nullable();
|
||||
|
||||
$table->text('two_factor_recovery_codes')
|
||||
->after('two_factor_secret')
|
||||
->nullable();
|
||||
|
||||
$table->timestamp('two_factor_confirmed_at')
|
||||
->after('two_factor_recovery_codes')
|
||||
->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropColumn([
|
||||
'two_factor_secret',
|
||||
'two_factor_recovery_codes',
|
||||
'two_factor_confirmed_at',
|
||||
]);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -1,28 +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()
|
||||
{
|
||||
Schema::create('files', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('tenant_id')->comment('멀티테넌시');
|
||||
$table->string('file_path', 255)->comment('저장경로');
|
||||
$table->string('file_name', 255);
|
||||
$table->integer('file_size')->nullable();
|
||||
$table->string('mime_type', 50)->nullable();
|
||||
$table->string('description', 255)->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('files');
|
||||
}
|
||||
};
|
||||
@@ -1,31 +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 {
|
||||
Schema::create('board_comments', function (Blueprint $table) {
|
||||
$table->id()->comment('댓글 고유번호');
|
||||
$table->unsignedBigInteger('post_id')->comment('게시글 고유번호');
|
||||
$table->unsignedBigInteger('tenant_id')->comment('테넌트 고유번호');
|
||||
$table->unsignedBigInteger('user_id')->nullable()->comment('작성자 고유번호');
|
||||
$table->unsignedBigInteger('parent_id')->nullable()->comment('상위 댓글ID(대댓글)');
|
||||
$table->text('content')->comment('댓글 내용');
|
||||
$table->string('ip_address', 45)->nullable()->comment('작성자 IP');
|
||||
$table->string('status', 20)->default('active')->comment('상태');
|
||||
$table->timestamps();
|
||||
$table->softDeletes()->comment('삭제일시(Soft Delete)');
|
||||
|
||||
$table->foreign('post_id')->references('id')->on('posts')->onDelete('cascade');
|
||||
$table->foreign('tenant_id')->references('id')->on('tenants');
|
||||
$table->foreign('user_id')->references('id')->on('users');
|
||||
$table->foreign('parent_id')->references('id')->on('board_comments');
|
||||
});
|
||||
}
|
||||
public function down(): void {
|
||||
Schema::dropIfExists('board_comments');
|
||||
}
|
||||
};
|
||||
@@ -1,32 +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
|
||||
{
|
||||
Schema::table('common_codes', function (Blueprint $table) {
|
||||
// 1. attributes 컬럼 추가
|
||||
if (!Schema::hasColumn('common_codes', 'attributes')) {
|
||||
$table->json('attributes')->nullable()->comment('동적 속성')->after('parent_id');
|
||||
}
|
||||
// 2. is_active 타입 및 코멘트 변경
|
||||
$table->tinyInteger('is_active')->default(1)->comment('사용여부')->change();
|
||||
});
|
||||
|
||||
// 3. 테이블 코멘트
|
||||
DB::statement("ALTER TABLE `common_codes` COMMENT = '공통코드 트리';");
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('common_codes', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('common_codes', 'attributes')) {
|
||||
$table->dropColumn('attributes');
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -1,37 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class UpdateFilesTableForCommonUsage extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('files', function (Blueprint $table) {
|
||||
// 기존 컬럼명 변경
|
||||
$table->renameColumn('file_name', 'file_name_old'); // 잠시 백업
|
||||
|
||||
// 새로운 컬럼 추가
|
||||
$table->string('original_name', 255)->after('file_path')->comment('원본 파일명');
|
||||
$table->string('file_name', 255)->after('original_name')->comment('저장 파일명 (난수)');
|
||||
$table->string('target_table', 50)->after('description')->comment('연결된 테이블명');
|
||||
$table->unsignedBigInteger('target_id')->after('target_table')->comment('연결된 테이블의 PK ID');
|
||||
$table->unsignedBigInteger('uploaded_by')->nullable()->after('target_id')->comment('업로더 사용자 ID');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('files', function (Blueprint $table) {
|
||||
// 복구 시 이전 file_name 복원
|
||||
$table->string('file_name', 255)->after('file_path');
|
||||
$table->dropColumn([
|
||||
'original_name',
|
||||
'target_table',
|
||||
'target_id',
|
||||
'uploaded_by'
|
||||
]);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -1,32 +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
|
||||
{
|
||||
Schema::table('files', function (Blueprint $table) {
|
||||
// 기존 컬럼 제거 (target_table, target_id)
|
||||
$table->dropColumn(['target_table', 'target_id']);
|
||||
|
||||
// Polymorphic 컬럼 추가
|
||||
$table->unsignedBigInteger('fileable_id')->after('description')->comment('Polymorphic - 연결된 모델의 PK');
|
||||
$table->string('fileable_type', 100)->after('fileable_id')->comment('Polymorphic - 연결된 모델 클래스명');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('files', function (Blueprint $table) {
|
||||
// Polymorphic 컬럼 제거
|
||||
$table->dropColumn(['fileable_id', 'fileable_type']);
|
||||
|
||||
// 다시 기존 방식으로 복원
|
||||
$table->string('target_table', 50)->after('description')->comment('연결된 테이블명');
|
||||
$table->unsignedBigInteger('target_id')->after('target_table')->comment('연결된 테이블의 PK ID');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -1,23 +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
|
||||
{
|
||||
Schema::table('log_session', function (Blueprint $table) {
|
||||
// id 컬럼 길이를 128로 변경
|
||||
$table->string('id', 128)->change();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('log_session', function (Blueprint $table) {
|
||||
// id 컬럼 길이를 원래대로 40으로 복구
|
||||
$table->string('id', 40)->change();
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -1,36 +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
|
||||
{
|
||||
// 1. 컬럼 nullable 해제, 주석 보강, soft delete 추가
|
||||
Schema::table('roles', function (Blueprint $table) {
|
||||
// tenant_id NOT NULL로 변경
|
||||
$table->unsignedBigInteger('tenant_id')->nullable(false)->change();
|
||||
$table->string('name', 50)->comment('역할명')->change();
|
||||
$table->string('description', 255)->nullable()->comment('설명')->change();
|
||||
|
||||
// deleted_at 추가 (soft delete)
|
||||
$table->softDeletes()->comment('삭제일시(소프트삭제)');
|
||||
});
|
||||
|
||||
// 2. (권장) 유니크 인덱스 보장: 한 테넌트 내에서 동일한 역할명 중복 불가
|
||||
Schema::table('roles', function (Blueprint $table) {
|
||||
$table->unique(['tenant_id', 'name'], 'uk_roles_tenant_name');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('roles', function (Blueprint $table) {
|
||||
// 롤백시 soft delete 및 인덱스 제거
|
||||
$table->dropSoftDeletes();
|
||||
$table->dropUnique('uk_roles_tenant_name');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -1,51 +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
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
// 1. tenant_id NOT NULL 추가
|
||||
$table->unsignedBigInteger('tenant_id')->after('id')->comment('FK: 테넌트 ID')->default(1); // default 값은 마이그레이션 중 기존 데이터 보호용
|
||||
|
||||
// 2. 컬럼별 주석 보강
|
||||
$table->string('name', 255)->comment('회원 이름')->change();
|
||||
$table->string('email', 255)->comment('이메일')->change();
|
||||
$table->string('password', 255)->comment('비밀번호')->change();
|
||||
$table->string('profile_photo_path', 2048)->nullable()->comment('프로필 사진 경로')->change();
|
||||
$table->string('remember_token', 100)->nullable()->comment('자동로그인 토큰')->change();
|
||||
|
||||
// 3. soft delete 추가
|
||||
$table->softDeletes()->comment('삭제일시(소프트삭제)');
|
||||
|
||||
// 4. 유니크키 변경: (tenant_id, email)로
|
||||
$table->dropUnique(['email']);
|
||||
$table->unique(['tenant_id', 'email'], 'uk_users_tenant_email');
|
||||
});
|
||||
|
||||
// FK 추가 (이미 tenants 테이블이 있어야 함)
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->foreign('tenant_id')->references('id')->on('tenants');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
// 롤백: FK/유니크/컬럼 제거
|
||||
$table->dropForeign(['tenant_id']);
|
||||
$table->dropUnique('uk_users_tenant_email');
|
||||
$table->dropColumn('tenant_id');
|
||||
$table->dropSoftDeletes();
|
||||
});
|
||||
|
||||
// 기존 유니크 복구
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->unique('email');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -1,26 +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
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
// 외래키 먼저 삭제
|
||||
$table->dropForeign('users_tenant_id_foreign');
|
||||
// 컬럼 삭제
|
||||
$table->dropColumn('tenant_id');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->unsignedBigInteger('tenant_id')->nullable()->comment('테넌트ID');
|
||||
$table->foreign('tenant_id')->references('id')->on('tenants')->onDelete('set null');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -12,10 +12,10 @@
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('api_keys', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('key')->unique(); // API Key
|
||||
$table->string('description')->nullable(); // 용도 설명 등
|
||||
$table->boolean('is_active')->default(true); // 키 활성 여부
|
||||
$table->bigIncrements('id');
|
||||
$table->string('key')->unique();
|
||||
$table->string('description')->nullable();
|
||||
$table->boolean('is_active')->default(true);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
@@ -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('board_comments', function (Blueprint $table) {
|
||||
$table->bigIncrements('id')->comment('댓글 고유번호');
|
||||
$table->unsignedBigInteger('post_id')->index('board_comments_post_id_foreign')->comment('게시글 고유번호');
|
||||
$table->unsignedBigInteger('tenant_id')->index('board_comments_tenant_id_foreign')->comment('테넌트 고유번호');
|
||||
$table->unsignedBigInteger('user_id')->nullable()->index('board_comments_user_id_foreign')->comment('작성자 고유번호');
|
||||
$table->unsignedBigInteger('parent_id')->nullable()->index('board_comments_parent_id_foreign')->comment('상위 댓글ID(대댓글)');
|
||||
$table->text('content')->comment('댓글 내용');
|
||||
$table->string('ip_address', 45)->nullable()->comment('작성자 IP');
|
||||
$table->string('status', 20)->default('active')->comment('상태');
|
||||
$table->timestamps();
|
||||
$table->softDeletes()->comment('삭제일시(Soft Delete)');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('board_comments');
|
||||
}
|
||||
};
|
||||
@@ -6,20 +6,27 @@
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('board_files', function (Blueprint $table) {
|
||||
$table->id()->comment('첨부파일 고유번호');
|
||||
$table->unsignedBigInteger('post_id')->comment('게시글 고유번호');
|
||||
$table->string('file_path', 255)->comment('저장경로');
|
||||
$table->string('file_name', 255)->comment('원본 파일명');
|
||||
$table->bigIncrements('id')->comment('첨부파일 고유번호');
|
||||
$table->unsignedBigInteger('post_id')->index('board_files_post_id_foreign')->comment('게시글 고유번호');
|
||||
$table->string('file_path')->comment('저장경로');
|
||||
$table->string('file_name')->comment('원본 파일명');
|
||||
$table->integer('file_size')->comment('파일 크기(Byte)');
|
||||
$table->string('file_type', 100)->nullable()->comment('파일 MIME 타입');
|
||||
$table->timestamps();
|
||||
|
||||
$table->foreign('post_id')->references('id')->on('posts')->onDelete('cascade');
|
||||
});
|
||||
}
|
||||
public function down(): void {
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('board_files');
|
||||
}
|
||||
};
|
||||
@@ -6,9 +6,13 @@
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('board_settings', function (Blueprint $table) {
|
||||
$table->id()->comment('커스텀필드 고유번호');
|
||||
$table->bigIncrements('id')->comment('커스텀필드 고유번호');
|
||||
$table->unsignedBigInteger('board_id')->comment('게시판 고유번호');
|
||||
$table->string('name', 100)->comment('필드명');
|
||||
$table->string('field_key', 50)->comment('필드키');
|
||||
@@ -19,10 +23,14 @@ public function up(): void {
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['board_id', 'field_key']);
|
||||
$table->foreign('board_id')->references('id')->on('boards');
|
||||
});
|
||||
}
|
||||
public function down(): void {
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('board_settings');
|
||||
}
|
||||
};
|
||||
@@ -6,13 +6,17 @@
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('boards', function (Blueprint $table) {
|
||||
$table->id()->comment('게시판 고유번호');
|
||||
$table->bigIncrements('id')->comment('게시판 고유번호');
|
||||
$table->unsignedBigInteger('tenant_id')->comment('테넌트 고유번호');
|
||||
$table->string('board_code', 30)->comment('게시판 코드');
|
||||
$table->string('name', 100)->comment('게시판 이름');
|
||||
$table->string('description', 255)->nullable()->comment('게시판 설명');
|
||||
$table->string('description')->nullable()->comment('게시판 설명');
|
||||
$table->string('editor_type', 20)->default('wysiwyg')->comment('에디터 유형');
|
||||
$table->boolean('allow_files')->default(true)->comment('파일첨부 허용 여부');
|
||||
$table->integer('max_file_count')->default(5)->comment('최대 첨부파일 수');
|
||||
@@ -22,10 +26,14 @@ public function up(): void {
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['tenant_id', 'board_code']);
|
||||
$table->foreign('tenant_id')->references('id')->on('tenants');
|
||||
});
|
||||
}
|
||||
public function down(): void {
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('boards');
|
||||
}
|
||||
};
|
||||
@@ -6,13 +6,16 @@
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up()
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('bom_items', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->bigIncrements('id');
|
||||
$table->unsignedBigInteger('tenant_id')->comment('멀티테넌시');
|
||||
$table->unsignedBigInteger('bom_id')->comment('BOM ID');
|
||||
$table->unsignedBigInteger('parent_id')->nullable()->comment('상위 BOM Item');
|
||||
$table->unsignedBigInteger('bom_id')->index('bom_items_bom_id_foreign')->comment('BOM ID');
|
||||
$table->unsignedBigInteger('parent_id')->nullable()->index('bom_items_parent_id_foreign')->comment('상위 BOM Item');
|
||||
$table->string('item_type', 20)->comment('item 종류: part, product, bom');
|
||||
$table->unsignedBigInteger('ref_id')->comment('참조 ID');
|
||||
$table->decimal('quantity', 18, 4)->default(1);
|
||||
@@ -20,13 +23,13 @@ public function up()
|
||||
$table->integer('sort_order')->default(0);
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->foreign('bom_id')->references('id')->on('boms');
|
||||
$table->foreign('parent_id')->references('id')->on('bom_items');
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('bom_items');
|
||||
}
|
||||
@@ -6,31 +6,34 @@
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up()
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('boms', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->bigIncrements('id');
|
||||
$table->unsignedBigInteger('tenant_id')->comment('멀티테넌시');
|
||||
$table->unsignedBigInteger('product_id')->comment('제품ID');
|
||||
$table->unsignedBigInteger('product_id')->index('boms_product_id_foreign')->comment('제품ID');
|
||||
$table->string('code', 30)->comment('BOM코드');
|
||||
$table->string('name', 100)->comment('BOM명');
|
||||
$table->unsignedBigInteger('category_id')->comment('카테고리ID(common_codes)');
|
||||
$table->unsignedBigInteger('category_id')->index('boms_category_id_foreign')->comment('카테고리ID(common_codes)');
|
||||
$table->json('attributes')->nullable()->comment('동적 속성');
|
||||
$table->string('description', 255)->nullable()->comment('설명');
|
||||
$table->boolean('is_default')->default(0)->comment('기본BOM여부');
|
||||
$table->boolean('is_active')->default(1)->comment('사용여부');
|
||||
$table->unsignedBigInteger('image_file_id')->nullable()->comment('첨부파일ID');
|
||||
$table->string('description')->nullable()->comment('설명');
|
||||
$table->boolean('is_default')->default(false)->comment('기본BOM여부');
|
||||
$table->boolean('is_active')->default(true)->comment('사용여부');
|
||||
$table->unsignedBigInteger('image_file_id')->nullable()->index('boms_image_file_id_foreign')->comment('첨부파일ID');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->unique(['tenant_id', 'product_id', 'code']);
|
||||
$table->foreign('product_id')->references('id')->on('products');
|
||||
$table->foreign('category_id')->references('id')->on('common_codes');
|
||||
$table->foreign('image_file_id')->references('id')->on('files');
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('boms');
|
||||
}
|
||||
@@ -11,12 +11,6 @@
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('cache', function (Blueprint $table) {
|
||||
$table->string('key')->primary();
|
||||
$table->mediumText('value');
|
||||
$table->integer('expiration');
|
||||
});
|
||||
|
||||
Schema::create('cache_locks', function (Blueprint $table) {
|
||||
$table->string('key')->primary();
|
||||
$table->string('owner');
|
||||
@@ -29,7 +23,6 @@ public function up(): void
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('cache');
|
||||
Schema::dropIfExists('cache_locks');
|
||||
}
|
||||
};
|
||||
28
database/migrations/2025_07_26_051643_create_cache_table.php
Normal file
28
database/migrations/2025_07_26_051643_create_cache_table.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?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('cache', function (Blueprint $table) {
|
||||
$table->string('key')->primary();
|
||||
$table->mediumText('value');
|
||||
$table->integer('expiration');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('cache');
|
||||
}
|
||||
};
|
||||
@@ -6,27 +6,34 @@
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up()
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('common_codes', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->comment('공통코드 트리');
|
||||
$table->bigIncrements('id');
|
||||
$table->unsignedBigInteger('tenant_id')->nullable()->comment('멀티테넌시');
|
||||
$table->string('code_group', 30)->default('category')->comment('코드 그룹');
|
||||
$table->string('code', 20)->comment('코드값');
|
||||
$table->string('name', 100)->comment('이름');
|
||||
$table->unsignedBigInteger('parent_id')->nullable()->comment('상위코드ID(트리)');
|
||||
$table->string('description', 255)->nullable()->comment('설명');
|
||||
$table->unsignedBigInteger('parent_id')->nullable()->index('common_codes_parent_id_foreign')->comment('상위코드ID(트리)');
|
||||
$table->json('attributes')->nullable()->comment('동적 속성');
|
||||
$table->string('description')->nullable()->comment('설명');
|
||||
$table->tinyInteger('is_active')->default(1)->comment('사용여부');
|
||||
$table->integer('sort_order')->default(0)->comment('정렬순서');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->unique(['tenant_id','code_group','code']);
|
||||
$table->foreign('parent_id')->references('id')->on('common_codes');
|
||||
$table->unique(['tenant_id', 'code_group', 'code']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('common_codes');
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?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('failed_jobs', function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->string('uuid')->unique();
|
||||
$table->text('connection');
|
||||
$table->text('queue');
|
||||
$table->longText('payload');
|
||||
$table->longText('exception');
|
||||
$table->timestamp('failed_at')->useCurrent();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('failed_jobs');
|
||||
}
|
||||
};
|
||||
39
database/migrations/2025_07_26_051643_create_files_table.php
Normal file
39
database/migrations/2025_07_26_051643_create_files_table.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?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('files', function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->unsignedBigInteger('tenant_id')->comment('멀티테넌시');
|
||||
$table->string('file_path')->comment('저장경로');
|
||||
$table->string('original_name')->comment('원본 파일명');
|
||||
$table->string('file_name')->comment('저장 파일명 (난수)');
|
||||
$table->string('file_name_old');
|
||||
$table->integer('file_size')->nullable();
|
||||
$table->string('mime_type', 50)->nullable();
|
||||
$table->string('description')->nullable();
|
||||
$table->unsignedBigInteger('fileable_id')->comment('Polymorphic - 연결된 모델의 PK');
|
||||
$table->string('fileable_type', 100)->comment('Polymorphic - 연결된 모델 클래스명');
|
||||
$table->unsignedBigInteger('uploaded_by')->nullable()->comment('업로더 사용자 ID');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('files');
|
||||
}
|
||||
};
|
||||
@@ -11,16 +11,6 @@
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('jobs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('queue')->index();
|
||||
$table->longText('payload');
|
||||
$table->unsignedTinyInteger('attempts');
|
||||
$table->unsignedInteger('reserved_at')->nullable();
|
||||
$table->unsignedInteger('available_at');
|
||||
$table->unsignedInteger('created_at');
|
||||
});
|
||||
|
||||
Schema::create('job_batches', function (Blueprint $table) {
|
||||
$table->string('id')->primary();
|
||||
$table->string('name');
|
||||
@@ -33,16 +23,6 @@ public function up(): void
|
||||
$table->integer('created_at');
|
||||
$table->integer('finished_at')->nullable();
|
||||
});
|
||||
|
||||
Schema::create('failed_jobs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('uuid')->unique();
|
||||
$table->text('connection');
|
||||
$table->text('queue');
|
||||
$table->longText('payload');
|
||||
$table->longText('exception');
|
||||
$table->timestamp('failed_at')->useCurrent();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -50,8 +30,6 @@ public function up(): void
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('jobs');
|
||||
Schema::dropIfExists('job_batches');
|
||||
Schema::dropIfExists('failed_jobs');
|
||||
}
|
||||
};
|
||||
32
database/migrations/2025_07_26_051643_create_jobs_table.php
Normal file
32
database/migrations/2025_07_26_051643_create_jobs_table.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?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('jobs', function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->string('queue')->index();
|
||||
$table->longText('payload');
|
||||
$table->unsignedTinyInteger('attempts');
|
||||
$table->unsignedInteger('reserved_at')->nullable();
|
||||
$table->unsignedInteger('available_at');
|
||||
$table->unsignedInteger('created_at');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('jobs');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
<?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('log_session', function (Blueprint $table) {
|
||||
$table->comment('세션정보 저장 테이블');
|
||||
$table->string('id', 128)->primary();
|
||||
$table->string('ip_address', 45)->default('0')->comment('IP 주소');
|
||||
$table->string('user_agent', 120)->comment('User Agent');
|
||||
$table->integer('last_activity')->default(0)->index('last_activity_idx')->comment('마지막 활동 시간');
|
||||
$table->string('timestamp', 50)->comment('타임스탬프');
|
||||
$table->text('data')->comment('세션 데이터');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('log_session');
|
||||
}
|
||||
};
|
||||
@@ -6,24 +6,31 @@
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up()
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('menus', function (Blueprint $table) {
|
||||
$table->bigIncrements('id')->comment('PK: 메뉴 ID');
|
||||
$table->unsignedBigInteger('tenant_id')->nullable()->index()->comment('FK: 테넌트 ID(null=공용메뉴)');
|
||||
$table->unsignedBigInteger('parent_id')->nullable()->index()->comment('상위 메뉴 ID');
|
||||
$table->string('name', 100)->comment('메뉴명');
|
||||
$table->string('url', 255)->nullable()->comment('메뉴 URL');
|
||||
$table->string('url')->nullable()->comment('메뉴 URL');
|
||||
$table->boolean('is_active')->default(true)->comment('활성여부(1=활성,0=비활성)');
|
||||
$table->integer('sort_order')->default(0)->comment('정렬순서');
|
||||
$table->boolean('hidden')->default(false)->comment('숨김여부');
|
||||
$table->boolean('is_external')->default(false)->comment('외부링크여부');
|
||||
$table->string('external_url', 255)->nullable()->comment('외부링크 URL');
|
||||
$table->string('external_url')->nullable()->comment('외부링크 URL');
|
||||
$table->string('icon', 50)->nullable()->comment('아이콘명');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
public function down()
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('menus');
|
||||
}
|
||||
@@ -6,29 +6,33 @@
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up()
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('parts', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->bigIncrements('id');
|
||||
$table->unsignedBigInteger('tenant_id')->comment('멀티테넌시');
|
||||
$table->string('code', 30)->comment('부품코드');
|
||||
$table->string('name', 100)->comment('부품명');
|
||||
$table->unsignedBigInteger('category_id')->comment('카테고리ID(common_codes)');
|
||||
$table->unsignedBigInteger('part_type_id')->nullable()->comment('부품타입ID(common_codes)');
|
||||
$table->unsignedBigInteger('category_id')->index('parts_category_id_foreign')->comment('카테고리ID(common_codes)');
|
||||
$table->unsignedBigInteger('part_type_id')->nullable()->index('parts_part_type_id_foreign')->comment('부품타입ID(common_codes)');
|
||||
$table->string('unit', 20)->nullable()->comment('단위');
|
||||
$table->json('attributes')->nullable()->comment('동적 속성');
|
||||
$table->string('description', 255)->nullable()->comment('설명');
|
||||
$table->string('description')->nullable()->comment('설명');
|
||||
$table->tinyInteger('is_active')->default(1)->comment('사용여부');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->unique(['tenant_id','code']);
|
||||
$table->foreign('category_id')->references('id')->on('common_codes');
|
||||
$table->foreign('part_type_id')->references('id')->on('common_codes');
|
||||
$table->unique(['tenant_id', 'code']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('parts');
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?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('password_reset_tokens', function (Blueprint $table) {
|
||||
$table->string('email')->primary();
|
||||
$table->string('token');
|
||||
$table->timestamp('created_at')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('password_reset_tokens');
|
||||
}
|
||||
};
|
||||
@@ -6,11 +6,15 @@
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('payments', function (Blueprint $table) {
|
||||
$table->id()->comment('PK');
|
||||
$table->foreignId('subscription_id')->constrained('subscriptions')->comment('구독ID');
|
||||
$table->decimal('amount', 12, 2)->comment('결제금액');
|
||||
$table->bigIncrements('id')->comment('PK');
|
||||
$table->unsignedBigInteger('subscription_id')->index('payments_subscription_id_foreign');
|
||||
$table->decimal('amount', 12)->comment('결제금액');
|
||||
$table->string('payment_method', 30)->comment('결제수단');
|
||||
$table->string('transaction_id', 100)->nullable()->comment('PG 거래ID');
|
||||
$table->dateTime('paid_at')->comment('결제일시');
|
||||
@@ -21,7 +25,11 @@ public function up(): void {
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void {
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('payments');
|
||||
}
|
||||
};
|
||||
@@ -12,14 +12,17 @@
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('personal_access_tokens', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->morphs('tokenable');
|
||||
$table->bigIncrements('id');
|
||||
$table->string('tokenable_type');
|
||||
$table->unsignedBigInteger('tokenable_id');
|
||||
$table->string('name');
|
||||
$table->string('token', 64)->unique();
|
||||
$table->text('abilities')->nullable();
|
||||
$table->timestamp('last_used_at')->nullable();
|
||||
$table->timestamp('expires_at')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['tokenable_type', 'tokenable_id']);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -6,13 +6,17 @@
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('plans', function (Blueprint $table) {
|
||||
$table->id()->comment('PK');
|
||||
$table->bigIncrements('id')->comment('PK');
|
||||
$table->string('name')->comment('플랜명');
|
||||
$table->string('code', 30)->unique()->comment('플랜 코드');
|
||||
$table->text('description')->nullable()->comment('설명');
|
||||
$table->decimal('price', 12, 2)->comment('월 요금');
|
||||
$table->decimal('price', 12)->comment('월 요금');
|
||||
$table->string('billing_cycle', 20)->default('monthly')->comment('청구 주기');
|
||||
$table->json('features')->nullable()->comment('제공 기능/제한사항');
|
||||
$table->boolean('is_active')->default(true)->comment('사용여부');
|
||||
@@ -21,7 +25,11 @@ public function up(): void {
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void {
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('plans');
|
||||
}
|
||||
};
|
||||
@@ -6,20 +6,27 @@
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('post_custom_field_values', function (Blueprint $table) {
|
||||
$table->id()->comment('필드값 고유번호');
|
||||
$table->bigIncrements('id')->comment('필드값 고유번호');
|
||||
$table->unsignedBigInteger('post_id')->comment('게시글 고유번호');
|
||||
$table->unsignedBigInteger('field_id')->comment('커스텀필드 고유번호');
|
||||
$table->unsignedBigInteger('field_id')->index('post_custom_field_values_field_id_foreign')->comment('커스텀필드 고유번호');
|
||||
$table->text('value')->nullable()->comment('필드값');
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['post_id', 'field_id']);
|
||||
$table->foreign('post_id')->references('id')->on('posts')->onDelete('cascade');
|
||||
$table->foreign('field_id')->references('id')->on('board_settings');
|
||||
});
|
||||
}
|
||||
public function down(): void {
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('post_custom_field_values');
|
||||
}
|
||||
};
|
||||
@@ -6,30 +6,36 @@
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('posts', function (Blueprint $table) {
|
||||
$table->id()->comment('게시글 고유번호');
|
||||
$table->bigIncrements('id')->comment('게시글 고유번호');
|
||||
$table->unsignedBigInteger('tenant_id')->comment('테넌트 고유번호');
|
||||
$table->unsignedBigInteger('board_id')->comment('게시판 고유번호');
|
||||
$table->unsignedBigInteger('board_id')->index('posts_board_id_foreign')->comment('게시판 고유번호');
|
||||
$table->unsignedBigInteger('user_id')->nullable()->comment('작성자 고유번호');
|
||||
$table->string('title', 255)->comment('제목');
|
||||
$table->string('title')->comment('제목');
|
||||
$table->longText('content')->comment('내용');
|
||||
$table->string('editor_type', 20)->default('wysiwyg')->comment('에디터 유형');
|
||||
$table->string('ip_address', 45)->nullable()->comment('작성자 IP');
|
||||
$table->boolean('is_notice')->default(false)->comment('공지글 여부');
|
||||
$table->boolean('is_secret')->default(false)->comment('비밀글 여부');
|
||||
$table->integer('views')->default(0)->comment('조회수');
|
||||
$table->string('status', 20)->default('active')->comment('상태');
|
||||
$table->string('status', 20)->default('active')->index()->comment('상태');
|
||||
$table->timestamps();
|
||||
$table->softDeletes()->comment('삭제일시(Soft Delete)');
|
||||
|
||||
$table->index(['tenant_id', 'board_id']);
|
||||
$table->index('status');
|
||||
$table->foreign('tenant_id')->references('id')->on('tenants');
|
||||
$table->foreign('board_id')->references('id')->on('boards');
|
||||
});
|
||||
}
|
||||
public function down(): void {
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('posts');
|
||||
}
|
||||
};
|
||||
@@ -6,10 +6,13 @@
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up()
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('price_histories', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->bigIncrements('id');
|
||||
$table->unsignedBigInteger('tenant_id')->comment('멀티테넌시');
|
||||
$table->string('item_type_code', 20)->comment('대상구분(product/part/bom 등, code_group=price_item_type)');
|
||||
$table->unsignedBigInteger('item_id')->comment('대상ID');
|
||||
@@ -20,14 +23,14 @@ public function up()
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index(
|
||||
['tenant_id', 'item_type_code', 'item_id', 'started_at'],
|
||||
'idx_price_histories_main'
|
||||
);
|
||||
$table->index(['tenant_id', 'item_type_code', 'item_id', 'started_at'], 'idx_price_histories_main');
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('price_histories');
|
||||
}
|
||||
@@ -6,26 +6,31 @@
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up()
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('products', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->bigIncrements('id');
|
||||
$table->unsignedBigInteger('tenant_id')->comment('멀티테넌시');
|
||||
$table->string('code', 30)->comment('제품코드');
|
||||
$table->string('name', 100)->comment('제품명');
|
||||
$table->unsignedBigInteger('category_id')->comment('카테고리ID(common_codes)');
|
||||
$table->unsignedBigInteger('category_id')->index('products_category_id_foreign')->comment('카테고리ID(common_codes)');
|
||||
$table->json('attributes')->nullable()->comment('동적 속성');
|
||||
$table->string('description', 255)->nullable()->comment('설명');
|
||||
$table->string('description')->nullable()->comment('설명');
|
||||
$table->tinyInteger('is_active')->default(1)->comment('사용여부');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->unique(['tenant_id','code']);
|
||||
$table->foreign('category_id')->references('id')->on('common_codes');
|
||||
$table->unique(['tenant_id', 'code']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('products');
|
||||
}
|
||||
@@ -6,12 +6,15 @@
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up()
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('role_menu_permissions', function (Blueprint $table) {
|
||||
$table->bigIncrements('id')->comment('PK: 역할-메뉴 권한 ID');
|
||||
$table->unsignedBigInteger('role_id')->comment('FK: 역할 ID');
|
||||
$table->unsignedBigInteger('menu_id')->comment('FK: 메뉴 ID');
|
||||
$table->unsignedBigInteger('menu_id')->index('role_menu_permissions_menu_id_foreign')->comment('FK: 메뉴 ID');
|
||||
$table->boolean('access')->default(false)->comment('메뉴 접근 권한');
|
||||
$table->boolean('read')->default(false)->comment('조회 권한');
|
||||
$table->boolean('write')->default(false)->comment('등록/수정/삭제 권한');
|
||||
@@ -20,11 +23,13 @@ public function up()
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['role_id', 'menu_id']);
|
||||
$table->foreign('role_id')->references('id')->on('roles')->onDelete('cascade');
|
||||
$table->foreign('menu_id')->references('id')->on('menus')->onDelete('cascade');
|
||||
});
|
||||
}
|
||||
public function down()
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('role_menu_permissions');
|
||||
}
|
||||
@@ -6,17 +6,27 @@
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up()
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('roles', function (Blueprint $table) {
|
||||
$table->bigIncrements('id')->comment('PK: 역할 ID');
|
||||
$table->unsignedBigInteger('tenant_id')->nullable()->index()->comment('FK: 테넌트 ID(null=공용역할)');
|
||||
$table->unsignedBigInteger('tenant_id')->index();
|
||||
$table->string('name', 50)->comment('역할명');
|
||||
$table->string('description', 255)->nullable()->comment('설명');
|
||||
$table->string('description')->nullable()->comment('설명');
|
||||
$table->timestamps();
|
||||
$table->softDeletes()->comment('삭제일시(소프트삭제)');
|
||||
|
||||
$table->unique(['tenant_id', 'name'], 'uk_roles_tenant_name');
|
||||
});
|
||||
}
|
||||
public function down()
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('roles');
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?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('sessions', function (Blueprint $table) {
|
||||
$table->string('id')->primary();
|
||||
$table->unsignedBigInteger('user_id')->nullable()->index();
|
||||
$table->string('ip_address', 45)->nullable();
|
||||
$table->text('user_agent')->nullable();
|
||||
$table->longText('payload');
|
||||
$table->integer('last_activity')->index();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('sessions');
|
||||
}
|
||||
};
|
||||
@@ -6,11 +6,15 @@
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('subscriptions', function (Blueprint $table) {
|
||||
$table->id()->comment('PK');
|
||||
$table->foreignId('tenant_id')->constrained('tenants')->comment('테넌트ID');
|
||||
$table->foreignId('plan_id')->constrained('plans')->comment('플랜ID');
|
||||
$table->bigIncrements('id')->comment('PK');
|
||||
$table->unsignedBigInteger('tenant_id')->index('subscriptions_tenant_id_foreign');
|
||||
$table->unsignedBigInteger('plan_id')->index('subscriptions_plan_id_foreign');
|
||||
$table->date('started_at')->comment('구독 시작일');
|
||||
$table->date('ended_at')->nullable()->comment('구독 종료일(해지시)');
|
||||
$table->string('status', 20)->default('active')->comment('상태(active, canceled, expired 등)');
|
||||
@@ -19,7 +23,11 @@ public function up(): void {
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void {
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('subscriptions');
|
||||
}
|
||||
};
|
||||
@@ -6,14 +6,26 @@
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('tenants', function (Blueprint $table) {
|
||||
$table->bigIncrements('id')->comment('PK');
|
||||
$table->string('name', 100)->comment('회사/조직명');
|
||||
$table->string('company_name', 100)->comment('회사/조직명');
|
||||
$table->string('code', 50)->unique()->comment('테넌트 코드');
|
||||
$table->string('email', 80)->nullable()->comment('대표 이메일');
|
||||
$table->string('phone', 20)->nullable()->comment('대표 전화번호');
|
||||
$table->string('address', 255)->nullable()->comment('주소');
|
||||
$table->string('address')->nullable()->comment('주소');
|
||||
$table->string('business_num', 12)->nullable()->comment('사업자등록번호(10자리)');
|
||||
$table->string('corp_reg_no', 13)->nullable()->comment('법인등록번호(13자리, 법인만)');
|
||||
$table->string('ceo_name', 50)->nullable()->comment('대표자명');
|
||||
$table->string('homepage')->nullable()->comment('홈페이지 주소');
|
||||
$table->string('fax', 30)->nullable()->comment('팩스번호');
|
||||
$table->string('logo')->nullable()->comment('회사 로고 이미지 경로');
|
||||
$table->text('admin_memo')->nullable()->comment('관리자 메모/비고');
|
||||
$table->json('options')->nullable()->comment('회사별 옵션 정보(확장용 JSON)');
|
||||
$table->string('tenant_st_code', 20)->default('trial')->comment('테넌트 상태(trial,active,suspended,cancelled)');
|
||||
$table->unsignedBigInteger('plan_id')->nullable()->comment('현재 요금제(플랜) ID');
|
||||
$table->unsignedBigInteger('subscription_id')->nullable()->comment('현재 구독 정보 ID');
|
||||
@@ -24,14 +36,14 @@ public function up(): void {
|
||||
$table->string('billing_tp_code', 20)->default('monthly')->comment('결제 주기(monthly,yearly)');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
// FK는 필요시 추가
|
||||
// $table->foreign('plan_id')->references('id')->on('plans');
|
||||
// $table->foreign('subscription_id')->references('id')->on('subscriptions');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void {
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('tenants');
|
||||
}
|
||||
};
|
||||
@@ -6,12 +6,15 @@
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up()
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('user_menu_permissions', function (Blueprint $table) {
|
||||
$table->bigIncrements('id')->comment('PK: 사용자-메뉴 권한 ID');
|
||||
$table->unsignedBigInteger('user_id')->comment('FK: 사용자 ID');
|
||||
$table->unsignedBigInteger('menu_id')->comment('FK: 메뉴 ID');
|
||||
$table->unsignedBigInteger('menu_id')->index('user_menu_permissions_menu_id_foreign')->comment('FK: 메뉴 ID');
|
||||
$table->boolean('access')->default(false)->comment('메뉴 접근 권한');
|
||||
$table->boolean('read')->default(false)->comment('조회 권한');
|
||||
$table->boolean('write')->default(false)->comment('등록/수정/삭제 권한');
|
||||
@@ -20,11 +23,13 @@ public function up()
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['user_id', 'menu_id']);
|
||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
$table->foreign('menu_id')->references('id')->on('menus')->onDelete('cascade');
|
||||
});
|
||||
}
|
||||
public function down()
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('user_menu_permissions');
|
||||
}
|
||||
@@ -6,24 +6,27 @@
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('user_roles', function (Blueprint $table) {
|
||||
$table->bigIncrements('id')->comment('PK: 회원별 역할 매핑 ID');
|
||||
$table->unsignedBigInteger('user_id')->comment('FK: 회원ID');
|
||||
$table->unsignedBigInteger('tenant_id')->comment('FK: 테넌트ID');
|
||||
$table->unsignedBigInteger('role_id')->comment('FK: 역할ID');
|
||||
$table->unsignedBigInteger('tenant_id')->index('user_roles_tenant_id_foreign')->comment('FK: 테넌트ID');
|
||||
$table->unsignedBigInteger('role_id')->index('user_roles_role_id_foreign')->comment('FK: 역할ID');
|
||||
$table->timestamp('assigned_at')->nullable()->comment('역할 할당일');
|
||||
$table->timestamps();
|
||||
$table->softDeletes()->comment('삭제일시(소프트삭제)');
|
||||
|
||||
$table->unique(['user_id', 'tenant_id', 'role_id'], 'uk_user_tenant_role');
|
||||
$table->foreign('user_id')->references('id')->on('users');
|
||||
$table->foreign('tenant_id')->references('id')->on('tenants');
|
||||
$table->foreign('role_id')->references('id')->on('roles');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('user_roles');
|
||||
@@ -4,25 +4,30 @@
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('user_tenants', function (Blueprint $table) {
|
||||
$table->bigIncrements('id')->comment('PK: 회원-테넌트 소속 ID');
|
||||
$table->unsignedBigInteger('user_id')->comment('FK: 회원ID');
|
||||
$table->unsignedBigInteger('tenant_id')->comment('FK: 테넌트ID');
|
||||
$table->boolean('is_active')->default(1)->comment('활성화 여부');
|
||||
$table->unsignedBigInteger('tenant_id')->index('user_tenants_tenant_id_foreign')->comment('FK: 테넌트ID');
|
||||
$table->boolean('is_active')->default(true)->comment('활성화 여부');
|
||||
$table->timestamp('joined_at')->nullable()->comment('소속일시');
|
||||
$table->timestamp('left_at')->nullable()->comment('탈퇴일시');
|
||||
$table->timestamps();
|
||||
$table->softDeletes()->comment('삭제일시(소프트삭제)');
|
||||
|
||||
$table->unique(['user_id', 'tenant_id'], 'uk_user_tenant');
|
||||
$table->foreign('user_id')->references('id')->on('users');
|
||||
$table->foreign('tenant_id')->references('id')->on('tenants');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('user_tenants');
|
||||
42
database/migrations/2025_07_26_051643_create_users_table.php
Normal file
42
database/migrations/2025_07_26_051643_create_users_table.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?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('users', function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->string('user_id', 100)->unique()->comment('회원 아이디');
|
||||
$table->string('phone', 30)->nullable()->comment('회원 전화번호');
|
||||
$table->json('options')->nullable()->comment('회사별 옵션 정보(계좌, 사번 등)');
|
||||
$table->string('name')->comment('회원 이름');
|
||||
$table->string('email')->unique('uk_users_tenant_email')->comment('이메일');
|
||||
$table->timestamp('email_verified_at')->nullable();
|
||||
$table->string('password')->comment('비밀번호');
|
||||
$table->timestamp('last_login_at')->nullable()->comment('마지막 로그인 일시');
|
||||
$table->text('two_factor_secret')->nullable();
|
||||
$table->text('two_factor_recovery_codes')->nullable();
|
||||
$table->timestamp('two_factor_confirmed_at')->nullable();
|
||||
$table->rememberToken()->comment('자동로그인 토큰');
|
||||
$table->unsignedBigInteger('current_team_id')->nullable();
|
||||
$table->string('profile_photo_path', 2048)->nullable()->comment('프로필 사진 경로');
|
||||
$table->timestamps();
|
||||
$table->softDeletes()->comment('삭제일시(소프트삭제)');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('users');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,34 @@
|
||||
<?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::table('board_comments', function (Blueprint $table) {
|
||||
$table->foreign(['parent_id'])->references(['id'])->on('board_comments')->onUpdate('no action')->onDelete('no action');
|
||||
$table->foreign(['post_id'])->references(['id'])->on('posts')->onUpdate('no action')->onDelete('cascade');
|
||||
$table->foreign(['tenant_id'])->references(['id'])->on('tenants')->onUpdate('no action')->onDelete('no action');
|
||||
$table->foreign(['user_id'])->references(['id'])->on('users')->onUpdate('no action')->onDelete('no action');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('board_comments', function (Blueprint $table) {
|
||||
$table->dropForeign('board_comments_parent_id_foreign');
|
||||
$table->dropForeign('board_comments_post_id_foreign');
|
||||
$table->dropForeign('board_comments_tenant_id_foreign');
|
||||
$table->dropForeign('board_comments_user_id_foreign');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
<?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::table('board_files', function (Blueprint $table) {
|
||||
$table->foreign(['post_id'])->references(['id'])->on('posts')->onUpdate('no action')->onDelete('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('board_files', function (Blueprint $table) {
|
||||
$table->dropForeign('board_files_post_id_foreign');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
<?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::table('board_settings', function (Blueprint $table) {
|
||||
$table->foreign(['board_id'])->references(['id'])->on('boards')->onUpdate('no action')->onDelete('no action');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('board_settings', function (Blueprint $table) {
|
||||
$table->dropForeign('board_settings_board_id_foreign');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
<?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::table('boards', function (Blueprint $table) {
|
||||
$table->foreign(['tenant_id'])->references(['id'])->on('tenants')->onUpdate('no action')->onDelete('no action');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('boards', function (Blueprint $table) {
|
||||
$table->dropForeign('boards_tenant_id_foreign');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,30 @@
|
||||
<?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::table('bom_items', function (Blueprint $table) {
|
||||
$table->foreign(['bom_id'])->references(['id'])->on('boms')->onUpdate('no action')->onDelete('no action');
|
||||
$table->foreign(['parent_id'])->references(['id'])->on('bom_items')->onUpdate('no action')->onDelete('no action');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('bom_items', function (Blueprint $table) {
|
||||
$table->dropForeign('bom_items_bom_id_foreign');
|
||||
$table->dropForeign('bom_items_parent_id_foreign');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
<?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::table('boms', function (Blueprint $table) {
|
||||
$table->foreign(['category_id'])->references(['id'])->on('common_codes')->onUpdate('no action')->onDelete('no action');
|
||||
$table->foreign(['image_file_id'])->references(['id'])->on('files')->onUpdate('no action')->onDelete('no action');
|
||||
$table->foreign(['product_id'])->references(['id'])->on('products')->onUpdate('no action')->onDelete('no action');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('boms', function (Blueprint $table) {
|
||||
$table->dropForeign('boms_category_id_foreign');
|
||||
$table->dropForeign('boms_image_file_id_foreign');
|
||||
$table->dropForeign('boms_product_id_foreign');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
<?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::table('common_codes', function (Blueprint $table) {
|
||||
$table->foreign(['parent_id'])->references(['id'])->on('common_codes')->onUpdate('no action')->onDelete('no action');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('common_codes', function (Blueprint $table) {
|
||||
$table->dropForeign('common_codes_parent_id_foreign');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,30 @@
|
||||
<?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::table('parts', function (Blueprint $table) {
|
||||
$table->foreign(['category_id'])->references(['id'])->on('common_codes')->onUpdate('no action')->onDelete('no action');
|
||||
$table->foreign(['part_type_id'])->references(['id'])->on('common_codes')->onUpdate('no action')->onDelete('no action');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('parts', function (Blueprint $table) {
|
||||
$table->dropForeign('parts_category_id_foreign');
|
||||
$table->dropForeign('parts_part_type_id_foreign');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
<?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::table('payments', function (Blueprint $table) {
|
||||
$table->foreign(['subscription_id'])->references(['id'])->on('subscriptions')->onUpdate('no action')->onDelete('no action');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('payments', function (Blueprint $table) {
|
||||
$table->dropForeign('payments_subscription_id_foreign');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,30 @@
|
||||
<?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::table('post_custom_field_values', function (Blueprint $table) {
|
||||
$table->foreign(['field_id'])->references(['id'])->on('board_settings')->onUpdate('no action')->onDelete('no action');
|
||||
$table->foreign(['post_id'])->references(['id'])->on('posts')->onUpdate('no action')->onDelete('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('post_custom_field_values', function (Blueprint $table) {
|
||||
$table->dropForeign('post_custom_field_values_field_id_foreign');
|
||||
$table->dropForeign('post_custom_field_values_post_id_foreign');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,30 @@
|
||||
<?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::table('posts', function (Blueprint $table) {
|
||||
$table->foreign(['board_id'])->references(['id'])->on('boards')->onUpdate('no action')->onDelete('no action');
|
||||
$table->foreign(['tenant_id'])->references(['id'])->on('tenants')->onUpdate('no action')->onDelete('no action');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('posts', function (Blueprint $table) {
|
||||
$table->dropForeign('posts_board_id_foreign');
|
||||
$table->dropForeign('posts_tenant_id_foreign');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
<?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::table('products', function (Blueprint $table) {
|
||||
$table->foreign(['category_id'])->references(['id'])->on('common_codes')->onUpdate('no action')->onDelete('no action');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('products', function (Blueprint $table) {
|
||||
$table->dropForeign('products_category_id_foreign');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,30 @@
|
||||
<?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::table('role_menu_permissions', function (Blueprint $table) {
|
||||
$table->foreign(['menu_id'])->references(['id'])->on('menus')->onUpdate('no action')->onDelete('cascade');
|
||||
$table->foreign(['role_id'])->references(['id'])->on('roles')->onUpdate('no action')->onDelete('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('role_menu_permissions', function (Blueprint $table) {
|
||||
$table->dropForeign('role_menu_permissions_menu_id_foreign');
|
||||
$table->dropForeign('role_menu_permissions_role_id_foreign');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,30 @@
|
||||
<?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::table('subscriptions', function (Blueprint $table) {
|
||||
$table->foreign(['plan_id'])->references(['id'])->on('plans')->onUpdate('no action')->onDelete('no action');
|
||||
$table->foreign(['tenant_id'])->references(['id'])->on('tenants')->onUpdate('no action')->onDelete('no action');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('subscriptions', function (Blueprint $table) {
|
||||
$table->dropForeign('subscriptions_plan_id_foreign');
|
||||
$table->dropForeign('subscriptions_tenant_id_foreign');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,30 @@
|
||||
<?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::table('user_menu_permissions', function (Blueprint $table) {
|
||||
$table->foreign(['menu_id'])->references(['id'])->on('menus')->onUpdate('no action')->onDelete('cascade');
|
||||
$table->foreign(['user_id'])->references(['id'])->on('users')->onUpdate('no action')->onDelete('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('user_menu_permissions', function (Blueprint $table) {
|
||||
$table->dropForeign('user_menu_permissions_menu_id_foreign');
|
||||
$table->dropForeign('user_menu_permissions_user_id_foreign');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
<?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::table('user_roles', function (Blueprint $table) {
|
||||
$table->foreign(['role_id'])->references(['id'])->on('roles')->onUpdate('no action')->onDelete('no action');
|
||||
$table->foreign(['tenant_id'])->references(['id'])->on('tenants')->onUpdate('no action')->onDelete('no action');
|
||||
$table->foreign(['user_id'])->references(['id'])->on('users')->onUpdate('no action')->onDelete('no action');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('user_roles', function (Blueprint $table) {
|
||||
$table->dropForeign('user_roles_role_id_foreign');
|
||||
$table->dropForeign('user_roles_tenant_id_foreign');
|
||||
$table->dropForeign('user_roles_user_id_foreign');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,30 @@
|
||||
<?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::table('user_tenants', function (Blueprint $table) {
|
||||
$table->foreign(['tenant_id'])->references(['id'])->on('tenants')->onUpdate('no action')->onDelete('no action');
|
||||
$table->foreign(['user_id'])->references(['id'])->on('users')->onUpdate('no action')->onDelete('no action');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('user_tenants', function (Blueprint $table) {
|
||||
$table->dropForeign('user_tenants_tenant_id_foreign');
|
||||
$table->dropForeign('user_tenants_user_id_foreign');
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user