laravel migration enum code example

Example 1: laravel enum migration

Add Laravel enmu migration : 
------------------------------
$table->enum('question_type', ['objective', 'subjective', 'multiple_choice']);

Update Laravel enum migration :
---------------------------------
DB::statement("ALTER TABLE users CHANGE COLUMN permissions permissions ENUM('admin', 'user', 'candidate') NOT NULL DEFAULT 'user'");

Example 2: laravel drop column

// To drop a column, use the dropColumn method on the schema builder.
// Before dropping columns from a SQLite database, you will need to add
// the doctrine/dbal dependency to your composer.json file and run the
// composer update command in your terminal to install the library:

Schema::table('users', function (Blueprint $table) {
    $table->dropColumn('votes');
});

Example 3: Laravel Migration - Update Enum Options

DB::statement("ALTER TABLE users CHANGE COLUMN permissions permissions ENUM('admin', 'user', 'candidate') NOT NULL DEFAULT 'user'");

Tags:

Php Example