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

36 lines
1.6 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('posts', function (Blueprint $table) {
$table->id()->comment('게시글 고유번호');
$table->unsignedBigInteger('tenant_id')->comment('테넌트 고유번호');
$table->unsignedBigInteger('board_id')->comment('게시판 고유번호');
$table->unsignedBigInteger('user_id')->nullable()->comment('작성자 고유번호');
$table->string('title', 255)->comment('제목');
$table->longText('content')->comment('내용');
$table->string('editor_type', 20)->default('wysiwyg')->comment('에디터 유형');
$table->string('ip_address', 45)->nullable()->comment('작성자 IP');
$table->boolean('is_notice')->default(false)->comment('공지글 여부');
$table->boolean('is_secret')->default(false)->comment('비밀글 여부');
$table->integer('views')->default(0)->comment('조회수');
$table->string('status', 20)->default('active')->comment('상태');
$table->timestamps();
$table->softDeletes()->comment('삭제일시(Soft Delete)');
$table->index(['tenant_id', 'board_id']);
$table->index('status');
$table->foreign('tenant_id')->references('id')->on('tenants');
$table->foreign('board_id')->references('id')->on('boards');
});
}
public function down(): void {
Schema::dropIfExists('posts');
}
};