2017-07-08 20:51:13 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
use Illuminate\Support\Facades\Schema;
|
|
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
|
|
use Illuminate\Database\Migrations\Migration;
|
|
|
|
|
|
|
|
class ChangeUserPermissionsToDeleteOnUserDeletion extends Migration
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Run the migrations.
|
|
|
|
*/
|
2022-11-25 20:29:04 +00:00
|
|
|
public function up(): void
|
2017-07-08 20:51:13 +00:00
|
|
|
{
|
|
|
|
Schema::table('permissions', function (Blueprint $table) {
|
|
|
|
$table->dropForeign(['subuser_id']);
|
|
|
|
|
|
|
|
$table->foreign('subuser_id')->references('id')->on('subusers')->onDelete('cascade');
|
|
|
|
});
|
|
|
|
|
|
|
|
Schema::table('subusers', function (Blueprint $table) {
|
|
|
|
$table->dropForeign(['user_id']);
|
|
|
|
$table->dropForeign(['server_id']);
|
|
|
|
|
|
|
|
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
|
|
|
$table->foreign('server_id')->references('id')->on('servers')->onDelete('cascade');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reverse the migrations.
|
|
|
|
*/
|
2022-11-25 20:29:04 +00:00
|
|
|
public function down(): void
|
2017-07-08 20:51:13 +00:00
|
|
|
{
|
|
|
|
Schema::table('subusers', function (Blueprint $table) {
|
|
|
|
$table->dropForeign(['user_id']);
|
|
|
|
$table->dropForeign(['server_id']);
|
|
|
|
|
|
|
|
$table->foreign('user_id')->references('id')->on('users');
|
|
|
|
$table->foreign('server_id')->references('id')->on('servers');
|
|
|
|
});
|
|
|
|
|
|
|
|
Schema::table('permissions', function (Blueprint $table) {
|
|
|
|
$table->dropForeign(['subuser_id']);
|
|
|
|
|
|
|
|
$table->foreign('subuser_id')->references('id')->on('subusers');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|