我正在尝试使用Doctrine运行模式创建工具。我的数据库是postgresql。我现在得到的错误是:
[Doctrine\DBAL\Schema\SchemaException]
The table with name 'tracon.users' already exists.只有当我尝试使用多个实体运行时,才会出现错误:
php vendor/bin/doctrine orm:schema-tool:update或
php vendor/bin/doctrine orm:schema-tool:create作为一个例子。如果我的用户实体是文件夹中唯一的实体,它就能工作!
<?php
namespace entities;
use Doctrine\ORM\Mapping;
use Doctrine\ORM\Mapping\Table;
// entities/Users.php
/**
* @Entity
* @Table(name="users")
* @Table(schema="development")
**/
class Users {
/**
* @var integer
*
* @Id
* @Column(name="id", type="integer")
* @GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @var string
* @Column(type="string", length=64)
*/
protected $username;
/**
* @var string
* @Column(type="string", length=64)
*/
protected $first_name;
/**
* @var string
* @Column(type="string", length=64)
*/
protected $last_name;
/**
* @var string
* @Column(type="string", length=255)
*/
protected $email;
}但是一旦我添加了另一个实体类,比如下面的'Media‘,它就会报警表已经存在:
<?php
namespace entities;
use Doctrine\ORM\Mapping;
// entities/Media.php
/**
* @Entity
* @Table(name="development.media")
**/
class Media {
/**
* @var integer
*
* @Id
* @Column(name="id", type="integer")
* @GeneratedValue(strategy="AUTO")
*
*/
protected $id;
/**
* @var string
* @Column(type="string", length=64)
*/
protected $file_name;
/**
* @var string
* @Column(type="string", length=64)
*/
protected $file_url;
/**
* @var string
* @Column(type="string", length=64)
*/
protected $file_extension;
}导致此错误的原因可能是什么?另外,架构似乎没有注册。
发布于 2016-03-08 05:12:26
缓存!使用此命令清除缓存解决了问题:
php vendor/bin/doctrine orm:clear-cache:metadatahttps://stackoverflow.com/questions/35852048
复制相似问题