我想为我的用户 created_at 列添加精度。所以,我创建了另一个迁移文件来更新 created_at 的属性,但它没有起作用。
这是我的迁移文件:
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('users', function (Blueprint $table) {
$table->dateTime('created_at', 3)->change();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('created_at');
});
}
当我运行 php artisan migrate 时,没有出现错误。但是每当我尝试创建一个新用户时,它不会反映更改。
我还在我的用户模型中添加了日期格式。
protected $dateFormat = 'Y-m-d H:i:s.v';