Skip to content

Commit

Permalink
Merge pull request #34 from YunusEmreNalbant/update-type-column-in-co…
Browse files Browse the repository at this point in the history
…nfig-table

Update type column in config table
  • Loading branch information
frkcn authored Mar 7, 2024
2 parents ffd624e + 1b6c9ea commit f3fbe0a
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

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

class UpdateTypeColumnInConfigTable extends Migration
Expand All @@ -13,20 +13,22 @@ class UpdateTypeColumnInConfigTable extends Migration
*/
public function up(): void
{
Schema::table(config('laravel-config.table'), function (Blueprint $table) {
$table->string('type')->nullable(false)->default('boolean')->change();
$tableName = config('laravel-config.table');

Schema::table($tableName, function () use ($tableName): void {
DB::statement("ALTER TABLE $tableName CHANGE type type varchar(255) DEFAULT 'boolean' NOT NULL");
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::table(config('laravel-config.table'), function (Blueprint $table) {
$table->enum('type', ['boolean', 'text'])->nullable()->default('boolean')->change();
$tableName = config('laravel-config.table');

Schema::table($tableName, function () use ($tableName): void {
DB::statement("ALTER TABLE $tableName CHANGE type type ENUM('boolean','text') DEFAULT 'boolean' NOT NULL ");
});
}
}

0 comments on commit f3fbe0a

Please sign in to comment.