Our blog

 

Magento Install Problem + Solution ‘sales_flat_quote’ already exists

Trying to do a clean install of Magento 1.2.1.2 I kept hitting this SQL error.

Base table or view already exists: 1050 Table 'sales_flat_quote' already exists

In the end I opted to manually edit the related install file and add DELETE IF EXISTS statements before each CREATE TABLE statement.

The file in question is located here:

/app/code/core/Mage/Sales/sql/sales_setup

and the problem file is

mysql4-install-0.9.0.php

The solution is to edit the file and add DROP TABLE IF EXISTS statements before each CREATE TABLE statement

eg

PHP:
  1. DROP TABLE IF EXISTS  `{$installer->getTable('sales_flat_quote')}`;
  2.  
  3. CREATE TABLE `{$installer->getTable('sales_flat_quote')}` (.....

I have created an issue on their bug tracker here.

More...

More Reading:

4 Comments

Unirgy
March 10th, 2009

That's how it was before 1.0 - the problem with that was dropping and re-creating the whole database on weird mysql server glitch that wouldn't show core_resource table as existing.

Besides, the install-*.php scripts suppose to work ONLY when the module is not installed yet. If there are already module tables in database, means there's something wrong and it is safer to involve a human.

 

onionlips
May 26th, 2009

After several frustrating hours to debug -- This worked for me. Regardless of the right or wrong way to do it -- Thank you!

 

Vier
July 29th, 2010

Man, you saved my life. I don't know what the hell I did while installing an extension but I had errors on sales_flat_order, and after including your piece of code the website came back to life, so I'm very grateful to you ;)

Thanks!

 

Alex
September 22nd, 2010

Hello, I have a problem with my magento website
After edit "en-tête html" this code appear

Error in file: "/homez.361/comunpix/www/paiement/app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-1.3.99-1.4.0.0.php" - SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'sales_flat_order_grid' already exists

Trace:
#0 /homez.361/comunpix/www/paiement/app/code/core/Mage/Core/Model/Resource/Setup.php(390): Mage::exception('Mage_Core', 'Error in file: ...')
#1 /homez.361/comunpix/www/paiement/app/code/core/Mage/Core/Model/Resource/Setup.php(289): Mage_Core_Model_Resource_Setup->_modifyResourceDb('upgrade', '0.9.56', '1.4.0.15')
#2 /homez.361/comunpix/www/paiement/app/code/core/Mage/Core/Model/Resource/Setup.php(233): Mage_Core_Model_Resource_Setup->_upgradeResourceDb('0.9.56', '1.4.0.15')
#3 /homez.361/comunpix/www/paiement/app/code/core/Mage/Core/Model/Resource/Setup.php(161): Mage_Core_Model_Resource_Setup->applyUpdates()
#4 /homez.361/comunpix/www/paiement/app/code/core/Mage/Core/Model/App.php(363): Mage_Core_Model_Resource_Setup::applyAllUpdates()
#5 /homez.361/comunpix/www/paiement/app/code/core/Mage/Core/Model/App.php(295): Mage_Core_Model_App->_initModules()
#6 /homez.361/comunpix/www/paiement/app/Mage.php(596): Mage_Core_Model_App->run(Array)
#7 /homez.361/comunpix/www/paiement/index.php(80): Mage::run('', 'store')
#8 {main}

I'm test your solution but ...

Thanks

 

 

Leave a Reply