每当我在Schema
(例如$schema->getTables()
)上调用方法时,我都在将Doctrine Migrations集成到现有项目和迁移文件中,但出现此错误:
Executing dry run of migration up to 20180726185129 from 0
++ migrating 20180726185129
IN UP
Migration 20180726185129 failed during Execution. Error An exception occurred while executing 'SELECT quote_ident(r.conname) as conname, pg_catalog.pg_get_constraintdef(r.oid, true) as condef
FROM pg_catalog.pg_constraint r
WHERE r.conrelid =
(
SELECT c.oid
FROM pg_catalog.pg_class c, pg_catalog.pg_namespace n
WHERE n.nspname NOT IN ('pg_catalog', 'information_schema', 'pg_toast') AND c.relname = 'config' AND n.nspname = ANY(string_to_array((select replace(replace(setting,'"$user"',user),' ','') from pg_catalog.pg_settings where name = 'search_path'),',')) AND n.oid = c.relnamespace
)
AND r.contype = 'f'':
SQLSTATE[21000]: Cardinality violation: 7 ERROR: more than one row returned by a subquery used as an expression
In AbstractPostgreSQLDriver.php line 91:
An exception occurred while executing 'SELECT quote_ident(r.conname) as con
name, pg_catalog.pg_get_constraintdef(r.oid, true) as condef
FROM pg_catalog.pg_constraint r
WHERE r.conrelid =
(
SELECT c.oid
FROM pg_catalog.pg_class c, pg_catalog.pg_namespace n
WHERE n.nspname NOT IN ('pg_catalog', 'information_sc
hema', 'pg_toast') AND c.relname = 'config' AND n.nspname = ANY(string_to_a
rray((select replace(replace(setting,'"$user"',user),' ','') from pg_catalo
g.pg_settings where name = 'search_path'),',')) AND n.oid = c.relnamespace
)
AND r.contype = 'f'':
SQLSTATE[21000]: Cardinality violation: 7 ERROR: more than one row returne
d by a subquery used as an expression
In PDOConnection.php line 106:
SQLSTATE[21000]: Cardinality violation: 7 ERROR: more than one row returne
d by a subquery used as an expression
In PDOConnection.php line 104:
SQLSTATE[21000]: Cardinality violation: 7 ERROR: more than one row returne
d by a subquery used as an expression
我认为这是因为我在两种模式中都有名为config
的表,这就是为什么它要获得两行的原因。我不确定如何避免此问题,也没有选择在migrations.xml
或migrations-db.php
中声明默认模式。
我真的很想在迁移中使用DBAL,但是不幸的是,这让我别无选择,只能使用this->addSql()
。