【发布时间】:2017-02-27 22:10:17
【问题描述】:
我使用以下命令在 CakePHP 3 上创建了一个新的迁移脚本
bin/cake bake migration CreateOfficialTeams id:int name:string topic_id:int
id 字段应该是主键,topic_id 是外键。脚本按照我的意愿出现,除了 topic_id 出于某种原因是一个字符串,但我手动修复了它。
当我尝试运行脚本时,我收到一条错误消息:
Exception: SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name 'id' in [/home/bradygp/workspace/vendor/robmorgan/phinx/src/Phinx/Db/Adapter/PdoAdapter.php, line 306]
2017-02-27 21:52:16 Error [PDOException] SQLSTATE[45S21]: Column already exists: 1060 Duplicate column name 'id'
我还有其他列名为“id”的表,但这是一个新表,使用create() 函数调用,
【问题讨论】:
-
@ndm 啊,就是这样。迁移脚本将自动创建 id,当我也尝试创建一个时,出现重复列错误。谢谢。
标签: php mysql cakephp migration phinx