I am working on integrating Doctrine Migrations into an existing project and in migration files, whenever I call methods on Schema
(ex. $schema->getTables()
), I get this error:
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
I think this is because I have tables named config
in two schemas which is why it's getting two rows. I'm not sure how to avoid this issue and there's no option to declare default Schema in migrations.xml
or migrations-db.php
either.
I would really like to use DBAL in migrations but unfortunately, this leaves me with no option but to use this->addSql()
.