first commit
This commit is contained in:
44
database/migrations/2024_12_14_030215_modify_users_table.php
Normal file
44
database/migrations/2024_12_14_030215_modify_users_table.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Koneko\VuexyAdmin\Models\User;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
DB::statement('ALTER TABLE `users` MODIFY `id` BIGINT UNSIGNED NOT NULL;');
|
||||
DB::statement('ALTER TABLE `users` DROP PRIMARY KEY;');
|
||||
DB::statement('ALTER TABLE `users` MODIFY `id` MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT, ADD PRIMARY KEY (`id`);');
|
||||
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->string('last_name', 100)->nullable()->comment('Apellidos')->index()->after('name');
|
||||
$table->string('profile_photo_path', 2048)->nullable()->after('remember_token');
|
||||
$table->unsignedTinyInteger('status')->default(User::STATUS_DISABLED)->after('profile_photo_path');
|
||||
$table->unsignedMediumInteger('created_by')->nullable()->index()->after('status');
|
||||
|
||||
// Definir la relación con created_by
|
||||
$table->foreign('created_by')->references('id')->on('users')->onUpdate('restrict')->onDelete('restrict');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
DB::statement('ALTER TABLE `users` MODIFY `id` MEDIUMINT UNSIGNED NOT NULL;');
|
||||
DB::statement('ALTER TABLE `users` DROP PRIMARY KEY;');
|
||||
DB::statement('ALTER TABLE `users` MODIFY `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, ADD PRIMARY KEY (`id`);');
|
||||
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropColumn(['last_name', 'profile_photo_path', 'status', 'created_by']);
|
||||
|
||||
});
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user