From 78e130030d876d71eba491ed69d51174ec7518d5 Mon Sep 17 00:00:00 2001 From: hskwon Date: Thu, 14 Aug 2025 10:05:23 +0900 Subject: [PATCH] =?UTF-8?q?fix=20:=20API=20=EB=A7=88=EC=9D=B4=EA=B7=B8?= =?UTF-8?q?=EB=A0=88=EC=9D=B4=EC=85=98=20=EC=B4=88=EA=B8=B0=ED=99=94=20?= =?UTF-8?q?=EB=B0=8F=20=ED=98=84=EC=9E=AC=20DB=20=EA=B5=AC=EC=A1=B0=20?= =?UTF-8?q?=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...025_07_26_051643_create_api_keys_table.php | 30 - ..._26_051643_create_board_comments_table.php | 35 - ..._07_26_051643_create_board_files_table.php | 32 - ..._26_051643_create_board_settings_table.php | 36 - .../2025_07_26_051643_create_boards_table.php | 39 - ...25_07_26_051643_create_bom_items_table.php | 38 - .../2025_07_26_051643_create_boms_table.php | 42 - ..._07_26_051643_create_cache_locks_table.php | 28 - .../2025_07_26_051643_create_cache_table.php | 28 - ...07_26_051643_create_common_codes_table.php | 40 - ..._07_26_051643_create_failed_jobs_table.php | 32 - .../2025_07_26_051643_create_files_table.php | 39 - ..._07_26_051643_create_job_batches_table.php | 35 - .../2025_07_26_051643_create_jobs_table.php | 32 - ..._07_26_051643_create_log_session_table.php | 32 - .../2025_07_26_051643_create_menus_table.php | 37 - .../2025_07_26_051643_create_parts_table.php | 41 - ...643_create_password_reset_tokens_table.php | 28 - ...025_07_26_051643_create_payments_table.php | 35 - ...43_create_personal_access_tokens_table.php | 36 - .../2025_07_26_051643_create_plans_table.php | 35 - ..._create_post_custom_field_values_table.php | 32 - .../2025_07_26_051643_create_posts_table.php | 41 - ...26_051643_create_price_histories_table.php | 39 - ...025_07_26_051643_create_products_table.php | 39 - ...643_create_role_menu_permissions_table.php | 36 - .../2025_07_26_051643_create_roles_table.php | 33 - ...025_07_26_051643_create_sessions_table.php | 31 - ...7_26_051643_create_subscriptions_table.php | 33 - ...2025_07_26_051643_create_tenants_table.php | 49 - ...643_create_user_menu_permissions_table.php | 36 - ...5_07_26_051643_create_user_roles_table.php | 34 - ...07_26_051643_create_user_tenants_table.php | 35 - .../2025_07_26_051643_create_users_table.php | 42 - ...d_foreign_keys_to_board_comments_table.php | 34 - ..._add_foreign_keys_to_board_files_table.php | 28 - ...d_foreign_keys_to_board_settings_table.php | 28 - ...51646_add_foreign_keys_to_boards_table.php | 28 - ...46_add_foreign_keys_to_bom_items_table.php | 30 - ..._051646_add_foreign_keys_to_boms_table.php | 32 - ...add_foreign_keys_to_common_codes_table.php | 28 - ...051646_add_foreign_keys_to_parts_table.php | 30 - ...646_add_foreign_keys_to_payments_table.php | 28 - ...keys_to_post_custom_field_values_table.php | 30 - ...051646_add_foreign_keys_to_posts_table.php | 30 - ...646_add_foreign_keys_to_products_table.php | 28 - ...gn_keys_to_role_menu_permissions_table.php | 30 - ...dd_foreign_keys_to_subscriptions_table.php | 30 - ...gn_keys_to_user_menu_permissions_table.php | 30 - ...6_add_foreign_keys_to_user_roles_table.php | 32 - ...add_foreign_keys_to_user_tenants_table.php | 30 - ...25_07_28_183746_create_materials_table.php | 31 - ...25_07_28_183747_create_lot_sales_table.php | 30 - .../2025_07_28_183747_create_lots_table.php | 34 - ...create_material_inspection_items_table.php | 27 - ...3747_create_material_inspections_table.php | 33 - ..._183747_create_material_receipts_table.php | 38 - ..._add_foreign_keys_to_material_receipts.php | 45 - database/schema/mysql-schema.sql | 1277 +++++++++++++++++ 59 files changed, 1277 insertions(+), 1954 deletions(-) delete mode 100644 database/migrations/2025_07_26_051643_create_api_keys_table.php delete mode 100644 database/migrations/2025_07_26_051643_create_board_comments_table.php delete mode 100644 database/migrations/2025_07_26_051643_create_board_files_table.php delete mode 100644 database/migrations/2025_07_26_051643_create_board_settings_table.php delete mode 100644 database/migrations/2025_07_26_051643_create_boards_table.php delete mode 100644 database/migrations/2025_07_26_051643_create_bom_items_table.php delete mode 100644 database/migrations/2025_07_26_051643_create_boms_table.php delete mode 100644 database/migrations/2025_07_26_051643_create_cache_locks_table.php delete mode 100644 database/migrations/2025_07_26_051643_create_cache_table.php delete mode 100644 database/migrations/2025_07_26_051643_create_common_codes_table.php delete mode 100644 database/migrations/2025_07_26_051643_create_failed_jobs_table.php delete mode 100644 database/migrations/2025_07_26_051643_create_files_table.php delete mode 100644 database/migrations/2025_07_26_051643_create_job_batches_table.php delete mode 100644 database/migrations/2025_07_26_051643_create_jobs_table.php delete mode 100644 database/migrations/2025_07_26_051643_create_log_session_table.php delete mode 100644 database/migrations/2025_07_26_051643_create_menus_table.php delete mode 100644 database/migrations/2025_07_26_051643_create_parts_table.php delete mode 100644 database/migrations/2025_07_26_051643_create_password_reset_tokens_table.php delete mode 100644 database/migrations/2025_07_26_051643_create_payments_table.php delete mode 100644 database/migrations/2025_07_26_051643_create_personal_access_tokens_table.php delete mode 100644 database/migrations/2025_07_26_051643_create_plans_table.php delete mode 100644 database/migrations/2025_07_26_051643_create_post_custom_field_values_table.php delete mode 100644 database/migrations/2025_07_26_051643_create_posts_table.php delete mode 100644 database/migrations/2025_07_26_051643_create_price_histories_table.php delete mode 100644 database/migrations/2025_07_26_051643_create_products_table.php delete mode 100644 database/migrations/2025_07_26_051643_create_role_menu_permissions_table.php delete mode 100644 database/migrations/2025_07_26_051643_create_roles_table.php delete mode 100644 database/migrations/2025_07_26_051643_create_sessions_table.php delete mode 100644 database/migrations/2025_07_26_051643_create_subscriptions_table.php delete mode 100644 database/migrations/2025_07_26_051643_create_tenants_table.php delete mode 100644 database/migrations/2025_07_26_051643_create_user_menu_permissions_table.php delete mode 100644 database/migrations/2025_07_26_051643_create_user_roles_table.php delete mode 100644 database/migrations/2025_07_26_051643_create_user_tenants_table.php delete mode 100644 database/migrations/2025_07_26_051643_create_users_table.php delete mode 100644 database/migrations/2025_07_26_051646_add_foreign_keys_to_board_comments_table.php delete mode 100644 database/migrations/2025_07_26_051646_add_foreign_keys_to_board_files_table.php delete mode 100644 database/migrations/2025_07_26_051646_add_foreign_keys_to_board_settings_table.php delete mode 100644 database/migrations/2025_07_26_051646_add_foreign_keys_to_boards_table.php delete mode 100644 database/migrations/2025_07_26_051646_add_foreign_keys_to_bom_items_table.php delete mode 100644 database/migrations/2025_07_26_051646_add_foreign_keys_to_boms_table.php delete mode 100644 database/migrations/2025_07_26_051646_add_foreign_keys_to_common_codes_table.php delete mode 100644 database/migrations/2025_07_26_051646_add_foreign_keys_to_parts_table.php delete mode 100644 database/migrations/2025_07_26_051646_add_foreign_keys_to_payments_table.php delete mode 100644 database/migrations/2025_07_26_051646_add_foreign_keys_to_post_custom_field_values_table.php delete mode 100644 database/migrations/2025_07_26_051646_add_foreign_keys_to_posts_table.php delete mode 100644 database/migrations/2025_07_26_051646_add_foreign_keys_to_products_table.php delete mode 100644 database/migrations/2025_07_26_051646_add_foreign_keys_to_role_menu_permissions_table.php delete mode 100644 database/migrations/2025_07_26_051646_add_foreign_keys_to_subscriptions_table.php delete mode 100644 database/migrations/2025_07_26_051646_add_foreign_keys_to_user_menu_permissions_table.php delete mode 100644 database/migrations/2025_07_26_051646_add_foreign_keys_to_user_roles_table.php delete mode 100644 database/migrations/2025_07_26_051646_add_foreign_keys_to_user_tenants_table.php delete mode 100644 database/migrations/2025_07_28_183746_create_materials_table.php delete mode 100644 database/migrations/2025_07_28_183747_create_lot_sales_table.php delete mode 100644 database/migrations/2025_07_28_183747_create_lots_table.php delete mode 100644 database/migrations/2025_07_28_183747_create_material_inspection_items_table.php delete mode 100644 database/migrations/2025_07_28_183747_create_material_inspections_table.php delete mode 100644 database/migrations/2025_07_28_183747_create_material_receipts_table.php delete mode 100644 database/migrations/2025_07_28_183748_add_foreign_keys_to_material_receipts.php create mode 100644 database/schema/mysql-schema.sql diff --git a/database/migrations/2025_07_26_051643_create_api_keys_table.php b/database/migrations/2025_07_26_051643_create_api_keys_table.php deleted file mode 100644 index cca23d4..0000000 --- a/database/migrations/2025_07_26_051643_create_api_keys_table.php +++ /dev/null @@ -1,30 +0,0 @@ -bigIncrements('id'); - $table->string('key')->unique(); - $table->string('description')->nullable(); - $table->boolean('is_active')->default(true); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('api_keys'); - } -}; diff --git a/database/migrations/2025_07_26_051643_create_board_comments_table.php b/database/migrations/2025_07_26_051643_create_board_comments_table.php deleted file mode 100644 index 8a9dd7e..0000000 --- a/database/migrations/2025_07_26_051643_create_board_comments_table.php +++ /dev/null @@ -1,35 +0,0 @@ -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'); - } -}; diff --git a/database/migrations/2025_07_26_051643_create_board_files_table.php b/database/migrations/2025_07_26_051643_create_board_files_table.php deleted file mode 100644 index 53c388a..0000000 --- a/database/migrations/2025_07_26_051643_create_board_files_table.php +++ /dev/null @@ -1,32 +0,0 @@ -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(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('board_files'); - } -}; diff --git a/database/migrations/2025_07_26_051643_create_board_settings_table.php b/database/migrations/2025_07_26_051643_create_board_settings_table.php deleted file mode 100644 index a99e89b..0000000 --- a/database/migrations/2025_07_26_051643_create_board_settings_table.php +++ /dev/null @@ -1,36 +0,0 @@ -bigIncrements('id')->comment('커스텀필드 고유번호'); - $table->unsignedBigInteger('board_id')->comment('게시판 고유번호'); - $table->string('name', 100)->comment('필드명'); - $table->string('field_key', 50)->comment('필드키'); - $table->string('field_type', 20)->comment('필드유형'); - $table->json('field_meta')->nullable()->comment('필드메타'); - $table->boolean('is_required')->default(false)->comment('필수여부'); - $table->integer('sort_order')->default(0)->comment('정렬순서'); - $table->timestamps(); - - $table->unique(['board_id', 'field_key']); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('board_settings'); - } -}; diff --git a/database/migrations/2025_07_26_051643_create_boards_table.php b/database/migrations/2025_07_26_051643_create_boards_table.php deleted file mode 100644 index 1ab76bd..0000000 --- a/database/migrations/2025_07_26_051643_create_boards_table.php +++ /dev/null @@ -1,39 +0,0 @@ -bigIncrements('id')->comment('게시판 고유번호'); - $table->unsignedBigInteger('tenant_id')->comment('테넌트 고유번호'); - $table->string('board_code', 30)->comment('게시판 코드'); - $table->string('name', 100)->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('최대 첨부파일 수'); - $table->integer('max_file_size')->default(20480)->comment('최대 첨부파일 크기(KB)'); - $table->json('extra_settings')->nullable()->comment('추가 설정(JSON)'); - $table->boolean('is_active')->default(true)->comment('활성화 여부'); - $table->timestamps(); - - $table->unique(['tenant_id', 'board_code']); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('boards'); - } -}; diff --git a/database/migrations/2025_07_26_051643_create_bom_items_table.php b/database/migrations/2025_07_26_051643_create_bom_items_table.php deleted file mode 100644 index a6bb1de..0000000 --- a/database/migrations/2025_07_26_051643_create_bom_items_table.php +++ /dev/null @@ -1,38 +0,0 @@ -bigIncrements('id'); - $table->unsignedBigInteger('tenant_id')->comment('멀티테넌시'); - $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); - $table->json('attributes')->nullable()->comment('동적 속성'); - $table->integer('sort_order')->default(0); - $table->unsignedBigInteger('created_by')->comment('생성자(회원PK)'); - $table->unsignedBigInteger('updated_by')->nullable()->comment('수정자(회원PK)'); - $table->timestamps(); - $table->softDeletes(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('bom_items'); - } -}; diff --git a/database/migrations/2025_07_26_051643_create_boms_table.php b/database/migrations/2025_07_26_051643_create_boms_table.php deleted file mode 100644 index 7f8270f..0000000 --- a/database/migrations/2025_07_26_051643_create_boms_table.php +++ /dev/null @@ -1,42 +0,0 @@ -bigIncrements('id'); - $table->unsignedBigInteger('tenant_id')->comment('멀티테넌시'); - $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')->index('boms_category_id_foreign')->comment('카테고리ID(common_codes)'); - $table->json('attributes')->nullable()->comment('동적 속성'); - $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->unsignedBigInteger('created_by')->comment('생성자(회원PK)'); - $table->unsignedBigInteger('updated_by')->nullable()->comment('수정자(회원PK)'); - $table->timestamps(); - $table->softDeletes(); - - $table->unique(['tenant_id', 'product_id', 'code']); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('boms'); - } -}; diff --git a/database/migrations/2025_07_26_051643_create_cache_locks_table.php b/database/migrations/2025_07_26_051643_create_cache_locks_table.php deleted file mode 100644 index e320c41..0000000 --- a/database/migrations/2025_07_26_051643_create_cache_locks_table.php +++ /dev/null @@ -1,28 +0,0 @@ -string('key')->primary(); - $table->string('owner'); - $table->integer('expiration'); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('cache_locks'); - } -}; diff --git a/database/migrations/2025_07_26_051643_create_cache_table.php b/database/migrations/2025_07_26_051643_create_cache_table.php deleted file mode 100644 index 960ce18..0000000 --- a/database/migrations/2025_07_26_051643_create_cache_table.php +++ /dev/null @@ -1,28 +0,0 @@ -string('key')->primary(); - $table->mediumText('value'); - $table->integer('expiration'); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('cache'); - } -}; diff --git a/database/migrations/2025_07_26_051643_create_common_codes_table.php b/database/migrations/2025_07_26_051643_create_common_codes_table.php deleted file mode 100644 index f328597..0000000 --- a/database/migrations/2025_07_26_051643_create_common_codes_table.php +++ /dev/null @@ -1,40 +0,0 @@ -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()->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']); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('common_codes'); - } -}; diff --git a/database/migrations/2025_07_26_051643_create_failed_jobs_table.php b/database/migrations/2025_07_26_051643_create_failed_jobs_table.php deleted file mode 100644 index 08606bd..0000000 --- a/database/migrations/2025_07_26_051643_create_failed_jobs_table.php +++ /dev/null @@ -1,32 +0,0 @@ -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'); - } -}; diff --git a/database/migrations/2025_07_26_051643_create_files_table.php b/database/migrations/2025_07_26_051643_create_files_table.php deleted file mode 100644 index cfa5afb..0000000 --- a/database/migrations/2025_07_26_051643_create_files_table.php +++ /dev/null @@ -1,39 +0,0 @@ -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'); - } -}; diff --git a/database/migrations/2025_07_26_051643_create_job_batches_table.php b/database/migrations/2025_07_26_051643_create_job_batches_table.php deleted file mode 100644 index 50e38c2..0000000 --- a/database/migrations/2025_07_26_051643_create_job_batches_table.php +++ /dev/null @@ -1,35 +0,0 @@ -string('id')->primary(); - $table->string('name'); - $table->integer('total_jobs'); - $table->integer('pending_jobs'); - $table->integer('failed_jobs'); - $table->longText('failed_job_ids'); - $table->mediumText('options')->nullable(); - $table->integer('cancelled_at')->nullable(); - $table->integer('created_at'); - $table->integer('finished_at')->nullable(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('job_batches'); - } -}; diff --git a/database/migrations/2025_07_26_051643_create_jobs_table.php b/database/migrations/2025_07_26_051643_create_jobs_table.php deleted file mode 100644 index 6098d9b..0000000 --- a/database/migrations/2025_07_26_051643_create_jobs_table.php +++ /dev/null @@ -1,32 +0,0 @@ -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'); - } -}; diff --git a/database/migrations/2025_07_26_051643_create_log_session_table.php b/database/migrations/2025_07_26_051643_create_log_session_table.php deleted file mode 100644 index 505b39f..0000000 --- a/database/migrations/2025_07_26_051643_create_log_session_table.php +++ /dev/null @@ -1,32 +0,0 @@ -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'); - } -}; diff --git a/database/migrations/2025_07_26_051643_create_menus_table.php b/database/migrations/2025_07_26_051643_create_menus_table.php deleted file mode 100644 index 8c4d6a2..0000000 --- a/database/migrations/2025_07_26_051643_create_menus_table.php +++ /dev/null @@ -1,37 +0,0 @@ -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')->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')->nullable()->comment('외부링크 URL'); - $table->string('icon', 50)->nullable()->comment('아이콘명'); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('menus'); - } -}; diff --git a/database/migrations/2025_07_26_051643_create_parts_table.php b/database/migrations/2025_07_26_051643_create_parts_table.php deleted file mode 100644 index d468739..0000000 --- a/database/migrations/2025_07_26_051643_create_parts_table.php +++ /dev/null @@ -1,41 +0,0 @@ -bigIncrements('id'); - $table->unsignedBigInteger('tenant_id')->comment('멀티테넌시'); - $table->string('code', 30)->comment('부품코드'); - $table->string('name', 100)->comment('부품명'); - $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')->nullable()->comment('설명'); - $table->tinyInteger('is_active')->default(1)->comment('사용여부'); - $table->unsignedBigInteger('created_by')->comment('생성자(회원PK)'); - $table->unsignedBigInteger('updated_by')->nullable()->comment('수정자(회원PK)'); - $table->timestamps(); - $table->softDeletes(); - - $table->unique(['tenant_id', 'code']); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('parts'); - } -}; diff --git a/database/migrations/2025_07_26_051643_create_password_reset_tokens_table.php b/database/migrations/2025_07_26_051643_create_password_reset_tokens_table.php deleted file mode 100644 index 81a7229..0000000 --- a/database/migrations/2025_07_26_051643_create_password_reset_tokens_table.php +++ /dev/null @@ -1,28 +0,0 @@ -string('email')->primary(); - $table->string('token'); - $table->timestamp('created_at')->nullable(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('password_reset_tokens'); - } -}; diff --git a/database/migrations/2025_07_26_051643_create_payments_table.php b/database/migrations/2025_07_26_051643_create_payments_table.php deleted file mode 100644 index 32b55a0..0000000 --- a/database/migrations/2025_07_26_051643_create_payments_table.php +++ /dev/null @@ -1,35 +0,0 @@ -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('결제일시'); - $table->string('status', 20)->default('paid')->comment('결제상태(paid, failed 등)'); - $table->text('memo')->nullable()->comment('비고'); - $table->timestamps(); - $table->softDeletes(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('payments'); - } -}; diff --git a/database/migrations/2025_07_26_051643_create_personal_access_tokens_table.php b/database/migrations/2025_07_26_051643_create_personal_access_tokens_table.php deleted file mode 100644 index 2978f38..0000000 --- a/database/migrations/2025_07_26_051643_create_personal_access_tokens_table.php +++ /dev/null @@ -1,36 +0,0 @@ -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']); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('personal_access_tokens'); - } -}; diff --git a/database/migrations/2025_07_26_051643_create_plans_table.php b/database/migrations/2025_07_26_051643_create_plans_table.php deleted file mode 100644 index 1b502bd..0000000 --- a/database/migrations/2025_07_26_051643_create_plans_table.php +++ /dev/null @@ -1,35 +0,0 @@ -bigIncrements('id')->comment('PK'); - $table->string('name')->comment('플랜명'); - $table->string('code', 30)->unique()->comment('플랜 코드'); - $table->text('description')->nullable()->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('사용여부'); - $table->timestamps(); - $table->softDeletes(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('plans'); - } -}; diff --git a/database/migrations/2025_07_26_051643_create_post_custom_field_values_table.php b/database/migrations/2025_07_26_051643_create_post_custom_field_values_table.php deleted file mode 100644 index 62bf8c2..0000000 --- a/database/migrations/2025_07_26_051643_create_post_custom_field_values_table.php +++ /dev/null @@ -1,32 +0,0 @@ -bigIncrements('id')->comment('필드값 고유번호'); - $table->unsignedBigInteger('post_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']); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('post_custom_field_values'); - } -}; diff --git a/database/migrations/2025_07_26_051643_create_posts_table.php b/database/migrations/2025_07_26_051643_create_posts_table.php deleted file mode 100644 index 432b49c..0000000 --- a/database/migrations/2025_07_26_051643_create_posts_table.php +++ /dev/null @@ -1,41 +0,0 @@ -bigIncrements('id')->comment('게시글 고유번호'); - $table->unsignedBigInteger('tenant_id')->comment('테넌트 고유번호'); - $table->unsignedBigInteger('board_id')->index('posts_board_id_foreign')->comment('게시판 고유번호'); - $table->unsignedBigInteger('user_id')->nullable()->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')->index()->comment('상태'); - $table->timestamps(); - $table->softDeletes()->comment('삭제일시(Soft Delete)'); - - $table->index(['tenant_id', 'board_id']); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('posts'); - } -}; diff --git a/database/migrations/2025_07_26_051643_create_price_histories_table.php b/database/migrations/2025_07_26_051643_create_price_histories_table.php deleted file mode 100644 index dac7c92..0000000 --- a/database/migrations/2025_07_26_051643_create_price_histories_table.php +++ /dev/null @@ -1,39 +0,0 @@ -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'); - $table->string('price_type_code', 20)->comment('단가구분(default/20%up/10%discount 등, code_group=price_type)'); - $table->decimal('price', 18, 4)->comment('단가'); - $table->date('started_at'); - $table->date('ended_at')->nullable(); - $table->unsignedBigInteger('created_by')->comment('생성자(회원PK)'); - $table->unsignedBigInteger('updated_by')->nullable()->comment('수정자(회원PK)'); - $table->timestamps(); - $table->softDeletes(); - - $table->index(['tenant_id', 'item_type_code', 'item_id', 'started_at'], 'idx_price_histories_main'); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('price_histories'); - } -}; diff --git a/database/migrations/2025_07_26_051643_create_products_table.php b/database/migrations/2025_07_26_051643_create_products_table.php deleted file mode 100644 index 71d1e7f..0000000 --- a/database/migrations/2025_07_26_051643_create_products_table.php +++ /dev/null @@ -1,39 +0,0 @@ -bigIncrements('id'); - $table->unsignedBigInteger('tenant_id')->comment('멀티테넌시'); - $table->string('code', 30)->comment('제품코드'); - $table->string('name', 100)->comment('제품명'); - $table->unsignedBigInteger('category_id')->index('products_category_id_foreign')->comment('카테고리ID(common_codes)'); - $table->json('attributes')->nullable()->comment('동적 속성'); - $table->string('description')->nullable()->comment('설명'); - $table->tinyInteger('is_active')->default(1)->comment('사용여부'); - $table->unsignedBigInteger('created_by')->comment('생성자(회원PK)'); - $table->unsignedBigInteger('updated_by')->nullable()->comment('수정자(회원PK)'); - $table->timestamps(); - $table->softDeletes(); - - $table->unique(['tenant_id', 'code']); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('products'); - } -}; diff --git a/database/migrations/2025_07_26_051643_create_role_menu_permissions_table.php b/database/migrations/2025_07_26_051643_create_role_menu_permissions_table.php deleted file mode 100644 index 984257d..0000000 --- a/database/migrations/2025_07_26_051643_create_role_menu_permissions_table.php +++ /dev/null @@ -1,36 +0,0 @@ -bigIncrements('id')->comment('PK: 역할-메뉴 권한 ID'); - $table->unsignedBigInteger('role_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('등록/수정/삭제 권한'); - $table->boolean('export')->default(false)->comment('다운로드 권한'); - $table->boolean('approve')->default(false)->comment('승인/반려 권한'); - $table->timestamps(); - - $table->unique(['role_id', 'menu_id']); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('role_menu_permissions'); - } -}; diff --git a/database/migrations/2025_07_26_051643_create_roles_table.php b/database/migrations/2025_07_26_051643_create_roles_table.php deleted file mode 100644 index abaf342..0000000 --- a/database/migrations/2025_07_26_051643_create_roles_table.php +++ /dev/null @@ -1,33 +0,0 @@ -bigIncrements('id')->comment('PK: 역할 ID'); - $table->unsignedBigInteger('tenant_id')->index(); - $table->string('name', 50)->comment('역할명'); - $table->string('description')->nullable()->comment('설명'); - $table->timestamps(); - $table->softDeletes()->comment('삭제일시(소프트삭제)'); - - $table->unique(['tenant_id', 'name'], 'uk_roles_tenant_name'); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('roles'); - } -}; diff --git a/database/migrations/2025_07_26_051643_create_sessions_table.php b/database/migrations/2025_07_26_051643_create_sessions_table.php deleted file mode 100644 index 4b8efda..0000000 --- a/database/migrations/2025_07_26_051643_create_sessions_table.php +++ /dev/null @@ -1,31 +0,0 @@ -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'); - } -}; diff --git a/database/migrations/2025_07_26_051643_create_subscriptions_table.php b/database/migrations/2025_07_26_051643_create_subscriptions_table.php deleted file mode 100644 index b2d9e26..0000000 --- a/database/migrations/2025_07_26_051643_create_subscriptions_table.php +++ /dev/null @@ -1,33 +0,0 @@ -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 등)'); - $table->timestamps(); - $table->softDeletes(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('subscriptions'); - } -}; diff --git a/database/migrations/2025_07_26_051643_create_tenants_table.php b/database/migrations/2025_07_26_051643_create_tenants_table.php deleted file mode 100644 index 71c58e5..0000000 --- a/database/migrations/2025_07_26_051643_create_tenants_table.php +++ /dev/null @@ -1,49 +0,0 @@ -bigIncrements('id')->comment('PK'); - $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')->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'); - $table->integer('max_users')->default(10)->comment('최대 사용자 수'); - $table->dateTime('trial_ends_at')->nullable()->comment('트라이얼 종료일'); - $table->dateTime('expires_at')->nullable()->comment('계약 만료일'); - $table->dateTime('last_paid_at')->nullable()->comment('마지막 결제일'); - $table->string('billing_tp_code', 20)->default('monthly')->comment('결제 주기(monthly,yearly)'); - $table->timestamps(); - $table->softDeletes(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('tenants'); - } -}; diff --git a/database/migrations/2025_07_26_051643_create_user_menu_permissions_table.php b/database/migrations/2025_07_26_051643_create_user_menu_permissions_table.php deleted file mode 100644 index 5139e22..0000000 --- a/database/migrations/2025_07_26_051643_create_user_menu_permissions_table.php +++ /dev/null @@ -1,36 +0,0 @@ -bigIncrements('id')->comment('PK: 사용자-메뉴 권한 ID'); - $table->unsignedBigInteger('user_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('등록/수정/삭제 권한'); - $table->boolean('export')->default(false)->comment('다운로드 권한'); - $table->boolean('approve')->default(false)->comment('승인/반려 권한'); - $table->timestamps(); - - $table->unique(['user_id', 'menu_id']); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('user_menu_permissions'); - } -}; diff --git a/database/migrations/2025_07_26_051643_create_user_roles_table.php b/database/migrations/2025_07_26_051643_create_user_roles_table.php deleted file mode 100644 index daf926e..0000000 --- a/database/migrations/2025_07_26_051643_create_user_roles_table.php +++ /dev/null @@ -1,34 +0,0 @@ -bigIncrements('id')->comment('PK: 회원별 역할 매핑 ID'); - $table->unsignedBigInteger('user_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'); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('user_roles'); - } -}; diff --git a/database/migrations/2025_07_26_051643_create_user_tenants_table.php b/database/migrations/2025_07_26_051643_create_user_tenants_table.php deleted file mode 100644 index a725d5e..0000000 --- a/database/migrations/2025_07_26_051643_create_user_tenants_table.php +++ /dev/null @@ -1,35 +0,0 @@ -bigIncrements('id')->comment('PK: 회원-테넌트 소속 ID'); - $table->unsignedBigInteger('user_id')->comment('FK: 회원ID'); - $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'); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('user_tenants'); - } -}; diff --git a/database/migrations/2025_07_26_051643_create_users_table.php b/database/migrations/2025_07_26_051643_create_users_table.php deleted file mode 100644 index 014270e..0000000 --- a/database/migrations/2025_07_26_051643_create_users_table.php +++ /dev/null @@ -1,42 +0,0 @@ -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'); - } -}; diff --git a/database/migrations/2025_07_26_051646_add_foreign_keys_to_board_comments_table.php b/database/migrations/2025_07_26_051646_add_foreign_keys_to_board_comments_table.php deleted file mode 100644 index b67781d..0000000 --- a/database/migrations/2025_07_26_051646_add_foreign_keys_to_board_comments_table.php +++ /dev/null @@ -1,34 +0,0 @@ -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'); - }); - } -}; diff --git a/database/migrations/2025_07_26_051646_add_foreign_keys_to_board_files_table.php b/database/migrations/2025_07_26_051646_add_foreign_keys_to_board_files_table.php deleted file mode 100644 index 445dbbc..0000000 --- a/database/migrations/2025_07_26_051646_add_foreign_keys_to_board_files_table.php +++ /dev/null @@ -1,28 +0,0 @@ -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'); - }); - } -}; diff --git a/database/migrations/2025_07_26_051646_add_foreign_keys_to_board_settings_table.php b/database/migrations/2025_07_26_051646_add_foreign_keys_to_board_settings_table.php deleted file mode 100644 index 33384b5..0000000 --- a/database/migrations/2025_07_26_051646_add_foreign_keys_to_board_settings_table.php +++ /dev/null @@ -1,28 +0,0 @@ -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'); - }); - } -}; diff --git a/database/migrations/2025_07_26_051646_add_foreign_keys_to_boards_table.php b/database/migrations/2025_07_26_051646_add_foreign_keys_to_boards_table.php deleted file mode 100644 index 0952994..0000000 --- a/database/migrations/2025_07_26_051646_add_foreign_keys_to_boards_table.php +++ /dev/null @@ -1,28 +0,0 @@ -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'); - }); - } -}; diff --git a/database/migrations/2025_07_26_051646_add_foreign_keys_to_bom_items_table.php b/database/migrations/2025_07_26_051646_add_foreign_keys_to_bom_items_table.php deleted file mode 100644 index c704bdd..0000000 --- a/database/migrations/2025_07_26_051646_add_foreign_keys_to_bom_items_table.php +++ /dev/null @@ -1,30 +0,0 @@ -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'); - }); - } -}; diff --git a/database/migrations/2025_07_26_051646_add_foreign_keys_to_boms_table.php b/database/migrations/2025_07_26_051646_add_foreign_keys_to_boms_table.php deleted file mode 100644 index dd69b68..0000000 --- a/database/migrations/2025_07_26_051646_add_foreign_keys_to_boms_table.php +++ /dev/null @@ -1,32 +0,0 @@ -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'); - }); - } -}; diff --git a/database/migrations/2025_07_26_051646_add_foreign_keys_to_common_codes_table.php b/database/migrations/2025_07_26_051646_add_foreign_keys_to_common_codes_table.php deleted file mode 100644 index b2e2b9a..0000000 --- a/database/migrations/2025_07_26_051646_add_foreign_keys_to_common_codes_table.php +++ /dev/null @@ -1,28 +0,0 @@ -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'); - }); - } -}; diff --git a/database/migrations/2025_07_26_051646_add_foreign_keys_to_parts_table.php b/database/migrations/2025_07_26_051646_add_foreign_keys_to_parts_table.php deleted file mode 100644 index 5b9fa50..0000000 --- a/database/migrations/2025_07_26_051646_add_foreign_keys_to_parts_table.php +++ /dev/null @@ -1,30 +0,0 @@ -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'); - }); - } -}; diff --git a/database/migrations/2025_07_26_051646_add_foreign_keys_to_payments_table.php b/database/migrations/2025_07_26_051646_add_foreign_keys_to_payments_table.php deleted file mode 100644 index 5b011be..0000000 --- a/database/migrations/2025_07_26_051646_add_foreign_keys_to_payments_table.php +++ /dev/null @@ -1,28 +0,0 @@ -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'); - }); - } -}; diff --git a/database/migrations/2025_07_26_051646_add_foreign_keys_to_post_custom_field_values_table.php b/database/migrations/2025_07_26_051646_add_foreign_keys_to_post_custom_field_values_table.php deleted file mode 100644 index cf168ea..0000000 --- a/database/migrations/2025_07_26_051646_add_foreign_keys_to_post_custom_field_values_table.php +++ /dev/null @@ -1,30 +0,0 @@ -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'); - }); - } -}; diff --git a/database/migrations/2025_07_26_051646_add_foreign_keys_to_posts_table.php b/database/migrations/2025_07_26_051646_add_foreign_keys_to_posts_table.php deleted file mode 100644 index 19b87aa..0000000 --- a/database/migrations/2025_07_26_051646_add_foreign_keys_to_posts_table.php +++ /dev/null @@ -1,30 +0,0 @@ -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'); - }); - } -}; diff --git a/database/migrations/2025_07_26_051646_add_foreign_keys_to_products_table.php b/database/migrations/2025_07_26_051646_add_foreign_keys_to_products_table.php deleted file mode 100644 index a961e5c..0000000 --- a/database/migrations/2025_07_26_051646_add_foreign_keys_to_products_table.php +++ /dev/null @@ -1,28 +0,0 @@ -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'); - }); - } -}; diff --git a/database/migrations/2025_07_26_051646_add_foreign_keys_to_role_menu_permissions_table.php b/database/migrations/2025_07_26_051646_add_foreign_keys_to_role_menu_permissions_table.php deleted file mode 100644 index 83e619b..0000000 --- a/database/migrations/2025_07_26_051646_add_foreign_keys_to_role_menu_permissions_table.php +++ /dev/null @@ -1,30 +0,0 @@ -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'); - }); - } -}; diff --git a/database/migrations/2025_07_26_051646_add_foreign_keys_to_subscriptions_table.php b/database/migrations/2025_07_26_051646_add_foreign_keys_to_subscriptions_table.php deleted file mode 100644 index c6c2fac..0000000 --- a/database/migrations/2025_07_26_051646_add_foreign_keys_to_subscriptions_table.php +++ /dev/null @@ -1,30 +0,0 @@ -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'); - }); - } -}; diff --git a/database/migrations/2025_07_26_051646_add_foreign_keys_to_user_menu_permissions_table.php b/database/migrations/2025_07_26_051646_add_foreign_keys_to_user_menu_permissions_table.php deleted file mode 100644 index 970b89f..0000000 --- a/database/migrations/2025_07_26_051646_add_foreign_keys_to_user_menu_permissions_table.php +++ /dev/null @@ -1,30 +0,0 @@ -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'); - }); - } -}; diff --git a/database/migrations/2025_07_26_051646_add_foreign_keys_to_user_roles_table.php b/database/migrations/2025_07_26_051646_add_foreign_keys_to_user_roles_table.php deleted file mode 100644 index a280255..0000000 --- a/database/migrations/2025_07_26_051646_add_foreign_keys_to_user_roles_table.php +++ /dev/null @@ -1,32 +0,0 @@ -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'); - }); - } -}; diff --git a/database/migrations/2025_07_26_051646_add_foreign_keys_to_user_tenants_table.php b/database/migrations/2025_07_26_051646_add_foreign_keys_to_user_tenants_table.php deleted file mode 100644 index 2cf136d..0000000 --- a/database/migrations/2025_07_26_051646_add_foreign_keys_to_user_tenants_table.php +++ /dev/null @@ -1,30 +0,0 @@ -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'); - }); - } -}; diff --git a/database/migrations/2025_07_28_183746_create_materials_table.php b/database/migrations/2025_07_28_183746_create_materials_table.php deleted file mode 100644 index 4741ca4..0000000 --- a/database/migrations/2025_07_28_183746_create_materials_table.php +++ /dev/null @@ -1,31 +0,0 @@ -id()->comment('자재 PK'); - $table->unsignedBigInteger('tenant_id')->comment('테넌트ID'); - $table->string('name', 100)->comment('자재명(품명)'); - $table->string('specification', 100)->nullable()->comment('규격'); - $table->string('material_code', 50)->unique()->comment('자재코드'); - $table->string('unit', 10)->comment('단위'); - $table->char('is_inspection', 1)->default('N')->comment('검사대상 여부(Y/N)'); - $table->text('search_tag')->nullable()->comment('검색 태그'); - $table->text('remarks')->nullable()->comment('비고'); - $table->unsignedBigInteger('created_by')->comment('생성자(회원PK)'); - $table->unsignedBigInteger('updated_by')->nullable()->comment('수정자(회원PK)'); - $table->timestamps(); - $table->softDeletes(); - }); - } - public function down(): void - { - Schema::dropIfExists('materials'); - } -}; diff --git a/database/migrations/2025_07_28_183747_create_lot_sales_table.php b/database/migrations/2025_07_28_183747_create_lot_sales_table.php deleted file mode 100644 index 9d20ceb..0000000 --- a/database/migrations/2025_07_28_183747_create_lot_sales_table.php +++ /dev/null @@ -1,30 +0,0 @@ -id()->comment('로트별 판매기록 PK'); - $table->unsignedBigInteger('tenant_id')->comment('테넌트ID'); - $table->unsignedBigInteger('lot_id')->comment('로트ID'); - $table->date('sale_date')->comment('판매일'); - $table->string('author', 50)->nullable()->comment('등록자'); - $table->string('workplace_name', 60)->nullable()->comment('작업장명'); - $table->text('remarks')->nullable()->comment('비고'); - $table->unsignedBigInteger('created_by')->comment('생성자(회원PK)'); - $table->unsignedBigInteger('updated_by')->nullable()->comment('수정자(회원PK)'); - $table->timestamps(); - $table->softDeletes(); - $table->index('lot_id', 'idx_sales_lot_id'); - }); - } - public function down(): void - { - Schema::dropIfExists('lot_sales'); - } -}; diff --git a/database/migrations/2025_07_28_183747_create_lots_table.php b/database/migrations/2025_07_28_183747_create_lots_table.php deleted file mode 100644 index 82e1a2c..0000000 --- a/database/migrations/2025_07_28_183747_create_lots_table.php +++ /dev/null @@ -1,34 +0,0 @@ -id()->comment('로트관리 PK'); - $table->unsignedBigInteger('tenant_id')->comment('테넌트ID'); - $table->string('lot_number', 30)->unique()->comment('로트번호'); - $table->unsignedBigInteger('material_id')->comment('자재ID'); - $table->string('specification', 100)->nullable()->comment('규격'); - $table->string('length', 20)->nullable()->comment('길이'); - $table->integer('quantity')->comment('수량'); - $table->string('raw_lot_number', 30)->nullable()->comment('원자재 로트번호'); - $table->string('fabric_lot', 30)->nullable()->comment('원단 로트'); - $table->string('author', 50)->nullable()->comment('작성자'); - $table->text('remarks')->nullable()->comment('비고'); - $table->unsignedBigInteger('created_by')->comment('생성자(회원PK)'); - $table->unsignedBigInteger('updated_by')->nullable()->comment('수정자(회원PK)'); - $table->timestamps(); - $table->softDeletes(); - $table->index('material_id', 'idx_lots_material_id'); - }); - } - public function down(): void - { - Schema::dropIfExists('lots'); - } -}; diff --git a/database/migrations/2025_07_28_183747_create_material_inspection_items_table.php b/database/migrations/2025_07_28_183747_create_material_inspection_items_table.php deleted file mode 100644 index 08987db..0000000 --- a/database/migrations/2025_07_28_183747_create_material_inspection_items_table.php +++ /dev/null @@ -1,27 +0,0 @@ -id()->comment('검사항목 PK'); - $table->unsignedBigInteger('inspection_id')->comment('수입검사ID'); - $table->string('item_name', 100)->comment('검사항목명'); - $table->char('is_checked', 1)->default('N')->comment('체크여부(Y/N)'); - $table->unsignedBigInteger('created_by')->comment('생성자(회원PK)'); - $table->unsignedBigInteger('updated_by')->nullable()->comment('수정자(회원PK)'); - $table->timestamps(); - $table->softDeletes(); - $table->index('inspection_id', 'idx_items_inspection_id'); - }); - } - public function down(): void - { - Schema::dropIfExists('material_inspection_items'); - } -}; diff --git a/database/migrations/2025_07_28_183747_create_material_inspections_table.php b/database/migrations/2025_07_28_183747_create_material_inspections_table.php deleted file mode 100644 index 45ea7f7..0000000 --- a/database/migrations/2025_07_28_183747_create_material_inspections_table.php +++ /dev/null @@ -1,33 +0,0 @@ -id()->comment('수입검사 PK'); - $table->unsignedBigInteger('receipt_id')->comment('자재입고ID'); - $table->unsignedBigInteger('tenant_id')->comment('테넌트ID'); - $table->date('inspection_date')->comment('검사일자'); - $table->string('inspector_name', 50)->nullable()->comment('검사자'); - $table->string('approver_name', 50)->nullable()->comment('결재자'); - $table->string('judgment_code', 30)->comment('종합판정(common_codes)'); - $table->string('status_code', 30)->comment('상태코드(common_codes)'); - $table->text('result_file_path')->nullable()->comment('성적서 PDF 경로'); - $table->text('remarks')->nullable()->comment('비고'); - $table->unsignedBigInteger('created_by')->comment('생성자(회원PK)'); - $table->unsignedBigInteger('updated_by')->nullable()->comment('수정자(회원PK)'); - $table->timestamps(); - $table->softDeletes(); - $table->index('receipt_id', 'idx_inspections_receipt_id'); - }); - } - public function down(): void - { - Schema::dropIfExists('material_inspections'); - } -}; diff --git a/database/migrations/2025_07_28_183747_create_material_receipts_table.php b/database/migrations/2025_07_28_183747_create_material_receipts_table.php deleted file mode 100644 index f2c3318..0000000 --- a/database/migrations/2025_07_28_183747_create_material_receipts_table.php +++ /dev/null @@ -1,38 +0,0 @@ -id()->comment('자재입고 PK'); - $table->unsignedBigInteger('material_id')->comment('자재ID'); - $table->unsignedBigInteger('tenant_id')->comment('테넌트ID'); - $table->date('receipt_date')->comment('입고일'); - $table->string('lot_number', 30)->comment('로트번호'); - $table->decimal('received_qty', 12, 2)->comment('입고수량'); - $table->string('unit', 10)->comment('단위'); - $table->string('supplier_name', 100)->nullable()->comment('납품업체'); - $table->string('manufacturer_name', 100)->nullable()->comment('제조사'); - $table->decimal('purchase_price_excl_vat', 12, 2)->nullable()->comment('구매단가(부가세 제외)'); - $table->decimal('weight_kg', 12, 2)->nullable()->comment('총 무게(kg)'); - $table->string('status_code', 30)->comment('상태코드(common_codes)'); - $table->char('is_inspection', 1)->default('N')->comment('검사대상 여부(Y/N)'); - $table->date('inspection_date')->nullable()->comment('검사일자'); - $table->text('remarks')->nullable()->comment('비고'); - $table->unsignedBigInteger('created_by')->comment('생성자(회원PK)'); - $table->unsignedBigInteger('updated_by')->nullable()->comment('수정자(회원PK)'); - $table->timestamps(); - $table->softDeletes(); - $table->index('material_id', 'idx_receipts_material_id'); - }); - } - public function down(): void - { - Schema::dropIfExists('material_receipts'); - } -}; diff --git a/database/migrations/2025_07_28_183748_add_foreign_keys_to_material_receipts.php b/database/migrations/2025_07_28_183748_add_foreign_keys_to_material_receipts.php deleted file mode 100644 index 84bf02a..0000000 --- a/database/migrations/2025_07_28_183748_add_foreign_keys_to_material_receipts.php +++ /dev/null @@ -1,45 +0,0 @@ -foreign('material_id', 'fk_receipts_material_id')->references('id')->on('materials'); - }); - Schema::table('material_inspections', function (Blueprint $table) { - $table->foreign('receipt_id', 'fk_inspections_receipt_id')->references('id')->on('material_receipts')->onDelete('cascade'); - }); - Schema::table('material_inspection_items', function (Blueprint $table) { - $table->foreign('inspection_id', 'fk_items_inspection_id')->references('id')->on('material_inspections')->onDelete('cascade'); - }); - Schema::table('lots', function (Blueprint $table) { - $table->foreign('material_id', 'fk_lots_material_id')->references('id')->on('materials'); - }); - Schema::table('lot_sales', function (Blueprint $table) { - $table->foreign('lot_id', 'fk_sales_lot_id')->references('id')->on('lots'); - }); - } - public function down(): void - { - Schema::table('material_receipts', function (Blueprint $table) { - $table->dropForeign('fk_receipts_material_id'); - }); - Schema::table('material_inspections', function (Blueprint $table) { - $table->dropForeign('fk_inspections_receipt_id'); - }); - Schema::table('material_inspection_items', function (Blueprint $table) { - $table->dropForeign('fk_items_inspection_id'); - }); - Schema::table('lots', function (Blueprint $table) { - $table->dropForeign('fk_lots_material_id'); - }); - Schema::table('lot_sales', function (Blueprint $table) { - $table->dropForeign('fk_sales_lot_id'); - }); - } -}; diff --git a/database/schema/mysql-schema.sql b/database/schema/mysql-schema.sql new file mode 100644 index 0000000..d74cd62 --- /dev/null +++ b/database/schema/mysql-schema.sql @@ -0,0 +1,1277 @@ +/*M!999999\- enable the sandbox mode */ +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; +DROP TABLE IF EXISTS `api_keys`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `api_keys` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT, + `key` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, + `description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `is_active` tinyint(1) NOT NULL DEFAULT '1', + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `api_keys_key_unique` (`key`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `board_comments`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `board_comments` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '댓글 고유번호', + `post_id` bigint unsigned NOT NULL COMMENT '게시글 고유번호', + `tenant_id` bigint unsigned NOT NULL COMMENT '테넌트 고유번호', + `user_id` bigint unsigned DEFAULT NULL COMMENT '작성자 고유번호', + `parent_id` bigint unsigned DEFAULT NULL COMMENT '상위 댓글ID(대댓글)', + `content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '댓글 내용', + `ip_address` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '작성자 IP', + `status` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'active' COMMENT '상태', + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + `deleted_at` timestamp NULL DEFAULT NULL COMMENT '삭제일시(Soft Delete)', + PRIMARY KEY (`id`), + KEY `board_comments_post_id_foreign` (`post_id`), + KEY `board_comments_tenant_id_foreign` (`tenant_id`), + KEY `board_comments_user_id_foreign` (`user_id`), + KEY `board_comments_parent_id_foreign` (`parent_id`), + CONSTRAINT `board_comments_parent_id_foreign` FOREIGN KEY (`parent_id`) REFERENCES `board_comments` (`id`), + CONSTRAINT `board_comments_post_id_foreign` FOREIGN KEY (`post_id`) REFERENCES `posts` (`id`) ON DELETE CASCADE, + CONSTRAINT `board_comments_tenant_id_foreign` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`), + CONSTRAINT `board_comments_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `board_files`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `board_files` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '첨부파일 고유번호', + `post_id` bigint unsigned NOT NULL COMMENT '게시글 고유번호', + `file_path` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '저장경로', + `file_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '원본 파일명', + `file_size` int NOT NULL COMMENT '파일 크기(Byte)', + `file_type` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '파일 MIME 타입', + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `board_files_post_id_foreign` (`post_id`), + CONSTRAINT `board_files_post_id_foreign` FOREIGN KEY (`post_id`) REFERENCES `posts` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `board_settings`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `board_settings` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '커스텀필드 고유번호', + `board_id` bigint unsigned NOT NULL COMMENT '게시판 고유번호', + `name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '필드명', + `field_key` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '필드키', + `field_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '필드유형', + `field_meta` json DEFAULT NULL COMMENT '필드메타', + `is_required` tinyint(1) NOT NULL DEFAULT '0' COMMENT '필수여부', + `sort_order` int NOT NULL DEFAULT '0' COMMENT '정렬순서', + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `board_settings_board_id_field_key_unique` (`board_id`,`field_key`), + CONSTRAINT `board_settings_board_id_foreign` FOREIGN KEY (`board_id`) REFERENCES `boards` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `boards`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `boards` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '게시판 고유번호', + `tenant_id` bigint unsigned NOT NULL COMMENT '테넌트 고유번호', + `board_code` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '게시판 코드', + `name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '게시판 이름', + `description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '게시판 설명', + `editor_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'wysiwyg' COMMENT '에디터 유형', + `allow_files` tinyint(1) NOT NULL DEFAULT '1' COMMENT '파일첨부 허용 여부', + `max_file_count` int NOT NULL DEFAULT '5' COMMENT '최대 첨부파일 수', + `max_file_size` int NOT NULL DEFAULT '20480' COMMENT '최대 첨부파일 크기(KB)', + `extra_settings` json DEFAULT NULL COMMENT '추가 설정(JSON)', + `is_active` tinyint(1) NOT NULL DEFAULT '1' COMMENT '활성화 여부', + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `boards_tenant_id_board_code_unique` (`tenant_id`,`board_code`), + CONSTRAINT `boards_tenant_id_foreign` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `bom_items`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `bom_items` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT, + `tenant_id` bigint unsigned NOT NULL COMMENT '멀티테넌시', + `bom_id` bigint unsigned NOT NULL COMMENT 'BOM ID', + `parent_id` bigint unsigned DEFAULT NULL COMMENT '상위 BOM Item', + `item_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'item 종류: part, product, bom', + `ref_id` bigint unsigned NOT NULL COMMENT '참조 ID', + `quantity` decimal(18,4) NOT NULL DEFAULT '1.0000', + `attributes` json DEFAULT NULL COMMENT '동적 속성', + `sort_order` int NOT NULL DEFAULT '0', + `created_by` bigint unsigned NOT NULL COMMENT '생성자(회원PK)', + `updated_by` bigint unsigned DEFAULT NULL COMMENT '수정자(회원PK)', + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + `deleted_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `bom_items_bom_id_foreign` (`bom_id`), + KEY `bom_items_parent_id_foreign` (`parent_id`), + CONSTRAINT `bom_items_bom_id_foreign` FOREIGN KEY (`bom_id`) REFERENCES `boms` (`id`), + CONSTRAINT `bom_items_parent_id_foreign` FOREIGN KEY (`parent_id`) REFERENCES `bom_items` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `boms`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `boms` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT, + `tenant_id` bigint unsigned NOT NULL COMMENT '멀티테넌시', + `product_id` bigint unsigned NOT NULL COMMENT '제품ID', + `code` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'BOM코드', + `name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'BOM명', + `category_id` bigint unsigned NOT NULL COMMENT '카테고리ID(common_codes)', + `attributes` json DEFAULT NULL COMMENT '동적 속성', + `description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '설명', + `is_default` tinyint(1) NOT NULL DEFAULT '0' COMMENT '기본BOM여부', + `is_active` tinyint(1) NOT NULL DEFAULT '1' COMMENT '사용여부', + `image_file_id` bigint unsigned DEFAULT NULL COMMENT '첨부파일ID', + `created_by` bigint unsigned NOT NULL COMMENT '생성자(회원PK)', + `updated_by` bigint unsigned DEFAULT NULL COMMENT '수정자(회원PK)', + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + `deleted_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `boms_tenant_id_product_id_code_unique` (`tenant_id`,`product_id`,`code`), + KEY `boms_product_id_foreign` (`product_id`), + KEY `boms_category_id_foreign` (`category_id`), + KEY `boms_image_file_id_foreign` (`image_file_id`), + CONSTRAINT `boms_category_id_foreign` FOREIGN KEY (`category_id`) REFERENCES `common_codes` (`id`), + CONSTRAINT `boms_image_file_id_foreign` FOREIGN KEY (`image_file_id`) REFERENCES `files` (`id`), + CONSTRAINT `boms_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `cache`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `cache` ( + `key` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, + `value` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, + `expiration` int NOT NULL, + PRIMARY KEY (`key`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `cache_locks`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `cache_locks` ( + `key` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, + `owner` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, + `expiration` int NOT NULL, + PRIMARY KEY (`key`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `categories`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `categories` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '카테고리 PK', + `tenant_id` bigint unsigned NOT NULL COMMENT '테넌트(고객사) ID', + `parent_id` bigint unsigned DEFAULT NULL COMMENT '상위 카테고리ID(NULL=최상위)', + `code` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '카테고리 코드(영문, 고유)', + `name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '카테고리명', + `is_active` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'Y' COMMENT '사용여부(Y/N)', + `sort_order` int NOT NULL DEFAULT '1' COMMENT '정렬순서', + `description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '비고', + `created_by` bigint unsigned DEFAULT NULL COMMENT '등록자(관리자ID)', + `updated_by` bigint unsigned DEFAULT NULL COMMENT '수정자(관리자ID)', + `deleted_by` bigint unsigned DEFAULT NULL COMMENT '삭제자(관리자ID)', + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + `deleted_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `uq_tenant_code` (`tenant_id`,`code`), + KEY `idx_tenant` (`tenant_id`), + KEY `idx_parent_id` (`parent_id`), + CONSTRAINT `fk_category_parent` FOREIGN KEY (`parent_id`) REFERENCES `categories` (`id`) ON DELETE SET NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='제품 카테고리(계층형, 멀티테넌시)'; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `category_fields`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `category_fields` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '항목 PK', + `tenant_id` bigint unsigned NOT NULL COMMENT '테넌트(고객사) ID', + `category_id` bigint unsigned NOT NULL COMMENT '카테고리ID', + `field_key` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '항목키(영문, 고유)', + `field_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '항목명', + `field_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '입력유형(text, number, select 등)', + `is_required` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'N' COMMENT '필수여부(Y/N)', + `sort_order` int NOT NULL DEFAULT '1' COMMENT '정렬순서', + `default_value` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '기본값', + `options` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '선택지(콤보박스, JSON)', + `description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '비고', + `created_by` bigint unsigned DEFAULT NULL COMMENT '등록자(관리자ID)', + `updated_by` bigint unsigned DEFAULT NULL COMMENT '수정자(관리자ID)', + `deleted_by` bigint unsigned DEFAULT NULL COMMENT '삭제자(관리자ID)', + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + `deleted_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `idx_tenant` (`tenant_id`), + KEY `idx_category_id` (`category_id`), + CONSTRAINT `fk_category_fields_category` FOREIGN KEY (`category_id`) REFERENCES `categories` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='카테고리별 항목(필드) 정의(멀티테넌시)'; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `category_logs`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `category_logs` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT, + `category_id` bigint unsigned NOT NULL COMMENT '카테고리ID', + `tenant_id` bigint unsigned NOT NULL, + `action` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '동작(등록,수정,삭제: insert, update, delete)', + `changed_by` bigint unsigned DEFAULT NULL COMMENT '작업자ID', + `changed_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '작업시각', + `before_json` json DEFAULT NULL COMMENT '변경 전 데이터(스냅샷)', + `after_json` json DEFAULT NULL COMMENT '변경 후 데이터(스냅샷)', + `remarks` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '비고', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='카테고리 변경 이력 로그'; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `category_templates`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `category_templates` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '템플릿 PK', + `tenant_id` bigint unsigned NOT NULL COMMENT '테넌트(고객사) ID', + `category_id` bigint unsigned NOT NULL COMMENT '카테고리ID', + `version_no` int NOT NULL COMMENT '버전번호', + `template_json` json NOT NULL COMMENT '항목구조 스냅샷', + `applied_at` timestamp NOT NULL COMMENT '적용일시', + `created_by` bigint unsigned DEFAULT NULL COMMENT '등록자(관리자ID)', + `updated_by` bigint unsigned DEFAULT NULL COMMENT '수정자(관리자ID)', + `deleted_by` bigint unsigned DEFAULT NULL COMMENT '삭제자(관리자ID)', + `remarks` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '비고', + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `uq_tenant_category_version` (`tenant_id`,`category_id`,`version_no`), + KEY `idx_tenant` (`tenant_id`), + KEY `idx_category_id` (`category_id`), + CONSTRAINT `fk_category_templates_category` FOREIGN KEY (`category_id`) REFERENCES `categories` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='카테고리 템플릿 버전관리(멀티테넌시)'; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `clients`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `clients` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'PK', + `tenant_id` bigint unsigned NOT NULL COMMENT '테넌트ID', + `client_code` varchar(50) NOT NULL COMMENT '거래처코드', + `name` varchar(100) NOT NULL COMMENT '거래처명', + `contact_person` varchar(50) DEFAULT NULL COMMENT '담당자', + `phone` varchar(30) DEFAULT NULL COMMENT '연락처', + `email` varchar(80) DEFAULT NULL COMMENT '이메일', + `address` varchar(255) DEFAULT NULL COMMENT '주소', + `is_active` char(1) DEFAULT 'Y' COMMENT '사용여부', + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `uq_client_code` (`client_code`), + KEY `idx_tenant_id` (`tenant_id`), + CONSTRAINT `fk_clients_tenant` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='거래처/발주처 마스터'; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `common_codes`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `common_codes` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT, + `tenant_id` bigint unsigned DEFAULT NULL COMMENT '멀티테넌시', + `code_group` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'category' COMMENT '코드 그룹', + `code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '코드값', + `name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '이름', + `parent_id` bigint unsigned DEFAULT NULL COMMENT '상위코드ID(트리)', + `attributes` json DEFAULT NULL COMMENT '동적 속성', + `description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '설명', + `is_active` tinyint NOT NULL DEFAULT '1' COMMENT '사용여부', + `sort_order` int NOT NULL DEFAULT '0' COMMENT '정렬순서', + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + `deleted_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `common_codes_tenant_id_code_group_code_unique` (`tenant_id`,`code_group`,`code`), + KEY `common_codes_parent_id_foreign` (`parent_id`), + CONSTRAINT `common_codes_parent_id_foreign` FOREIGN KEY (`parent_id`) REFERENCES `common_codes` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='공통코드 트리'; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `failed_jobs`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `failed_jobs` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT, + `uuid` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, + `connection` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, + `queue` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, + `payload` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, + `exception` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, + `failed_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`), + UNIQUE KEY `failed_jobs_uuid_unique` (`uuid`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `files`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `files` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT, + `tenant_id` bigint unsigned NOT NULL COMMENT '멀티테넌시', + `file_path` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '저장경로', + `original_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '원본 파일명', + `file_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '저장 파일명 (난수)', + `file_name_old` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, + `file_size` int DEFAULT NULL, + `mime_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `fileable_id` bigint unsigned NOT NULL COMMENT 'Polymorphic - 연결된 모델의 PK', + `fileable_type` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'Polymorphic - 연결된 모델 클래스명', + `uploaded_by` bigint unsigned DEFAULT NULL COMMENT '업로더 사용자 ID', + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + `deleted_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `job_batches`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `job_batches` ( + `id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, + `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, + `total_jobs` int NOT NULL, + `pending_jobs` int NOT NULL, + `failed_jobs` int NOT NULL, + `failed_job_ids` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, + `options` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci, + `cancelled_at` int DEFAULT NULL, + `created_at` int NOT NULL, + `finished_at` int DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `jobs`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `jobs` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT, + `queue` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, + `payload` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, + `attempts` tinyint unsigned NOT NULL, + `reserved_at` int unsigned DEFAULT NULL, + `available_at` int unsigned NOT NULL, + `created_at` int unsigned NOT NULL, + PRIMARY KEY (`id`), + KEY `jobs_queue_index` (`queue`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `log_session`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `log_session` ( + `id` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, + `ip_address` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '0' COMMENT 'IP 주소', + `user_agent` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'User Agent', + `last_activity` int NOT NULL DEFAULT '0' COMMENT '마지막 활동 시간', + `timestamp` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '타임스탬프', + `data` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '세션 데이터', + PRIMARY KEY (`id`), + KEY `last_activity_idx` (`last_activity`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='세션정보 저장 테이블'; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `lot_sales`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `lot_sales` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '로트별 판매기록 PK', + `tenant_id` bigint unsigned NOT NULL COMMENT '테넌트ID', + `lot_id` bigint unsigned NOT NULL COMMENT '로트ID', + `sale_date` date NOT NULL COMMENT '판매일', + `author` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '등록자', + `workplace_name` varchar(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '작업장명', + `remarks` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '비고', + `created_by` bigint unsigned NOT NULL COMMENT '생성자(회원PK)', + `updated_by` bigint unsigned DEFAULT NULL COMMENT '수정자(회원PK)', + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + `deleted_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `idx_sales_lot_id` (`lot_id`), + CONSTRAINT `fk_sales_lot_id` FOREIGN KEY (`lot_id`) REFERENCES `lots` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `lots`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `lots` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '로트관리 PK', + `tenant_id` bigint unsigned NOT NULL COMMENT '테넌트ID', + `lot_number` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '로트번호', + `material_id` bigint unsigned NOT NULL COMMENT '자재ID', + `specification` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '규격', + `length` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '길이', + `quantity` int NOT NULL COMMENT '수량', + `raw_lot_number` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '원자재 로트번호', + `fabric_lot` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '원단 로트', + `author` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '작성자', + `remarks` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '비고', + `created_by` bigint unsigned NOT NULL COMMENT '생성자(회원PK)', + `updated_by` bigint unsigned DEFAULT NULL COMMENT '수정자(회원PK)', + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + `deleted_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `lots_lot_number_unique` (`lot_number`), + KEY `idx_lots_material_id` (`material_id`), + CONSTRAINT `fk_lots_material_id` FOREIGN KEY (`material_id`) REFERENCES `materials` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `main_request_flows`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `main_request_flows` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT, + `main_request_id` bigint unsigned NOT NULL COMMENT '메인 업무 ID', + `flowable_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '업무타입(estimate,order,purchase,work 등)', + `flowable_id` bigint unsigned NOT NULL COMMENT '해당 업무 PK', + `status_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '상태코드', + `action` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '액션(등록/수정/승인 등)', + `content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '변경내역/메모', + `actor_id` bigint unsigned DEFAULT NULL COMMENT '처리자(회원PK)', + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `fk_mrf_main_request` (`main_request_id`), + CONSTRAINT `fk_mrf_main_request` FOREIGN KEY (`main_request_id`) REFERENCES `main_requests` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='업무 전체/상세 흐름 이력(폴리모픽)'; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `main_requests`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `main_requests` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT, + `tenant_id` bigint unsigned NOT NULL COMMENT '테넌트ID', + `status_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '업무진행상태(견적/수주/발주/작업 등)', + `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '요약/비고', + `created_by` bigint unsigned NOT NULL, + `updated_by` bigint unsigned DEFAULT NULL, + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + `deleted_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='업무 마스터(관계/흐름 중심)'; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `material_inspection_items`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `material_inspection_items` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '검사항목 PK', + `inspection_id` bigint unsigned NOT NULL COMMENT '수입검사ID', + `item_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '검사항목명', + `is_checked` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'N' COMMENT '체크여부(Y/N)', + `created_by` bigint unsigned NOT NULL COMMENT '생성자(회원PK)', + `updated_by` bigint unsigned DEFAULT NULL COMMENT '수정자(회원PK)', + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + `deleted_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `idx_items_inspection_id` (`inspection_id`), + CONSTRAINT `fk_items_inspection_id` FOREIGN KEY (`inspection_id`) REFERENCES `material_inspections` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `material_inspections`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `material_inspections` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '수입검사 PK', + `receipt_id` bigint unsigned NOT NULL COMMENT '자재입고ID', + `tenant_id` bigint unsigned NOT NULL COMMENT '테넌트ID', + `inspection_date` date NOT NULL COMMENT '검사일자', + `inspector_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '검사자', + `approver_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '결재자', + `judgment_code` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '종합판정(common_codes)', + `status_code` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '상태코드(common_codes)', + `result_file_path` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '성적서 PDF 경로', + `remarks` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '비고', + `created_by` bigint unsigned NOT NULL COMMENT '생성자(회원PK)', + `updated_by` bigint unsigned DEFAULT NULL COMMENT '수정자(회원PK)', + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + `deleted_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `idx_inspections_receipt_id` (`receipt_id`), + CONSTRAINT `fk_inspections_receipt_id` FOREIGN KEY (`receipt_id`) REFERENCES `material_receipts` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `material_receipts`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `material_receipts` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '자재입고 PK', + `material_id` bigint unsigned NOT NULL COMMENT '자재ID', + `tenant_id` bigint unsigned NOT NULL COMMENT '테넌트ID', + `receipt_date` date NOT NULL COMMENT '입고일', + `lot_number` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '로트번호', + `received_qty` decimal(12,2) NOT NULL COMMENT '입고수량', + `unit` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '단위', + `supplier_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '납품업체', + `manufacturer_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '제조사', + `purchase_price_excl_vat` decimal(12,2) DEFAULT NULL COMMENT '구매단가(부가세 제외)', + `weight_kg` decimal(12,2) DEFAULT NULL COMMENT '총 무게(kg)', + `status_code` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '상태코드(common_codes)', + `is_inspection` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'N' COMMENT '검사대상 여부(Y/N)', + `inspection_date` date DEFAULT NULL COMMENT '검사일자', + `remarks` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '비고', + `created_by` bigint unsigned NOT NULL COMMENT '생성자(회원PK)', + `updated_by` bigint unsigned DEFAULT NULL COMMENT '수정자(회원PK)', + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + `deleted_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `idx_receipts_material_id` (`material_id`), + CONSTRAINT `fk_receipts_material_id` FOREIGN KEY (`material_id`) REFERENCES `materials` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `materials`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `materials` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '자재 PK', + `tenant_id` bigint unsigned NOT NULL COMMENT '테넌트ID', + `name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '자재명(품명)', + `specification` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '규격', + `material_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '자재코드', + `unit` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '단위', + `is_inspection` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'N' COMMENT '검사대상 여부(Y/N)', + `search_tag` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '검색 태그', + `remarks` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '비고', + `created_by` bigint unsigned NOT NULL COMMENT '생성자(회원PK)', + `updated_by` bigint unsigned DEFAULT NULL COMMENT '수정자(회원PK)', + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + `deleted_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `materials_material_code_unique` (`material_code`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `menus`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `menus` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'PK: 메뉴 ID', + `tenant_id` bigint unsigned DEFAULT NULL COMMENT 'FK: 테넌트 ID(null=공용메뉴)', + `parent_id` bigint unsigned DEFAULT NULL COMMENT '상위 메뉴 ID', + `name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '메뉴명', + `url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '메뉴 URL', + `is_active` tinyint(1) NOT NULL DEFAULT '1' COMMENT '활성여부(1=활성,0=비활성)', + `sort_order` int NOT NULL DEFAULT '0' COMMENT '정렬순서', + `hidden` tinyint(1) NOT NULL DEFAULT '0' COMMENT '숨김여부', + `is_external` tinyint(1) NOT NULL DEFAULT '0' COMMENT '외부링크여부', + `external_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '외부링크 URL', + `icon` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '아이콘명', + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `menus_tenant_id_index` (`tenant_id`), + KEY `menus_parent_id_index` (`parent_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `migrations`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `migrations` ( + `id` int unsigned NOT NULL AUTO_INCREMENT, + `migration` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, + `batch` int NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `model_has_permissions`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `model_has_permissions` ( + `permission_id` bigint unsigned NOT NULL, + `model_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, + `model_id` bigint unsigned NOT NULL, + PRIMARY KEY (`permission_id`,`model_id`,`model_type`), + KEY `model_has_permissions_model_id_model_type_index` (`model_id`,`model_type`), + CONSTRAINT `model_has_permissions_permission_id_foreign` FOREIGN KEY (`permission_id`) REFERENCES `permissions` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `model_has_roles`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `model_has_roles` ( + `role_id` bigint unsigned NOT NULL, + `model_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, + `model_id` bigint unsigned NOT NULL, + PRIMARY KEY (`role_id`,`model_id`,`model_type`), + KEY `model_has_roles_model_id_model_type_index` (`model_id`,`model_type`), + CONSTRAINT `model_has_roles_role_id_foreign` FOREIGN KEY (`role_id`) REFERENCES `roles` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `order_histories`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `order_histories` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'PK', + `tenant_id` bigint unsigned NOT NULL COMMENT '테넌트ID', + `order_id` bigint unsigned NOT NULL COMMENT 'orders.id', + `history_type` varchar(20) NOT NULL COMMENT '이력구분(수정/견적/발주/메모)', + `content` text NOT NULL COMMENT '내용', + `created_by` bigint unsigned DEFAULT NULL COMMENT '작성자', + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `idx_tenant_id` (`tenant_id`), + KEY `idx_order_id` (`order_id`), + KEY `fk_order_histories_created_by` (`created_by`), + CONSTRAINT `fk_order_histories_created_by` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`), + CONSTRAINT `fk_order_histories_order` FOREIGN KEY (`order_id`) REFERENCES `orders` (`id`) ON DELETE CASCADE, + CONSTRAINT `fk_order_histories_tenant` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='주문 이력/메모'; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `order_item_components`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `order_item_components` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'PK', + `tenant_id` bigint unsigned NOT NULL COMMENT '테넌트ID', + `order_item_id` bigint unsigned NOT NULL COMMENT 'order_items.id', + `component_type` varchar(20) NOT NULL COMMENT '타입(material/product/part/bom)', + `component_id` bigint unsigned NOT NULL COMMENT '타입별 PK', + `quantity` decimal(12,2) NOT NULL DEFAULT '1.00' COMMENT '필요수량', + `unit` varchar(10) DEFAULT NULL, + `price` decimal(12,2) DEFAULT NULL, + `remarks` varchar(100) DEFAULT NULL, + `created_by` bigint unsigned NOT NULL COMMENT '생성자', + `updated_by` bigint unsigned DEFAULT NULL COMMENT '수정자', + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + `deleted_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `idx_tenant_id` (`tenant_id`), + KEY `idx_order_item_id` (`order_item_id`), + KEY `idx_component` (`component_type`,`component_id`), + CONSTRAINT `fk_oic_order_item` FOREIGN KEY (`order_item_id`) REFERENCES `order_items` (`id`) ON DELETE CASCADE, + CONSTRAINT `fk_oic_tenant` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='주문항목 투입구성(자재/제품/부품 등)'; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `order_items`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `order_items` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'PK', + `tenant_id` bigint unsigned NOT NULL COMMENT '테넌트ID', + `order_id` bigint unsigned NOT NULL COMMENT 'orders.id', + `serial_no` int NOT NULL COMMENT '일련번호', + `product_id` bigint unsigned DEFAULT NULL COMMENT '제품ID', + `quantity` int NOT NULL DEFAULT '1' COMMENT '수량', + `status_code` varchar(20) DEFAULT NULL COMMENT '상세상태 코드', + `design_code` varchar(100) DEFAULT NULL COMMENT '설계도면/부호', + `remarks` text COMMENT '비고', + `attributes` json DEFAULT NULL COMMENT '확장필드', + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + `deleted_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `idx_tenant_id` (`tenant_id`), + KEY `idx_order_id` (`order_id`), + KEY `idx_product_id` (`product_id`), + CONSTRAINT `fk_order_items_order` FOREIGN KEY (`order_id`) REFERENCES `orders` (`id`) ON DELETE CASCADE, + CONSTRAINT `fk_order_items_product` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`), + CONSTRAINT `fk_order_items_tenant` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='주문 상세(제품/오픈사이즈 등)'; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `order_versions`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `order_versions` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT, + `tenant_id` bigint unsigned NOT NULL, + `order_id` bigint unsigned NOT NULL, + `version_no` int NOT NULL, + `version_type` varchar(20) NOT NULL, + `status_code` varchar(20) NOT NULL, + `changed_fields` json DEFAULT NULL COMMENT '변경된 필드만 저장(전/후값)', + `changed_by` bigint unsigned DEFAULT NULL, + `changed_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `change_note` varchar(255) DEFAULT NULL COMMENT '변경사유/메모', + PRIMARY KEY (`id`), + KEY `idx_order_id` (`order_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='주문상태/중요필드 버전 히스토리'; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `orders`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `orders` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'PK', + `tenant_id` bigint unsigned NOT NULL COMMENT '테넌트ID', + `order_no` varchar(30) NOT NULL COMMENT '주문/견적번호', + `order_type_code` varchar(20) NOT NULL COMMENT '업무구분(견적/수주/발주 등)', + `status_code` varchar(20) NOT NULL COMMENT '진행상태 코드', + `category_code` varchar(20) DEFAULT NULL COMMENT '대분류(스크린/철재 등)', + `product_id` bigint unsigned DEFAULT NULL COMMENT '대표 제품ID', + `received_at` datetime DEFAULT NULL COMMENT '접수일', + `writer_id` bigint unsigned DEFAULT NULL COMMENT '작성자', + `client_id` bigint unsigned DEFAULT NULL COMMENT '거래처ID', + `client_contact` varchar(50) DEFAULT NULL COMMENT '담당자 연락처', + `site_name` varchar(100) DEFAULT NULL COMMENT '현장명', + `quantity` int DEFAULT NULL COMMENT '전체 수량', + `delivery_date` date DEFAULT NULL COMMENT '출고일', + `delivery_method_code` varchar(20) DEFAULT NULL COMMENT '운송방법', + `memo` text COMMENT '비고', + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + `deleted_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `idx_tenant_id` (`tenant_id`), + KEY `idx_client_id` (`client_id`), + KEY `idx_product_id` (`product_id`), + KEY `fk_orders_writer` (`writer_id`), + CONSTRAINT `fk_orders_client` FOREIGN KEY (`client_id`) REFERENCES `clients` (`id`), + CONSTRAINT `fk_orders_product` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`), + CONSTRAINT `fk_orders_tenant` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`), + CONSTRAINT `fk_orders_writer` FOREIGN KEY (`writer_id`) REFERENCES `users` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='수주/견적/발주 메인'; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `parts`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `parts` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT, + `tenant_id` bigint unsigned NOT NULL COMMENT '멀티테넌시', + `code` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '부품코드', + `name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '부품명', + `category_id` bigint unsigned NOT NULL COMMENT '카테고리ID(common_codes)', + `part_type_id` bigint unsigned DEFAULT NULL COMMENT '부품타입ID(common_codes)', + `unit` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '단위', + `attributes` json DEFAULT NULL COMMENT '동적 속성', + `description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '설명', + `is_active` tinyint NOT NULL DEFAULT '1' COMMENT '사용여부', + `created_by` bigint unsigned NOT NULL COMMENT '생성자(회원PK)', + `updated_by` bigint unsigned DEFAULT NULL COMMENT '수정자(회원PK)', + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + `deleted_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `parts_tenant_id_code_unique` (`tenant_id`,`code`), + KEY `parts_category_id_foreign` (`category_id`), + KEY `parts_part_type_id_foreign` (`part_type_id`), + CONSTRAINT `parts_category_id_foreign` FOREIGN KEY (`category_id`) REFERENCES `common_codes` (`id`), + CONSTRAINT `parts_part_type_id_foreign` FOREIGN KEY (`part_type_id`) REFERENCES `common_codes` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `password_reset_tokens`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `password_reset_tokens` ( + `email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, + `token` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, + `created_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`email`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `payments`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `payments` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'PK', + `subscription_id` bigint unsigned NOT NULL, + `amount` decimal(12,2) NOT NULL COMMENT '결제금액', + `payment_method` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '결제수단', + `transaction_id` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'PG 거래ID', + `paid_at` datetime NOT NULL COMMENT '결제일시', + `status` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'paid' COMMENT '결제상태(paid, failed 등)', + `memo` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '비고', + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + `deleted_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `payments_subscription_id_foreign` (`subscription_id`), + CONSTRAINT `payments_subscription_id_foreign` FOREIGN KEY (`subscription_id`) REFERENCES `subscriptions` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `permissions`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `permissions` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT, + `tenant_id` bigint unsigned DEFAULT NULL COMMENT '테넌트(고객사) ID', + `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, + `guard_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `permissions_name_guard_name_unique` (`name`,`guard_name`), + KEY `permissions_tenant_id_index` (`tenant_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `personal_access_tokens`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `personal_access_tokens` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT, + `tokenable_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, + `tokenable_id` bigint unsigned NOT NULL, + `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, + `token` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, + `abilities` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci, + `last_used_at` timestamp NULL DEFAULT NULL, + `expires_at` timestamp NULL DEFAULT NULL, + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `personal_access_tokens_token_unique` (`token`), + KEY `personal_access_tokens_tokenable_type_tokenable_id_index` (`tokenable_type`,`tokenable_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `plans`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `plans` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'PK', + `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '플랜명', + `code` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '플랜 코드', + `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '설명', + `price` decimal(12,2) NOT NULL COMMENT '월 요금', + `billing_cycle` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'monthly' COMMENT '청구 주기', + `features` json DEFAULT NULL COMMENT '제공 기능/제한사항', + `is_active` tinyint(1) NOT NULL DEFAULT '1' COMMENT '사용여부', + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + `deleted_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `plans_code_unique` (`code`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `post_custom_field_values`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `post_custom_field_values` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '필드값 고유번호', + `post_id` bigint unsigned NOT NULL COMMENT '게시글 고유번호', + `field_id` bigint unsigned NOT NULL COMMENT '커스텀필드 고유번호', + `value` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '필드값', + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `post_custom_field_values_post_id_field_id_unique` (`post_id`,`field_id`), + KEY `post_custom_field_values_field_id_foreign` (`field_id`), + CONSTRAINT `post_custom_field_values_field_id_foreign` FOREIGN KEY (`field_id`) REFERENCES `board_settings` (`id`), + CONSTRAINT `post_custom_field_values_post_id_foreign` FOREIGN KEY (`post_id`) REFERENCES `posts` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `posts`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `posts` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '게시글 고유번호', + `tenant_id` bigint unsigned NOT NULL COMMENT '테넌트 고유번호', + `board_id` bigint unsigned NOT NULL COMMENT '게시판 고유번호', + `user_id` bigint unsigned DEFAULT NULL COMMENT '작성자 고유번호', + `title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '제목', + `content` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '내용', + `editor_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'wysiwyg' COMMENT '에디터 유형', + `ip_address` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '작성자 IP', + `is_notice` tinyint(1) NOT NULL DEFAULT '0' COMMENT '공지글 여부', + `is_secret` tinyint(1) NOT NULL DEFAULT '0' COMMENT '비밀글 여부', + `views` int NOT NULL DEFAULT '0' COMMENT '조회수', + `status` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'active' COMMENT '상태', + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + `deleted_at` timestamp NULL DEFAULT NULL COMMENT '삭제일시(Soft Delete)', + PRIMARY KEY (`id`), + KEY `posts_tenant_id_board_id_index` (`tenant_id`,`board_id`), + KEY `posts_board_id_foreign` (`board_id`), + KEY `posts_status_index` (`status`), + CONSTRAINT `posts_board_id_foreign` FOREIGN KEY (`board_id`) REFERENCES `boards` (`id`), + CONSTRAINT `posts_tenant_id_foreign` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `price_histories`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `price_histories` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT, + `tenant_id` bigint unsigned NOT NULL COMMENT '멀티테넌시', + `item_type_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '대상구분(product/part/bom 등, code_group=price_item_type)', + `item_id` bigint unsigned NOT NULL COMMENT '대상ID', + `price_type_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '단가구분(default/20%up/10%discount 등, code_group=price_type)', + `price` decimal(18,4) NOT NULL COMMENT '단가', + `started_at` date NOT NULL, + `ended_at` date DEFAULT NULL, + `created_by` bigint unsigned NOT NULL COMMENT '생성자(회원PK)', + `updated_by` bigint unsigned DEFAULT NULL COMMENT '수정자(회원PK)', + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + `deleted_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `idx_price_histories_main` (`tenant_id`,`item_type_code`,`item_id`,`started_at`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `products`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `products` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT, + `tenant_id` bigint unsigned NOT NULL COMMENT '멀티테넌시', + `code` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '제품코드', + `name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '제품명', + `category_id` bigint unsigned NOT NULL COMMENT '카테고리ID(common_codes)', + `attributes` json DEFAULT NULL COMMENT '동적 속성', + `description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '설명', + `is_active` tinyint NOT NULL DEFAULT '1' COMMENT '사용여부', + `created_by` bigint unsigned NOT NULL COMMENT '생성자(회원PK)', + `updated_by` bigint unsigned DEFAULT NULL COMMENT '수정자(회원PK)', + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + `deleted_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `products_tenant_id_code_unique` (`tenant_id`,`code`), + KEY `products_category_id_foreign` (`category_id`), + CONSTRAINT `products_category_id_foreign` FOREIGN KEY (`category_id`) REFERENCES `common_codes` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `role_has_permissions`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `role_has_permissions` ( + `permission_id` bigint unsigned NOT NULL, + `role_id` bigint unsigned NOT NULL, + PRIMARY KEY (`permission_id`,`role_id`), + KEY `role_has_permissions_role_id_foreign` (`role_id`), + CONSTRAINT `role_has_permissions_permission_id_foreign` FOREIGN KEY (`permission_id`) REFERENCES `permissions` (`id`) ON DELETE CASCADE, + CONSTRAINT `role_has_permissions_role_id_foreign` FOREIGN KEY (`role_id`) REFERENCES `roles` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `role_menu_permissions`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `role_menu_permissions` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'PK: 역할-메뉴 권한 ID', + `role_id` bigint unsigned NOT NULL COMMENT 'FK: 역할 ID', + `menu_id` bigint unsigned NOT NULL COMMENT 'FK: 메뉴 ID', + `access` tinyint(1) NOT NULL DEFAULT '0' COMMENT '메뉴 접근 권한', + `read` tinyint(1) NOT NULL DEFAULT '0' COMMENT '조회 권한', + `write` tinyint(1) NOT NULL DEFAULT '0' COMMENT '등록/수정/삭제 권한', + `export` tinyint(1) NOT NULL DEFAULT '0' COMMENT '다운로드 권한', + `approve` tinyint(1) NOT NULL DEFAULT '0' COMMENT '승인/반려 권한', + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `role_menu_permissions_role_id_menu_id_unique` (`role_id`,`menu_id`), + KEY `role_menu_permissions_menu_id_foreign` (`menu_id`), + CONSTRAINT `role_menu_permissions_menu_id_foreign` FOREIGN KEY (`menu_id`) REFERENCES `menus` (`id`) ON DELETE CASCADE, + CONSTRAINT `role_menu_permissions_role_id_foreign` FOREIGN KEY (`role_id`) REFERENCES `roles` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `roles`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `roles` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'PK: 역할 ID', + `tenant_id` bigint unsigned NOT NULL, + `name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '역할명', + `description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '설명', + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + `deleted_at` timestamp NULL DEFAULT NULL COMMENT '삭제일시(소프트삭제)', + PRIMARY KEY (`id`), + UNIQUE KEY `uk_roles_tenant_name` (`tenant_id`,`name`), + KEY `roles_tenant_id_index` (`tenant_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `sessions`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `sessions` ( + `id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, + `user_id` bigint unsigned DEFAULT NULL, + `ip_address` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `user_agent` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci, + `payload` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, + `last_activity` int NOT NULL, + PRIMARY KEY (`id`), + KEY `sessions_user_id_index` (`user_id`), + KEY `sessions_last_activity_index` (`last_activity`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `setting_field_defs`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `setting_field_defs` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT, + `field_key` varchar(64) NOT NULL COMMENT '예: department, position, job_title', + `label` varchar(100) NOT NULL COMMENT '표시 라벨', + `data_type` varchar(20) NOT NULL COMMENT 'string|number|date|file|bigint 등', + `input_type` varchar(30) NOT NULL COMMENT 'text|select|textarea|date|file|select_user 등', + `option_source` varchar(20) DEFAULT NULL COMMENT 'static|tenant_list|table_ref', + `option_payload` json DEFAULT NULL COMMENT 'option_source에 따른 설정(JSON)', + `comment` text, + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + `storage_area` varchar(50) NOT NULL DEFAULT 'tenant_profile' COMMENT 'users: users 컬럼, tenant_profile: tenant_user_profiles 컬럼, tenant_profile_json: json_extra에 key로 저장', + `storage_key` varchar(64) DEFAULT NULL COMMENT '저장할 컬럼명(users/tenant_user_profiles) 또는 json key(tenant_profile_json)', + `is_core` tinyint(1) NOT NULL DEFAULT '0' COMMENT '1=코어 필드(이름/이메일 등), 테넌트가 비활성 불가', + PRIMARY KEY (`id`), + UNIQUE KEY `field_key` (`field_key`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='전역 필드 사전'; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `subscriptions`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `subscriptions` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'PK', + `tenant_id` bigint unsigned NOT NULL, + `plan_id` bigint unsigned NOT NULL, + `started_at` date NOT NULL COMMENT '구독 시작일', + `ended_at` date DEFAULT NULL COMMENT '구독 종료일(해지시)', + `status` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'active' COMMENT '상태(active, canceled, expired 등)', + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + `deleted_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `subscriptions_tenant_id_foreign` (`tenant_id`), + KEY `subscriptions_plan_id_foreign` (`plan_id`), + CONSTRAINT `subscriptions_plan_id_foreign` FOREIGN KEY (`plan_id`) REFERENCES `plans` (`id`), + CONSTRAINT `subscriptions_tenant_id_foreign` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `taggables`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `taggables` ( + `tag_id` bigint unsigned NOT NULL COMMENT '태그 ID (tags.id FK)', + `taggable_id` bigint unsigned NOT NULL COMMENT '태그가 연결된 엔티티의 PK', + `taggable_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '엔티티 타입(모델명)', + `created_at` timestamp NULL DEFAULT NULL COMMENT '연결일시', + PRIMARY KEY (`tag_id`,`taggable_id`,`taggable_type`), + CONSTRAINT `taggables_ibfk_1` FOREIGN KEY (`tag_id`) REFERENCES `tags` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='태그-대상(제품, 부품, 자재, BOM 등) 다형성 연결'; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `tags`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `tags` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'PK', + `tenant_id` bigint unsigned NOT NULL COMMENT '테넌트 ID', + `name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '태그명', + `created_at` timestamp NULL DEFAULT NULL COMMENT '생성일시', + `updated_at` timestamp NULL DEFAULT NULL COMMENT '수정일시', + PRIMARY KEY (`id`), + UNIQUE KEY `uk_tenant_tag_name` (`tenant_id`,`name`), + CONSTRAINT `tags_ibfk_1` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='테넌트별 태그 목록'; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `tenant_field_settings`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `tenant_field_settings` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT, + `tenant_id` bigint unsigned NOT NULL, + `field_key` varchar(64) NOT NULL, + `enabled` tinyint(1) NOT NULL DEFAULT '1' COMMENT '노출 여부', + `required` tinyint(1) NOT NULL DEFAULT '0' COMMENT '필수 여부', + `sort_order` int NOT NULL DEFAULT '0' COMMENT '정렬', + `option_group_id` bigint unsigned DEFAULT NULL COMMENT 'tenant_option_groups.id (option_source=tenant_list일 경우)', + `code_group` varchar(50) DEFAULT NULL COMMENT 'common_codes 참조 그룹', + PRIMARY KEY (`id`), + UNIQUE KEY `uk_tenant_field` (`tenant_id`,`field_key`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='테넌트별 회원필드 구동 설정'; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `tenant_option_groups`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `tenant_option_groups` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT, + `tenant_id` bigint unsigned NOT NULL, + `group_key` varchar(64) NOT NULL COMMENT '예: position, job_title, work_location 등', + `name` varchar(100) NOT NULL COMMENT '테넌트 화면 표기용 이름', + `description` varchar(255) DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `uk_tenant_group` (`tenant_id`,`group_key`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='테넌트 관리형 옵션 그룹'; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `tenant_option_values`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `tenant_option_values` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT, + `group_id` bigint unsigned NOT NULL, + `value_key` varchar(64) NOT NULL COMMENT '내부키 (영문/코드)', + `value_label` varchar(100) NOT NULL COMMENT '화면 라벨', + `sort_order` int NOT NULL DEFAULT '0', + `is_active` tinyint(1) NOT NULL DEFAULT '1', + PRIMARY KEY (`id`), + UNIQUE KEY `uk_group_value` (`group_id`,`value_key`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='옵션 그룹의 항목 값'; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `tenant_user_profiles`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `tenant_user_profiles` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT, + `tenant_id` bigint unsigned NOT NULL COMMENT '테넌트', + `user_id` bigint unsigned NOT NULL COMMENT 'users.id', + `department_id` bigint unsigned DEFAULT NULL COMMENT '부서(조직 트리 또는 common_codes)', + `position_key` varchar(64) DEFAULT NULL COMMENT '직급 key (tenant_option_values.value_key or common_codes.code)', + `job_title_key` varchar(64) DEFAULT NULL COMMENT '직책 key', + `work_location_key` varchar(64) DEFAULT NULL COMMENT '근무지 key', + `employment_type_key` varchar(64) DEFAULT NULL COMMENT '고용형태 key', + `manager_user_id` bigint unsigned DEFAULT NULL COMMENT '직속상급자 users.id', + `json_extra` json DEFAULT NULL COMMENT '은행/계좌/주소/개인옵션 등 유연필드', + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + `profile_photo_path` varchar(2048) DEFAULT NULL COMMENT '테넌트 전용 아바타(없으면 전역 사용)', + `display_name` varchar(255) DEFAULT NULL COMMENT '테넌트 전용 표기명(없으면 users.name)', + PRIMARY KEY (`id`), + UNIQUE KEY `uk_tenant_user` (`tenant_id`,`user_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='테넌트별 회원 프로필'; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `tenants`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `tenants` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'PK', + `company_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '회사/조직명', + `code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '테넌트 코드', + `email` varchar(80) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '대표 이메일', + `phone` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '대표 전화번호', + `address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '주소', + `business_num` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '사업자등록번호(10자리)', + `corp_reg_no` varchar(13) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '법인등록번호(13자리, 법인만)', + `ceo_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '대표자명', + `homepage` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '홈페이지 주소', + `fax` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '팩스번호', + `logo` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '회사 로고 이미지 경로', + `admin_memo` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '관리자 메모/비고', + `options` json DEFAULT NULL COMMENT '회사별 옵션 정보(확장용 JSON)', + `tenant_st_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'trial' COMMENT '테넌트 상태(trial,active,suspended,cancelled)', + `plan_id` bigint unsigned DEFAULT NULL COMMENT '현재 요금제(플랜) ID', + `subscription_id` bigint unsigned DEFAULT NULL COMMENT '현재 구독 정보 ID', + `max_users` int NOT NULL DEFAULT '10' COMMENT '최대 사용자 수', + `trial_ends_at` datetime DEFAULT NULL COMMENT '트라이얼 종료일', + `expires_at` datetime DEFAULT NULL COMMENT '계약 만료일', + `last_paid_at` datetime DEFAULT NULL COMMENT '마지막 결제일', + `billing_tp_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'monthly' COMMENT '결제 주기(monthly,yearly)', + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + `deleted_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `tenants_code_unique` (`code`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `user_menu_permissions`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `user_menu_permissions` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'PK: 사용자-메뉴 권한 ID', + `user_id` bigint unsigned NOT NULL COMMENT 'FK: 사용자 ID', + `menu_id` bigint unsigned NOT NULL COMMENT 'FK: 메뉴 ID', + `access` tinyint(1) NOT NULL DEFAULT '0' COMMENT '메뉴 접근 권한', + `read` tinyint(1) NOT NULL DEFAULT '0' COMMENT '조회 권한', + `write` tinyint(1) NOT NULL DEFAULT '0' COMMENT '등록/수정/삭제 권한', + `export` tinyint(1) NOT NULL DEFAULT '0' COMMENT '다운로드 권한', + `approve` tinyint(1) NOT NULL DEFAULT '0' COMMENT '승인/반려 권한', + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `user_menu_permissions_user_id_menu_id_unique` (`user_id`,`menu_id`), + KEY `user_menu_permissions_menu_id_foreign` (`menu_id`), + CONSTRAINT `user_menu_permissions_menu_id_foreign` FOREIGN KEY (`menu_id`) REFERENCES `menus` (`id`) ON DELETE CASCADE, + CONSTRAINT `user_menu_permissions_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `user_roles`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `user_roles` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'PK: 회원별 역할 매핑 ID', + `user_id` bigint unsigned NOT NULL COMMENT 'FK: 회원ID', + `tenant_id` bigint unsigned NOT NULL COMMENT 'FK: 테넌트ID', + `role_id` bigint unsigned NOT NULL COMMENT 'FK: 역할ID', + `assigned_at` timestamp NULL DEFAULT NULL COMMENT '역할 할당일', + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + `deleted_at` timestamp NULL DEFAULT NULL COMMENT '삭제일시(소프트삭제)', + PRIMARY KEY (`id`), + UNIQUE KEY `uk_user_tenant_role` (`user_id`,`tenant_id`,`role_id`), + KEY `user_roles_tenant_id_foreign` (`tenant_id`), + KEY `user_roles_role_id_foreign` (`role_id`), + CONSTRAINT `user_roles_role_id_foreign` FOREIGN KEY (`role_id`) REFERENCES `roles` (`id`), + CONSTRAINT `user_roles_tenant_id_foreign` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`), + CONSTRAINT `user_roles_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `user_tenants`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `user_tenants` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'PK: 회원-테넌트 소속 ID', + `user_id` bigint unsigned NOT NULL COMMENT 'FK: 회원ID', + `tenant_id` bigint unsigned NOT NULL COMMENT 'FK: 테넌트ID', + `is_active` tinyint(1) NOT NULL DEFAULT '1' COMMENT '활성화 여부', + `joined_at` timestamp NULL DEFAULT NULL COMMENT '소속일시', + `left_at` timestamp NULL DEFAULT NULL COMMENT '탈퇴일시', + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + `deleted_at` timestamp NULL DEFAULT NULL COMMENT '삭제일시(소프트삭제)', + `is_default` tinyint(1) NOT NULL DEFAULT '0' COMMENT '기본 설정 여부', + PRIMARY KEY (`id`), + UNIQUE KEY `uk_user_tenant` (`user_id`,`tenant_id`), + KEY `user_tenants_tenant_id_foreign` (`tenant_id`), + CONSTRAINT `user_tenants_tenant_id_foreign` FOREIGN KEY (`tenant_id`) REFERENCES `tenants` (`id`), + CONSTRAINT `user_tenants_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `users`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `users` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT, + `user_id` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '회원 아이디', + `phone` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '회원 전화번호', + `options` json DEFAULT NULL COMMENT '회사별 옵션 정보(계좌, 사번 등)', + `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '회원 이름', + `email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '이메일', + `email_verified_at` timestamp NULL DEFAULT NULL, + `password` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '비밀번호', + `last_login_at` timestamp NULL DEFAULT NULL COMMENT '마지막 로그인 일시', + `two_factor_secret` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci, + `two_factor_recovery_codes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci, + `two_factor_confirmed_at` timestamp NULL DEFAULT NULL, + `remember_token` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '자동로그인 토큰', + `current_team_id` bigint unsigned DEFAULT NULL, + `profile_photo_path` varchar(2048) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '프로필 사진 경로', + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + `deleted_at` timestamp NULL DEFAULT NULL COMMENT '삭제일시(소프트삭제)', + PRIMARY KEY (`id`), + UNIQUE KEY `users_user_id_unique` (`user_id`), + UNIQUE KEY `uk_users_tenant_email` (`email`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;