mirror of
https://github.com/flarum/core.git
synced 2025-08-08 09:26:34 +02:00
@@ -0,0 +1,25 @@
|
||||
<?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(
|
||||
'dialogs',
|
||||
function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->unsignedBigInteger('first_message_id')->nullable();
|
||||
$table->unsignedBigInteger('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();
|
||||
$table->string('type');
|
||||
$table->timestamps();
|
||||
}
|
||||
);
|
@@ -0,0 +1,23 @@
|
||||
<?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_messages',
|
||||
function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->foreignId('dialog_id')->constrained()->cascadeOnDelete();
|
||||
$table->unsignedInteger('user_id')->nullable();
|
||||
$table->foreign('user_id')->references('id')->on('users')->cascadeOnDelete();
|
||||
$table->text('content');
|
||||
$table->timestamps();
|
||||
}
|
||||
);
|
@@ -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_user',
|
||||
function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('dialog_id')->constrained()->cascadeOnDelete();
|
||||
$table->unsignedInteger('user_id');
|
||||
$table->dateTime('joined_at');
|
||||
$table->unsignedBigInteger('last_read_message_id')->default(0);
|
||||
$table->dateTime('last_read_at')->nullable();
|
||||
$table->foreign('user_id')->references('id')->on('users')->cascadeOnDelete();
|
||||
}
|
||||
);
|
@@ -0,0 +1,26 @@
|
||||
<?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 Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Schema\Builder;
|
||||
|
||||
return [
|
||||
'up' => function (Builder $schema) {
|
||||
$schema->table('dialogs', function (Blueprint $table) {
|
||||
$table->foreign('first_message_id')->references('id')->on('dialog_messages')->nullOnDelete();
|
||||
$table->foreign('last_message_id')->references('id')->on('dialog_messages')->nullOnDelete();
|
||||
});
|
||||
},
|
||||
'down' => function (Builder $schema) {
|
||||
$schema->table('dialogs', function (Blueprint $table) {
|
||||
$table->dropForeign(['first_message_id']);
|
||||
$table->dropForeign(['last_message_id']);
|
||||
});
|
||||
}
|
||||
];
|
@@ -0,0 +1,15 @@
|
||||
<?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 Flarum\Group\Group;
|
||||
|
||||
return Migration::addPermissions([
|
||||
'dialog.sendMessage' => Group::MEMBER_ID,
|
||||
]);
|
Reference in New Issue
Block a user