nullable migration laravel code example
Example 1: laravel migration remove column
public function up()
{
Schema::table('table', function($table) {
$table->dropColumn('column_name');
});
}
Example 2: laravel migration make column nullable
Schema::table('users', function($table)
{
$table->string('name', 50)->nullable()->change();
});
This is the correct syntax to revert the migration:
$table->integer('user_id')->unsigned()->nullable(false)->change();
Example 3: laravel change column
Schema::table('users', function (Blueprint $table) {
$table->string('name', 50)->nullable()->change();
});
Example 4: laravel create db table
php artisan make:migration create_users_table
Example 5: create migration laravel
php artisan make:Model Product -m -c --resource