无法使用Doctrine创建Postgres数据库

6

我有一个使用Symfony2和Doctrine的项目。在某一时刻,我失去了通过控制台命令创建/删除数据库的能力,例如:

app/console doctrine:database:drop --force
app/console doctrine:database:create
app/console doctrine:schema:update --force

如果我尝试创建数据库,Doctrine会给我以下错误:
[Doctrine\DBAL\Exception\ConnectionException]                                                     
  An exception occured in driver: SQLSTATE[08006] [7] FATAL:  database "motherhood" does not exist 

所以,我可以使用Symfony配置在psql中创建带有用户的数据库。如果我尝试通过Doctrine删除现有的数据库,会出现以下错误:

SQLSTATE[55006]: Object in use: 7 ERROR:  database "motherhood" is being accessed by other users
DETAIL:  There are 1 other session using the database.

但是这个数据库没有连接


1
我自己也遇到了同样的错误。Doctrine忽略了database_name参数,并告诉我config中的database_user名称的数据库不存在,当我像你一样运行app/console doctrine:database:create时。显然,那个不存在,真正存在的数据库是由database_name指定的,而不是database_user。这对新手Symfony用户来说非常令人沮丧。 - sdjuan
1个回答

0

解决问题的快速方法是创建一个与执行命令的用户名称相同的数据库,因为即使创建新数据库,PostgreSQL也必须连接到一个数据库。

删除数据库时出现的故障应在DoctrineBundle 1.4中修复。

创建数据库失败将在接下来的doctrine/dbal版本(2.5.2)中得到修复,如此处所述:https://github.com/doctrine/DoctrineBundle/issues/402。该问题将通过始终连接到无法删除的模板数据库来解决。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接