I am creating two database tables as part of a new extension. I can create one table just fine, but I get the following error message when I try to create two tables:

PDOException: SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'awesome_ness' already exists

Here's my config.xml entry:


In my install-1.0.0.php script, I have two createTable definitions, like so:

$installer = $this;


$table_one = $installer->getConnection()

$table_two = $installer->getConnection()


I guess I need to know how to create two <table></table> definitions. Thanks in advance.

2 Answers 2


The thing is, you are trying to create two tables for the same entity. And since an entity can have one table name (which is taken from the xml), you will be creating two tables with the same name. You would need to supply a second entity entry in your XML to create that second table.


Then in your install script, for the second table, you call


instead of


I haven't dont this in a while, and I haven't checked my work, BUT

When you say


You're telling Magento

Look at the resource model for awesome_ness, and within this resource model tell me the table name for the ness entity.

So, you're basically running the same create table statement, which is why MySQL complains about the table already existing (because it does).

If you add a new entity to your configuration


You should be able to say

  • Answered by the legend. Thank you Alan, I got it now.
    – Jongosi
    Jun 6, 2013 at 10:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.