Gruppen-Plugin 1.0.0
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
commit
5bdfb8a082
49 changed files with 4679 additions and 0 deletions
117
database/migrations/2026_10_23_000001_create_gruppen_tables.php
Normal file
117
database/migrations/2026_10_23_000001_create_gruppen_tables.php
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
<?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('gruppen_groups', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name', 100);
|
||||
$table->string('slug', 120)->unique();
|
||||
$table->text('description')->nullable();
|
||||
$table->string('cover_path', 300)->nullable();
|
||||
// open: jeder tritt bei | closed: sichtbar, Beitritt auf Anfrage | secret: unsichtbar, nur auf Einladung
|
||||
$table->string('privacy', 10)->default('open');
|
||||
$table->foreignId('created_by')->nullable()->constrained('users')->nullOnDelete();
|
||||
$table->unsignedInteger('members_count')->default(0);
|
||||
$table->unsignedInteger('posts_count')->default(0);
|
||||
$table->timestamp('last_activity_at')->nullable()->index();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('gruppen_members', function (Blueprint $table) {
|
||||
$table->foreignId('group_id')->constrained('gruppen_groups')->cascadeOnDelete();
|
||||
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('role', 10)->default('member'); // admin | moderator | member
|
||||
$table->string('status', 10)->default('active'); // active | pending | invited
|
||||
$table->foreignId('invited_by')->nullable()->constrained('users')->nullOnDelete();
|
||||
$table->string('notify', 10)->default('all'); // all | off
|
||||
$table->timestamp('joined_at')->nullable();
|
||||
$table->timestamp('last_seen_at')->nullable();
|
||||
$table->timestamp('notified_at')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->primary(['group_id', 'user_id']);
|
||||
$table->index(['user_id', 'status']);
|
||||
});
|
||||
|
||||
Schema::create('gruppen_posts', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('group_id')->constrained('gruppen_groups')->cascadeOnDelete();
|
||||
$table->foreignId('user_id')->nullable()->constrained()->nullOnDelete();
|
||||
$table->text('body')->nullable();
|
||||
$table->json('poll')->nullable(); // { options: [...], multiple: bool }
|
||||
$table->timestamp('pinned_at')->nullable();
|
||||
$table->timestamp('edited_at')->nullable();
|
||||
$table->unsignedInteger('comments_count')->default(0);
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['group_id', 'created_at']);
|
||||
});
|
||||
|
||||
Schema::create('gruppen_attachments', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('post_id')->constrained('gruppen_posts')->cascadeOnDelete();
|
||||
$table->string('path', 300);
|
||||
$table->string('thumb_path', 300)->nullable();
|
||||
$table->string('name', 200);
|
||||
$table->string('mime', 100);
|
||||
$table->unsignedBigInteger('size');
|
||||
$table->unsignedInteger('width')->nullable();
|
||||
$table->unsignedInteger('height')->nullable();
|
||||
$table->unsignedSmallInteger('sort')->default(0);
|
||||
});
|
||||
|
||||
Schema::create('gruppen_poll_votes', function (Blueprint $table) {
|
||||
$table->foreignId('post_id')->constrained('gruppen_posts')->cascadeOnDelete();
|
||||
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
||||
$table->unsignedTinyInteger('option');
|
||||
|
||||
$table->primary(['post_id', 'user_id', 'option']);
|
||||
});
|
||||
|
||||
Schema::create('gruppen_comments', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('post_id')->constrained('gruppen_posts')->cascadeOnDelete();
|
||||
$table->foreignId('user_id')->nullable()->constrained()->nullOnDelete();
|
||||
$table->foreignId('parent_id')->nullable()->constrained('gruppen_comments')->cascadeOnDelete();
|
||||
$table->text('body');
|
||||
$table->timestamp('edited_at')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['post_id', 'id']);
|
||||
});
|
||||
|
||||
Schema::create('gruppen_reactions', function (Blueprint $table) {
|
||||
$table->foreignId('post_id')->constrained('gruppen_posts')->cascadeOnDelete();
|
||||
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('emoji', 16);
|
||||
|
||||
$table->primary(['post_id', 'user_id']);
|
||||
});
|
||||
|
||||
Schema::create('gruppen_reports', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('group_id')->constrained('gruppen_groups')->cascadeOnDelete();
|
||||
$table->foreignId('post_id')->constrained('gruppen_posts')->cascadeOnDelete();
|
||||
$table->foreignId('comment_id')->nullable()->constrained('gruppen_comments')->cascadeOnDelete();
|
||||
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('reason', 500);
|
||||
$table->timestamp('resolved_at')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['user_id', 'post_id', 'comment_id']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
foreach (['gruppen_reports', 'gruppen_reactions', 'gruppen_comments', 'gruppen_poll_votes', 'gruppen_attachments', 'gruppen_posts', 'gruppen_members', 'gruppen_groups'] as $table) {
|
||||
Schema::dropIfExists($table);
|
||||
}
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue