52 lines
1.9 KiB
PHP
52 lines
1.9 KiB
PHP
<?php
|
|
|
|
use App\Enums\Users\RoleEnum;
|
|
use Illuminate\Database\Migrations\Migration;
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\Schema;
|
|
|
|
return new class extends Migration
|
|
{
|
|
/**
|
|
* Run the migrations.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function up(): void
|
|
{
|
|
Schema::table('users', function (Blueprint $table) {
|
|
$table->string('firstname')->change()->comment('First name of the user.');
|
|
$table->string('firstname')->change()->comment('Last name of the user.');
|
|
$table->timestamp('email_verified_at')->after('email')->nullable();
|
|
$table->boolean('role')->after('remember_token')
|
|
->comment('Role of the user who defines the rights/access.');
|
|
$table->boolean('published')->after('role')->comment('The user is acivated or not.');
|
|
$table->timestamp('published_at')->after('published')->nullable()->comment('The date on which the user was acivated.');
|
|
});
|
|
Schema::table('users', function (Blueprint $table) {
|
|
$table->renameColumn('firstname', 'first_name');
|
|
$table->renameColumn('lastname', 'last_name');
|
|
});
|
|
DB::table('users')->update(['role' => RoleEnum::admin->value()]);
|
|
DB::table('users')->update(['published' => true]);
|
|
DB::table('users')->where('email', 'equipe.web@ldc.fr')->update(['role' => RoleEnum::conceptor->value()]);
|
|
}
|
|
|
|
/**
|
|
* Reverse the migrations.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function down(): void
|
|
{
|
|
Schema::table('users', function (Blueprint $table) {
|
|
$table->renameColumn('first_name', 'firstname');
|
|
$table->renameColumn('last_name', 'lastname');
|
|
$table->dropColumn('email_verified_at');
|
|
$table->dropColumn('role');
|
|
$table->dropColumn('published');
|
|
$table->dropColumn('published_at');
|
|
});
|
|
}
|
|
};
|