2023-12-27 09:51:47 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
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::table('users', function (Blueprint $table) {
|
|
|
|
$table->boolean('has_roles')->default(false);
|
2024-01-01 23:19:24 +00:00
|
|
|
$table->unsignedInteger('parent_id')->nullable();
|
|
|
|
$table->tinyInteger('role_id')->unsigned()->nullable()->index();
|
2023-12-27 09:51:47 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reverse the migrations.
|
|
|
|
*/
|
|
|
|
public function down(): void
|
|
|
|
{
|
|
|
|
Schema::table('users', function (Blueprint $table) {
|
2024-01-11 08:50:51 +00:00
|
|
|
if (Schema::hasColumn('users', 'has_roles')) {
|
|
|
|
$table->dropColumn('has_roles');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Schema::hasColumn('users', 'role_id')) {
|
|
|
|
$table->dropColumn('role_id');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Schema::hasColumn('users', 'parent_id')) {
|
|
|
|
$table->dropColumn('parent_id');
|
|
|
|
}
|
2023-12-27 09:51:47 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|