sqlite上的索引重复,而不是mysql上的索引重复
我有一个实体定义,可以在开发和生产环境(mysql)上使用,但不能在测试(sqlite)上使用: 当我运行条令:schema:create或条令:schema:update--force on test env时,出现以下错误:sqlite上的索引重复,而不是mysql上的索引重复,sqlite,symfony,doctrine-orm,Sqlite,Symfony,Doctrine Orm,我有一个实体定义,可以在开发和生产环境(mysql)上使用,但不能在测试(sqlite)上使用: 当我运行条令:schema:create或条令:schema:update--force on test env时,出现以下错误: [Doctrine\DBAL\DBALException] An exception occurred while executin
[Doctrine\DBAL\DBALException]
An exception occurred while executing 'CREATE INDEX created_at_idx ON invoice (created_at)':
SQLSTATE[HY000]: General error: 1 index created_at_idx already exists
[PDOException]
SQLSTATE[HY000]: General error: 1 index created_at_idx already exists
有人已经有这种问题了吗?如何解决/忽略它
谢谢 解决方案如下:
简而言之,索引必须在整个数据库中具有唯一的名称
所以你不能有:
- 发票->在idx创建
- 用户->在\u idx处创建\u
- 发票->在idx创建的发票
- 用户->用户在idx创建
,sqlite可能会失败?对不起!我回答了重复行的问题,刚从您的评论中意识到问题在于重复索引本身。所以是的,我相信如果数据库中已经有一个名为created_at_idx的对象,不管它与这个表有什么关联,它都会失败。但是这对于大多数DBMS来说都是正确的,所以除了一个错误的名称之外,我们仍然不确定这两个DBMS在行为上有什么不同。查看是否存在一个(我认为是“从my_db_name.sqlite_master中选择*,其中name='created_at_id'))。对不起,帮不上忙了。谢谢你的回答。我将进行调查并等待其他帮助。:)
[Doctrine\DBAL\DBALException]
An exception occurred while executing 'CREATE INDEX created_at_idx ON invoice (created_at)':
SQLSTATE[HY000]: General error: 1 index created_at_idx already exists
[PDOException]
SQLSTATE[HY000]: General error: 1 index created_at_idx already exists