我无法让我的关系与doctrine2合作。
生成架构时出现以下错误消息:
"The table with name 'wasd.user_post' already exists."
我的问题是我不明白哪些关系导致出现此错误消息。
这些是我的实体:
发表:
<?php
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table(name="posts")
*/
class Post
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\Column(name="text", type="text")
*/
private $text;
/**
* @ORM\Column(name="votes", type="integer")
*/
private $votes = 0;
/**
* @ORM\ManyToOne(targetEntity="User", inversedBy="posts")
*/
private $owner;
/**
* @ORM\ManyToMany(targetEntity="User", inversedBy="upvotedPosts")
* @ORM\JoinTable(name="post_upvotes")
*/
private $upvotedBy;
/**
* @ORM\ManyToMany(targetEntity="User", inversedBy="downvotedPosts")
* @ORM\JoinTable(name="post_downvotes")
*/
private $downvotedBy;
/**
* @ORM\OneToMany(targetEntity="Comment", mappedBy="post")
*/
private $comments;
/**
* @ORM\OneToMany(targetEntity="Attachment", mappedBy="post")
*/
private $attachments;
}
用户:
use FOS\UserBundle\Model\User as BaseUser;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table(name="users")
*/
class User extends BaseUser
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(name="is_summoner_verified", type="boolean")
*/
private $isSummonerVerified = false;
/**
* @ORM\Column(name="summoner_id", type="string", length=255)
*/
private $summonerId = '';
/**
* @ORM\Column(name="summoner_name", type="string", length=255)
*/
private $summonerName = '';
/**
* @ORM\Column(name="display_league", type="boolean")
*/
private $displayLeague = true;
/**
* @ORM\Column(name="display_summoner", type="boolean")
*/
private $displaySummoner = true;
/**
* @ORM\Column(name="league", type="string", length=255)
*/
private $league = '';
/**
* @var $posts
* @ORM\OneToMany(targetEntity="Post", mappedBy="owner")
* @ORM\JoinColumn(name="owner_id")
*/
private $posts;
/**
* @ORM\Column(name="summoner_verify_code", type="string", length=8)
*/
private $summonerVerifyCode = '';
/**
* @ORM\ManyToMany(targetEntity="Post", inversedBy="upvotedBy")
*/
private $upvotedPosts;
/**
* @ORM\ManyToMany(targetEntity="Post", inversedBy="downvotedBy")
*/
private $downvotedPosts;
/**
* @ORM\ManyToMany(targetEntity="Comment", inversedBy="upvotedBy")
*/
private $upvotedComments;
/**
* @ORM\ManyToMany(targetEntity="Comment", inversedBy="downvotedBy")
*/
private $downvotedComments;
/**
* @ORM\OneToOne(targetEntity="Stream", mappedBy="user")
*/
private $stream = null;
/**
* @ORM\OneToMany(targetEntity="Comment", mappedBy="user")
*/
private $comments;
}