Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;

return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
$isMysql = DB::getDriverName() === 'mysql';
if (!$isMysql) {
return;
}
// check if the column status is of type enum
$column = DB::selectOne('SHOW COLUMNS FROM users WHERE Field = "status"');
$isEnum = substr($column->Type, 0, 4) === 'enum';
if (!$isEnum) {
return;
}
// change the column status to varchar
DB::statement('ALTER TABLE users MODIFY COLUMN status VARCHAR(255) NOT NULL DEFAULT "ACTIVE"');
}

/**
* Reverse the migrations.
*/
public function down(): void
{
}
};