Files
sam-api/database/migrations/2025_07_23_132400_create_tenants_table.php

38 lines
1.9 KiB
PHP
Raw Normal View History

<?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');
}
};