我正在尝试使用Doctrine运行架构创建工具。我的db是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
举个例子。如果我将Users实体作为文件夹中唯一的实体,那就可以了!
<?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;
}
但是一旦我添加了另一个Entity类,如下面的'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;
}
可能导致此错误的原因是什么?此外,模式似乎没有注册。
答案 0 :(得分:1)
缓存!使用此命令清除缓存解决了以下问题:
{
"Security": {
"UsernameToken": {
"Username": "ups_username_here",
"Password": "ups_password_here"
},
"UPSServiceAccessToken": {
"AccessLicenseNumber": "ups_access_license_number_here"
}
},
"TrackRequest": {
"Request": {
"RequestAction": "Track",
"RequestOption": "activity"
},
"InquiryNumber": "1Z202Y36A898759591"
}
}