I am trying to run the schema create tool with Doctrine. My db is postgresql. I currently get the error:
[Doctrine\DBAL\Schema\SchemaException]
The table with name 'tracon.users' already exists.
The error only occurs when I try to run with more than one Entity:
php vendor/bin/doctrine orm:schema-tool:update
or
php vendor/bin/doctrine orm:schema-tool:create
As an example. If I the Users entity the only entity in the folder, it works!
<?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;
}
But as soon as I add another Entity class like the 'Media' one below, it complains the table already exist:
<?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;
}
What could be causing this error? Also it appears the schema is not registering.
Cache! Clearing the cache with this command solved the problems:
php vendor/bin/doctrine orm:clear-cache:metadata
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.