Я использую Laravel Framework version 5.2.7
. Я cretaed миграции базы данных, как показано ниже:timestamps in laravel 5.2.7 имеют значения по умолчанию null
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateLessonsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('lessons', function (Blueprint $table) {
$table->increments('id');
$table->string('title');
$table->text('body');
$table->boolean('some_bool');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('lessons');
}
}
Я пошел в базе данных MySql виртуальной машины и использовать команду desc lessons;
, это то, что я получаю:
Я не понимаю, почему created_at
и updated_at
colums имеют NULL
как Default
. я пошел в Laravel 5.2 документации и увидел это:
$table->timestamps(); Adds created_at and updated_at columns.
$table->nullableTimestamps(); Same as timestamps(), except allows NULLs.
Так, согласно документации $table->timestamps();
не должны позволять NULL
в Default
. Но все же я получаю created_at
и updated_at
colums с NULL
как Default
. Я смущен. Пожалуйста помоги!!
Infact эти colums Шоул быть, как этот стол:
'$ table-> timestamp ('added_on');' - принимает CURRENT_TIMESTAMP, но '$ table-> timestamp ('created_date');' does not. – 151291