Laravel 5.2 Timestamps

Ok, so I'm trying to make some simple database schemas using Laravel 5.2 migrations. At the moment they are quite simple. The problem is that the created result table does not reflect in mysql what I dictated in the schema builder. For example: enter image description here creates the following table (ignore the image after the table): enter image description here

I am sure that if I wanted to allow nulls, I would have to use nullableTimestampts () also not default values, as well as "on update CURRENT TIMESTAMP", etc.

What am I missing here? The aritsan commands were pretty simple:

php artisan make:migration create_table_institutes --create=institutes
php artisan migrate

I'm on Ubuntu 14.04, php7, Apache mysql Here is my seeding code:

DB::table('institutes')->insert([
    'name' => 'Ncbi',
    'base_curl' => 'eutils.ncbi.nlm.nih.gov/entrez/eutils/',
]);
+4
1

Schema Builder timestamps Laravel 5.2. nullableTimestamps - , , , , , timestamps .

, timestamp, nullable, . created_at, MySQL, . :

$table->timestamps();

:

$table->dateTime('created_at')->default(DB::raw('CURRENT_TIMESTAMP'));
$table->dateTime('updated_at')->nullable();

MySQL 5.6.5, DATETIME , TIMESTAMP:

$table->timestamp('created_at')->default(DB::raw('CURRENT_TIMESTAMP'));

, Eloquent, created_at, , nullable, .

+3

Source: https://habr.com/ru/post/1629055/


All Articles