UI: portal/header refinements, board index UX, and user settings
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
<?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::table('forums', function (Blueprint $table) {
|
||||
$table->softDeletes();
|
||||
$table->foreignId('deleted_by')->nullable()->constrained('users')->nullOnDelete();
|
||||
$table->index(['deleted_at', 'deleted_by'], 'idx_forums_deleted_meta');
|
||||
});
|
||||
|
||||
Schema::table('threads', function (Blueprint $table) {
|
||||
$table->softDeletes();
|
||||
$table->foreignId('deleted_by')->nullable()->constrained('users')->nullOnDelete();
|
||||
$table->index(['deleted_at', 'deleted_by'], 'idx_threads_deleted_meta');
|
||||
});
|
||||
|
||||
Schema::table('posts', function (Blueprint $table) {
|
||||
$table->softDeletes();
|
||||
$table->foreignId('deleted_by')->nullable()->constrained('users')->nullOnDelete();
|
||||
$table->index(['deleted_at', 'deleted_by'], 'idx_posts_deleted_meta');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('forums', function (Blueprint $table) {
|
||||
$table->dropIndex('idx_forums_deleted_meta');
|
||||
$table->dropConstrainedForeignId('deleted_by');
|
||||
$table->dropSoftDeletes();
|
||||
});
|
||||
|
||||
Schema::table('threads', function (Blueprint $table) {
|
||||
$table->dropIndex('idx_threads_deleted_meta');
|
||||
$table->dropConstrainedForeignId('deleted_by');
|
||||
$table->dropSoftDeletes();
|
||||
});
|
||||
|
||||
Schema::table('posts', function (Blueprint $table) {
|
||||
$table->dropIndex('idx_posts_deleted_meta');
|
||||
$table->dropConstrainedForeignId('deleted_by');
|
||||
$table->dropSoftDeletes();
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
DB::table('forums')
|
||||
->where('type', 'forum')
|
||||
->whereNull('parent_id')
|
||||
->update(['type' => 'category']);
|
||||
|
||||
$driver = Schema::getConnection()->getDriverName();
|
||||
if ($driver === 'mysql') {
|
||||
DB::statement('DROP TRIGGER IF EXISTS trg_forums_parent_insert');
|
||||
DB::statement('DROP TRIGGER IF EXISTS trg_forums_parent_update');
|
||||
DB::statement(<<<'SQL'
|
||||
CREATE TRIGGER trg_forums_parent_insert
|
||||
BEFORE INSERT ON forums
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
IF NEW.type = 'forum' AND NEW.parent_id IS NULL THEN
|
||||
SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'Forums must belong to a category.';
|
||||
END IF;
|
||||
END
|
||||
SQL);
|
||||
DB::statement(<<<'SQL'
|
||||
CREATE TRIGGER trg_forums_parent_update
|
||||
BEFORE UPDATE ON forums
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
IF NEW.type = 'forum' AND NEW.parent_id IS NULL THEN
|
||||
SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'Forums must belong to a category.';
|
||||
END IF;
|
||||
END
|
||||
SQL);
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
$driver = Schema::getConnection()->getDriverName();
|
||||
if ($driver === 'mysql') {
|
||||
DB::statement('DROP TRIGGER IF EXISTS trg_forums_parent_insert');
|
||||
DB::statement('DROP TRIGGER IF EXISTS trg_forums_parent_update');
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,25 @@
|
||||
<?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('user_settings', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('key');
|
||||
$table->json('value');
|
||||
$table->timestamps();
|
||||
$table->unique(['user_id', 'key'], 'uniq_user_settings_user_key');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('user_settings');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user