Home  >  Article  >  Backend Development  >  timestamps field in mysql not working

timestamps field in mysql not working

WBOY
WBOYOriginal
2016-12-01 00:00:391146browse

Why did I set a field type to timestamps, but it did not automatically fill in the current timestamp when updating or adding as I expected?

The same goes for the data table I generated using Laravel's migrate. The timestamps field in the generated table has no effect at all. what's going on?

This is the migration file

<code><?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateEquip extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('equip', function (Blueprint $table) {
            // $table->increments('id');
            $table->smallInteger('equip_id')->unsigned()->comment('装备id');
            $table->string('eqiup_name')->comment('装备名称');
            $table->string('eqiup_desc')->comment('装备描述');
            $table->timestamps();
            $table->primary('equip_id');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        //
    }
}
</code>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn