mysql specific migration
This commit is contained in:
+39
@@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
// Check if we're using MySQL
|
||||||
|
$driver = DB::connection()->getDriverName();
|
||||||
|
|
||||||
|
if ($driver === 'mysql') {
|
||||||
|
// For MySQL, use ALTER TABLE MODIFY to update the ENUM
|
||||||
|
DB::statement("ALTER TABLE service_requests MODIFY COLUMN status ENUM('pending', 'confirmed', 'mail_sent', 'completed', 'cancelled') NOT NULL DEFAULT 'pending'");
|
||||||
|
}
|
||||||
|
// For SQLite, the other migration handles it
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
// Check if we're using MySQL
|
||||||
|
$driver = DB::connection()->getDriverName();
|
||||||
|
|
||||||
|
if ($driver === 'mysql') {
|
||||||
|
// Revert to original ENUM values
|
||||||
|
DB::statement("ALTER TABLE service_requests MODIFY COLUMN status ENUM('pending', 'confirmed', 'completed', 'cancelled') NOT NULL DEFAULT 'pending'");
|
||||||
|
}
|
||||||
|
// For SQLite, the other migration handles it
|
||||||
|
}
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user