I am learning laravel 5.1 through laracast fundamentals series and in episode 7 that talk about migrations, i built a table with migration like this:
public function up()
{
Schema::create('articles', function (Blueprint $table) {
$table->increments('id');
$table->string('title');
$table->text('body');
$table->timestamps();
$table->timestamp('published_at');
});
}
and as it says in the episode 10, when i add an article to database through a form that don't have a field for published_at
timestamp, then this should not work and should through an exception that Not Null constraint failed
But incredibly the article added to table.
When i look at the table in phpmyadmin structure for the published_at
column it didn't checked the null
checkbox, so it shouldn't accept null? is this true?
But then i noticed that the migration sets a default value to 0000-00-00 00:00:00
for published_at
column. why?! and will this override the NULL condition?
Then i tried to set the default value to none
and still the null is not checked. and again i tried to add an article without published_at
fields But again a new row added to table with published_at
value set to 0000-00-00 00:00:00
.
any explanation?
I am using wampserver with mysql v5.6.17
, php v5.5.12