WIP
This commit is contained in:
@@ -19,10 +19,10 @@ class CreatePermissionTables extends Migration
|
||||
$teams = config('permission.teams');
|
||||
|
||||
if (empty($tableNames)) {
|
||||
throw new \Exception('Error: config/permission.php not loaded. Run [php artisan config:clear] and try again.');
|
||||
throw new Exception('Error: config/permission.php not loaded. Run [php artisan config:clear] and try again.');
|
||||
}
|
||||
if ($teams && empty($columnNames['team_foreign_key'] ?? null)) {
|
||||
throw new \Exception('Error: team_foreign_key on config/permission.php not loaded. Run [php artisan config:clear] and try again.');
|
||||
throw new Exception('Error: team_foreign_key on config/permission.php not loaded. Run [php artisan config:clear] and try again.');
|
||||
}
|
||||
|
||||
Schema::create($tableNames['permissions'], function (Blueprint $table) {
|
||||
@@ -133,7 +133,7 @@ class CreatePermissionTables extends Migration
|
||||
$tableNames = config('permission.table_names');
|
||||
|
||||
if (empty($tableNames)) {
|
||||
throw new \Exception('Error: config/permission.php not found and defaults could not be merged. Please publish the package configuration before proceeding, or drop the tables manually.');
|
||||
throw new Exception('Error: config/permission.php not found and defaults could not be merged. Please publish the package configuration before proceeding, or drop the tables manually.');
|
||||
}
|
||||
|
||||
Schema::drop($tableNames['role_has_permissions']);
|
||||
|
||||
@@ -9,7 +9,7 @@ class CreateViewsTable extends Migration
|
||||
/**
|
||||
* The database schema.
|
||||
*
|
||||
* @var \Illuminate\Support\Facades\Schema
|
||||
* @var Schema
|
||||
*/
|
||||
protected $schema;
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
return new class extends Migration
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use BasementChat\Basement\Enums\MessageType;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('private_messages', static function (Blueprint $table): void {
|
||||
/** @var string $model */
|
||||
$model = config('basement.user_model');
|
||||
/** @var Model $user */
|
||||
$user = app($model);
|
||||
|
||||
$primaryKey = $user->getKeyName();
|
||||
$tableName = $user->getTable();
|
||||
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('receiver_id');
|
||||
$table->unsignedBigInteger('sender_id');
|
||||
$table->foreign('receiver_id')->references($primaryKey)->on($tableName);
|
||||
$table->foreign('sender_id')->references($primaryKey)->on($tableName);
|
||||
$table->enum('type', [MessageType::document()->value, MessageType::text()->value]);
|
||||
$table->string('value');
|
||||
$table->timestamp('read_at')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('private_messages');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user