Defining the Error
This error is caused when Magento attempts to run an installation file for an extension which has already been installed. The trigger which prevents this has been overseen different reasons that we will explore and Magento has forgotten that this extension installation has already happened. Let’s look at the complete backtrace report found in your report files.
Error in file: "/app/code/core/Mage/Oauth/sql/oauth_setup/install-1.0.0.0.php"
SQLSTATE[42S01]: Base table or view already exists: 1050 Table "oauth_consumer" already exists";
#0 /app/code/core/Mage/Core/Model/Resource/Setup.php(645): Mage::exception("Mage_Core", "Error in file: ...")
#1 /app/code/core/Mage/Core/Model/Resource/Setup.php(421): Mage_Core_Model_Resource_Setup->_modifyResourceDb("install", "", "1.0.0.0")
#2 /app/code/core/Mage/Core/Model/Resource/Setup.php(327): Mage_Core_Model_Resource_Setup->_installResourceDb("1.0.0.0")
#3 /app/code/core/Mage/Core/Model/Resource/Setup.php(235): Mage_Core_Model_Resource_Setup->applyUpdates()
#4 /app/code/core/Mage/Core/Model/App.php(417): Mage_Core_Model_Resource_Setup::applyAllUpdates()
#5 /app/code/core/Mage/Core/Model/App.php(343): Mage_Core_Model_App->_initModules()
#6 /app/Mage.php(684): Mage_Core_Model_App->run(Array)
#7 /index.php(87): Mage::run("", "store")
You may most likely experience this error during a site migration or when accessing your administrative area.
Defining Related Errors
Here are some other Magento users who are experience related errors.
- Base table or view already exists: 1050 Table âcatalogrule_affected_productâ already exists
- SQL error ‘core_resource’ already exists
Defining the causes of this error
1. Rolling back the database after installing an extension
If you’ve installed an extension onto your Magento Community store and then rolled your database back to a previous date, Magento will have lost the database flags, memory, which tell it that this extension has already been installed.
Rolling back to an old database version from within the Magento Administrative area will not remove database tables that were not in the old revision. Restoring an old database only overwrites tables which are in the revision.
2. Rolling back the database after upgrading Magento
This error can also be encountered after upgrading Magento and then rolling back the database. The same situation has been created here as before. You have upgraded your websites files and downgraded your database, now the two are out of sync.
3. During installation of a fresh Magento
I can’t tell you why it happens at this time.
Possible solutions for your situation
Every situation is different and therefore I cannot give you the one that is best for your solution. However, you may try these solutions, in this order to restore your Magento installation and protect your data.
Preparations: As with all procedures you should take a backup of your current database
I have run into a situation where I reverted a database and then restored the original. Within the hour that it took me to do this multiple production orders had gone through the store and I lost the order data. I’ve learned my lesson. Take a backup! Always!
Solution 1: Restore Magento to the last working state
Restore your files to the last working version. Delete the /app/etc/module files that were created when installing new extensions. Revert the entire Magento revision to the last working version. Running an earlier version of the file base is less problematic than an old version of the database.
Then revert your database to the last working version, which also should have been the latest one.
Solution 2: Update the upgrade flag for this extension
As mentioned initially, Magento keeps record of every extensions version, so that it may upgrade and downgrade extensions easily. After a successful extension upgrade Magento will save the extensions version into the database. If the upgrade fails, Magento will never update the extension version and you will be left in a stalemate.
Depending on which extension is throwing the error that you’re seeing, you’ll want to adjust this following sql command to work for you. Here is the sql that I had to use to correct the problem above.
INSERT INTO `core_resource` (`code`,`version`,`data_version`)
VALUES ("oauth_setup", "1.6.0.4", "1.6.0.4");
Solution 3: Delete the database tables in question
If this was a new extension that caused this error, and you have no sensitive records within the database table in question, then you can delete the table and restore normal operations.
Solution 4: [If this is a fresh installation]
It is very difficult to correct a copy of Magento that just won’t install properly. Most of the time these are due to missing files. If this is a brand new installation and you have no sensitive data, then I suggest that you delete the entire file base, the database and start over. If you use the downloader file provided by Magento then you can eliminate the risk of having missing files.
Deleting a Magento database can be a frustrating experience, because Magento uses foreign keys. Use the following sql command prior to any query to drop tables.
SET FOREIGN_KEY_CHECKS=0;
Don’t Forget!
If these solutions have helped you, please post this link back to any forums where you were discussing your problem with other community members. Also, make sure to post comments here with your input.
Solution to "Base table or view already exists"
No comments:
Post a Comment