【发布时间】:2021-09-01 22:43:36
【问题描述】:
Schema::table('cms_myterms', function (Blueprint $table) {
$table->dropColumn('created_at');
$table->timestamps();
});
但这是错误的。
在 Connection.php 第 664 行:
SQLSTATE[42S21]: 列已存在: 1060 列名重复'created_at' (SQL: alter table cms_myterms add cre ated_at timestamp null, add updated_at timestamp null)
在 Exception.php 第 18 行:
SQLSTATE[42S21]: 列已经存在: 1060 Duplicate column name 'created_at'
在 PDOStatement.php 第 112 行:
SQLSTATE[42S21]: 列已经存在: 1060 Duplicate column name 'created_at'
【问题讨论】:
-
在一次通话中,您不能删除并重新创建同一列。要么添加
updated_at,要么使用不同的调用来删除和创建。