【发布时间】:2016-04-05 22:09:28
【问题描述】:
Laravel 框架版本 5.2.5
当我更新一条记录时,update_at 没有改变,但 created_at 改变为当前时间戳。
这对吗?
MariaDB [月亮]> 显示来自用户的列; +----------------+------------------+------+------+ ---------------------+---------------------------- -+ |领域 |类型 |空 |钥匙 |默认 |额外 | +----------------+------------------+------+------+ ---------------------+---------------------------- -+ |编号 | int(10) 无符号 |否 |优先级 |空 |自动增量 | |姓名 | varchar(255) |否 | |空 | | |电子邮件 | varchar(255) |否 |统一 |空 | | |密码 | varchar(60) |否 | |空 | | |记住令牌 | varchar(100) |是 | |空 | | | created_at |时间戳 |否 | | CURRENT_TIMESTAMP |在更新 CURRENT_TIMESTAMP | |更新时间 |时间戳 |否 | | 0000-00-00 00:00:00 | | +----------------+------------------+------+------+ ---------------------+---------------------------- -+<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('email')->unique();
$table->string('password', 60);
$table->rememberToken();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('users');
}
}
【问题讨论】:
-
这听起来很奇怪。
-
请发布您的模型和导致反向更改的代码。
-
显然这是不正确的(与重复的问题相同)-
created_at列不应该有on update CURRENT_TIMESTAMP -
@MarcinNabiałek 谢谢。好像是mariadb的版本导致的问题?
标签: sql laravel laravel-5 eloquent laravel-5.2