From 8935065af163f92a93892e323b164597390981e8 Mon Sep 17 00:00:00 2001 From: Gregor Klevze Date: Tue, 17 Feb 2026 17:19:01 +0100 Subject: [PATCH] feat(forum): add forum schema --- ...7_161455_create_forum_categories_table.php | 38 +++++++++++++++ ..._02_17_161456_create_forum_posts_table.php | 41 ++++++++++++++++ ...2_17_161456_create_forum_threads_table.php | 48 +++++++++++++++++++ ..._161458_create_forum_attachments_table.php | 40 ++++++++++++++++ 4 files changed, 167 insertions(+) create mode 100644 database/migrations/2026_02_17_161455_create_forum_categories_table.php create mode 100644 database/migrations/2026_02_17_161456_create_forum_posts_table.php create mode 100644 database/migrations/2026_02_17_161456_create_forum_threads_table.php create mode 100644 database/migrations/2026_02_17_161458_create_forum_attachments_table.php diff --git a/database/migrations/2026_02_17_161455_create_forum_categories_table.php b/database/migrations/2026_02_17_161455_create_forum_categories_table.php new file mode 100644 index 00000000..538e6fe8 --- /dev/null +++ b/database/migrations/2026_02_17_161455_create_forum_categories_table.php @@ -0,0 +1,38 @@ +id(); + + $table->string('name', 150); + $table->string('slug', 150)->unique(); + + $table->foreignId('parent_id') + ->nullable() + ->constrained('forum_categories') + ->nullOnDelete(); + + $table->integer('position')->default(0); + + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('forum_categories'); + } +}; diff --git a/database/migrations/2026_02_17_161456_create_forum_posts_table.php b/database/migrations/2026_02_17_161456_create_forum_posts_table.php new file mode 100644 index 00000000..6f63f119 --- /dev/null +++ b/database/migrations/2026_02_17_161456_create_forum_posts_table.php @@ -0,0 +1,41 @@ +id(); + + $table->foreignId('thread_id')->constrained('forum_threads')->cascadeOnDelete(); + $table->foreignId('user_id')->constrained()->cascadeOnDelete(); + + $table->longText('content'); + + $table->boolean('is_edited')->default(false); + $table->timestamp('edited_at')->nullable(); + + $table->timestamps(); + $table->softDeletes(); + + $table->index(['thread_id','created_at']); + }); + } + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('forum_posts'); + } +}; diff --git a/database/migrations/2026_02_17_161456_create_forum_threads_table.php b/database/migrations/2026_02_17_161456_create_forum_threads_table.php new file mode 100644 index 00000000..61013fed --- /dev/null +++ b/database/migrations/2026_02_17_161456_create_forum_threads_table.php @@ -0,0 +1,48 @@ +id(); + + $table->foreignId('category_id')->constrained()->cascadeOnDelete(); + $table->foreignId('user_id')->constrained()->cascadeOnDelete(); + + $table->string('title'); + $table->string('slug')->unique(); + + $table->longText('content'); + + $table->unsignedInteger('views')->default(0); + + $table->boolean('is_locked')->default(false); + $table->boolean('is_pinned')->default(false); + + $table->enum('visibility', ['public','members','staff'])->default('public'); + + $table->timestamp('last_post_at')->nullable(); + + $table->timestamps(); + $table->softDeletes(); + + $table->index(['category_id','last_post_at']); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('forum_threads'); + } +}; diff --git a/database/migrations/2026_02_17_161458_create_forum_attachments_table.php b/database/migrations/2026_02_17_161458_create_forum_attachments_table.php new file mode 100644 index 00000000..4f774444 --- /dev/null +++ b/database/migrations/2026_02_17_161458_create_forum_attachments_table.php @@ -0,0 +1,40 @@ +id(); + + $table->foreignId('post_id')->constrained('forum_posts')->cascadeOnDelete(); + + $table->string('file_path'); + $table->unsignedBigInteger('file_size'); + + $table->string('mime_type', 100)->nullable(); + + $table->unsignedInteger('width')->nullable(); + $table->unsignedInteger('height')->nullable(); + + $table->timestamps(); + + $table->index('post_id'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('forum_attachments'); + } +};