Skip to content

Commit f3fbe0a

Browse files
authored
Merge pull request #34 from YunusEmreNalbant/update-type-column-in-config-table
Update type column in config table
2 parents ffd624e + 1b6c9ea commit f3fbe0a

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed
Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

33
use Illuminate\Database\Migrations\Migration;
4-
use Illuminate\Database\Schema\Blueprint;
4+
use Illuminate\Support\Facades\DB;
55
use Illuminate\Support\Facades\Schema;
66

77
class UpdateTypeColumnInConfigTable extends Migration
@@ -13,20 +13,22 @@ class UpdateTypeColumnInConfigTable extends Migration
1313
*/
1414
public function up(): void
1515
{
16-
Schema::table(config('laravel-config.table'), function (Blueprint $table) {
17-
$table->string('type')->nullable(false)->default('boolean')->change();
16+
$tableName = config('laravel-config.table');
17+
18+
Schema::table($tableName, function () use ($tableName): void {
19+
DB::statement("ALTER TABLE $tableName CHANGE type type varchar(255) DEFAULT 'boolean' NOT NULL");
1820
});
1921
}
2022

2123
/**
2224
* Reverse the migrations.
23-
*
24-
* @return void
2525
*/
2626
public function down(): void
2727
{
28-
Schema::table(config('laravel-config.table'), function (Blueprint $table) {
29-
$table->enum('type', ['boolean', 'text'])->nullable()->default('boolean')->change();
28+
$tableName = config('laravel-config.table');
29+
30+
Schema::table($tableName, function () use ($tableName): void {
31+
DB::statement("ALTER TABLE $tableName CHANGE type type ENUM('boolean','text') DEFAULT 'boolean' NOT NULL ");
3032
});
3133
}
3234
}

0 commit comments

Comments
 (0)