Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7724097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T04:36:30+00:00 2026-06-01T04:36:30+00:00

Before I describe my problem, it might actually make it clearer if I start

  • 0

Before I describe my problem, it might actually make it clearer if I start with the error I’m getting:

$ ./app/console doc:mig:diff

  [Doctrine\DBAL\Schema\SchemaException]                 
  The table with name 'user_media_area' already exists.  

That’s absolutely true – user_media_area does exist. I created it in a previous migration and I don’t understand why Symfony is trying to create the table again.

My problem has something to do with a many-to-many relationship. I have a table called user, a table called media_area and a table called user_media_area.

Here’s the code where I tell user about media_area (Entity/User.php):

/**
 * @ORM\ManyToMany(targetEntity="MediaArea", inversedBy="mediaAreas")
 * @JoinTable(name="user_media_area",
 *      joinColumns={@JoinColumn(name="user_id", referencedColumnName="id")},
 *      inverseJoinColumns={@JoinColumn(name="media_area_id", referencedColumnName="id")}
 *      )
 */
private $mediaAreas;

And here’s where I tell media_area about user (Entity/MediaArea.php):

/** 
 * @ORM\ManyToMany(targetEntity="User", mappedBy="users")
 */
private $users;

What’s interesting is that if I remove that JoinTable stuff from Entity/User.php, ./app/console doctrine:migrations:diff will work again:

/**
 * @ORM\ManyToMany(targetEntity="MediaArea", inversedBy="mediaAreas")
 */
private $mediaAreas;

However, it’s a little off: it now wants to create a new table called mediaarea, which I don’t want. My table already exists and it’s called media_area.

So it looks like either way, Symfony is trying to create a table based on this ManyToMany thing in my User class, and the only reason the problem goes away when I remove the JoinTable is that the name of the table it wants to create (mediaarea) no longer matches the actual name of my table (media_area).

So my question is: Why does it want to create a new table at all? What am I doing wrong?

(I know it’s possible that my naming conventions are off. Symfony and Doctrine’s database examples are frustratingly devoid of multi-term column names, so I don’t always know if I’m supposed to do media_area or mediaArea.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T04:36:31+00:00Added an answer on June 1, 2026 at 4:36 am

    According to the Association Mapping explanation on the official docs, the @JoinColumn and @JoinTable definitions are usually optional and have sensible default values, being:

    name: "<fieldname>_id"
    referencedColumnName: "id"
    

    From that we can conclude that there is really no concrete difference between the two implementations you presented.

    However, when it comes to migration, the creation of the table is a pretty common and expected behaviour. The thing is the table should always get deleted and created again, which is not happenning.

    About the table name issue, the default behaviour of Doctrine 2 about this:

    /**
     * @ORM\ManyToMany(targetEntity="MediaArea", inversedBy="mediaAreas")
     */
    private $mediaAreas;
    

    Is to try and create a table called mediaarea. Again, perfectly normal.

    If you want to declare a specific name for the table of an entity, you should do this:

    /**
     * @ORM\Table(name="my_table")
     */
    class Something
    

    I’m not sure if that helps you at all, but I guess it puts you, at least, on the right track.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Before I describe my problem, here is a description of the program (IHExplorer.exe) I'm
Before going to describe my problem first,I would like to define definitions of Decorator
Before I start, I know there is this post and it doesn't answer my
It's not some kind of synchronization problem I readed before. The code is quite
Ok, Last time I posted this (last week), I didn't describe the problem correctly.
What's the problem I wanna test a before filter that render errors in XML
This is a very difficult problem to describe. The big picture: An ajaxed dialog
I am having the exact same problem describe in this question , but for
I am not getting a tooltip to work and I think the problem is
I have a navigation problem. I want to create the following navigation structure: Start

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.