Files
sam-api/database/migrations/2025_07_23_132400_create_tenants_table.php
hskwon 609ac39ffb feat : 테이블 및 DB 마이그레이션 파일 추가
products
  - common_codes
  - parts
  - products
  - files
  - price_histories
  - boms
  - bom_items

  boards
  - boards
  - board_settings
  - posts
  - board_comments
  - board_files
  - post_custom_field_values

  permissions
  - menus
  - roles
  - user_menu_permissions
  - role_menu_permissions

  tenants
  - tenants
  - plans
  - subscriptions
  - payments
2025-07-23 15:41:01 +09:00

38 lines
1.9 KiB
PHP

<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void {
Schema::create('tenants', function (Blueprint $table) {
$table->bigIncrements('id')->comment('PK');
$table->string('name', 100)->comment('회사/조직명');
$table->string('code', 50)->unique()->comment('테넌트 코드');
$table->string('email', 80)->nullable()->comment('대표 이메일');
$table->string('phone', 20)->nullable()->comment('대표 전화번호');
$table->string('address', 255)->nullable()->comment('주소');
$table->string('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();
// FK는 필요시 추가
// $table->foreign('plan_id')->references('id')->on('plans');
// $table->foreign('subscription_id')->references('id')->on('subscriptions');
});
}
public function down(): void {
Schema::dropIfExists('tenants');
}
};