mirror of
https://github.com/flarum/core.git
synced 2025-08-08 01:16:52 +02:00
perf: store message mentions for better performance (#4079)
This commit is contained in:
@@ -13,9 +13,9 @@ use Illuminate\Database\Schema\Blueprint;
|
||||
return Migration::createTable(
|
||||
'dialogs',
|
||||
function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->unsignedBigInteger('first_message_id')->nullable();
|
||||
$table->unsignedBigInteger('last_message_id')->nullable();
|
||||
$table->increments('id');
|
||||
$table->unsignedInteger('first_message_id')->nullable();
|
||||
$table->unsignedInteger('last_message_id')->nullable();
|
||||
$table->dateTime('last_message_at')->nullable();
|
||||
$table->unsignedInteger('last_message_user_id')->nullable();
|
||||
$table->foreign('last_message_user_id')->references('id')->on('users')->nullOnDelete();
|
||||
|
@@ -13,8 +13,9 @@ use Illuminate\Database\Schema\Blueprint;
|
||||
return Migration::createTable(
|
||||
'dialog_messages',
|
||||
function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->foreignId('dialog_id')->constrained()->cascadeOnDelete();
|
||||
$table->increments('id');
|
||||
$table->unsignedInteger('dialog_id');
|
||||
$table->foreign('dialog_id')->references('id')->on('dialogs')->cascadeOnDelete();
|
||||
$table->unsignedInteger('user_id')->nullable();
|
||||
$table->foreign('user_id')->references('id')->on('users')->cascadeOnDelete();
|
||||
$table->text('content');
|
||||
|
@@ -14,10 +14,11 @@ return Migration::createTable(
|
||||
'dialog_user',
|
||||
function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('dialog_id')->constrained()->cascadeOnDelete();
|
||||
$table->unsignedInteger('dialog_id');
|
||||
$table->foreign('dialog_id')->references('id')->on('dialogs')->cascadeOnDelete();
|
||||
$table->unsignedInteger('user_id');
|
||||
$table->dateTime('joined_at');
|
||||
$table->unsignedBigInteger('last_read_message_id')->default(0);
|
||||
$table->unsignedInteger('last_read_message_id')->default(0);
|
||||
$table->dateTime('last_read_at')->nullable();
|
||||
$table->foreign('user_id')->references('id')->on('users')->cascadeOnDelete();
|
||||
}
|
||||
|
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Flarum\Database\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
return Migration::createTable(
|
||||
'dialog_message_mentions_user',
|
||||
function (Blueprint $table) {
|
||||
$table->unsignedInteger('dialog_message_id');
|
||||
$table->unsignedInteger('mentions_user_id');
|
||||
$table->dateTime('created_at')->nullable()->useCurrent();
|
||||
|
||||
$table->primary(['dialog_message_id', 'mentions_user_id']);
|
||||
$table->foreign('dialog_message_id')->references('id')->on('dialog_messages')->cascadeOnDelete();
|
||||
$table->foreign('mentions_user_id')->references('id')->on('users')->cascadeOnDelete();
|
||||
}
|
||||
);
|
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Flarum\Database\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
return Migration::createTable(
|
||||
'dialog_message_mentions_post',
|
||||
function (Blueprint $table) {
|
||||
$table->unsignedInteger('dialog_message_id');
|
||||
$table->unsignedInteger('mentions_post_id');
|
||||
$table->dateTime('created_at')->nullable()->useCurrent();
|
||||
|
||||
$table->primary(['dialog_message_id', 'mentions_post_id']);
|
||||
$table->foreign('dialog_message_id')->references('id')->on('dialog_messages')->cascadeOnDelete();
|
||||
$table->foreign('mentions_post_id')->references('id')->on('posts')->cascadeOnDelete();
|
||||
}
|
||||
);
|
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Flarum\Database\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
return Migration::createTable(
|
||||
'dialog_message_mentions_group',
|
||||
function (Blueprint $table) {
|
||||
$table->unsignedInteger('dialog_message_id');
|
||||
$table->unsignedInteger('mentions_group_id');
|
||||
$table->dateTime('created_at')->nullable()->useCurrent();
|
||||
|
||||
$table->primary(['dialog_message_id', 'mentions_group_id']);
|
||||
$table->foreign('dialog_message_id')->references('id')->on('dialog_messages')->cascadeOnDelete();
|
||||
$table->foreign('mentions_group_id')->references('id')->on('groups')->cascadeOnDelete();
|
||||
}
|
||||
);
|
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Flarum\Database\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
return Migration::createTable(
|
||||
'dialog_message_mentions_tag',
|
||||
function (Blueprint $table) {
|
||||
$table->unsignedInteger('dialog_message_id');
|
||||
$table->unsignedInteger('mentions_tag_id');
|
||||
$table->dateTime('created_at')->nullable()->useCurrent();
|
||||
|
||||
$table->primary(['dialog_message_id', 'mentions_tag_id']);
|
||||
$table->foreign('dialog_message_id')->references('id')->on('dialog_messages')->cascadeOnDelete();
|
||||
$table->foreign('mentions_tag_id')->references('id')->on('tags')->cascadeOnDelete();
|
||||
}
|
||||
);
|
Reference in New Issue
Block a user