I use Laravel 5.2, Php7, Apache, Windows
my migration file is "2016_03_30_095234_alter_date_update_news_table.php"
class AddSlugUpdateNewsTable extends Migration
{
/**
* Run the migrations.
* php artisan make:migration add_slug_update_news_table
* @return void
*/
public function up()
{
Schema::table('news', function (Blueprint $table) {
$table->date('slug')->change();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('news', function (Blueprint $table) {
$table->dateTime('slug')->change();
});
}
}
But after run migrate,
$\> php artisan migrate
gives me this error!
[RuntimeException] Changing columns for table "news" requires Doctrine DBAL; install "doctrine/dbal".
what do i do?
according to laravel docs. You must install doctrine/dbal first if you are using ->change()
function.
Type composer require doctrine/dbal
in your terminal
/**
* Run the migrations.
* php artisan make:migration alter_date_update_news_table
* @return void
*/
public function up()
{
Schema::table('news', function (Blueprint $table) {
$table->dropColumn('date');
});
Schema::table('news', function (Blueprint $table) {
$table->date('date')->after('image');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('news', function (Blueprint $table) {
$table->dropColumn('date');
});
Schema::table('news', function (Blueprint $table) {
$table->dateTime('date')->after('image');
});
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With