I am attempting to upgrade a clients Magento to v1.7 (from v1.4). I have had a couple of minor blips along the way, but nothing too tragic.... until now.
My upgrade route is to copy the existing v1.4 database and install a fresh version of 1.7. Then running the standard upgrade script, the database should get upgraded to v1.7 (except of course any installed extensions which will need re installing following the upgrade). This is a route I have used before and seems far more reliable that upgrading via magento connect.
However, I have hit a brick wall. I am getting the following error report:
a:5:{i:0;s:464:"Error in file: "/route/to/magento/install/app/code/core/Mage/Cms/data/cms_setup/data-upgrade-1.6.0.0.0-1.6.0.0.1.php" - SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`magento_1411_1702/cms_page_store`, CONSTRAINT `FK_CMS_PAGE_STORE_STORE_ID_CORE_STORE_STORE_ID` FOREIGN KEY (`store_id`) REFERENCES `core_store` (`store_id`) ON DELETE CASCADE ON UPDATE CASCAD)";i:1;s:1095:"#0 /route/to/magento/install/app/code/core/Mage/Core/Model/Resource/Setup.php(645): Mage::exception('Mage_Core', 'Error in file: ...')
Now this infers to me that there is a record in cms_page_store which has a store_id which cannot be found in the related table (in this case the ONLY related table is core_store). This is not the case. There was a record in core_store with no entries in cms_page_store and even though this did not break the referential integrity, I have removed it in desperation, without success.
I have also checked the records in the other immediately related tables and still cannot find the reason for the error.
Any ideas?
When doing the update from 1.4 to 1.7 I had to empty two tables before succeeding. Before that I got all kinds of weird errors.
The tables I emptied (not deleted, only emptied) are:
report_compared_product_index & report_viewed_product_index
Try if that helps in your case, too.
Oh, I forgot, in case you wonder. The tables are used for non-essential statistical data about compared and viewed products. If you are dependent on accurate store statistics of the past, then you might need to dig deeper into this issue.
Try it
SET FOREIGN_KEY_CHECKS=0;
UPDATE `core_store` SET store_id = 0 WHERE code='admin';
UPDATE `core_store_group` SET group_id = 0 WHERE name='Default';
UPDATE `core_website` SET website_id = 0 WHERE code='admin';
UPDATE `customer_group` SET customer_group_id = 0 WHERE customer_group_code='NOT LOGGED IN';
SET FOREIGN_KEY_CHECKS=1;
Can you verify that you have an admin store in core_store that has store_id 0? I've bumped into similar issues with primary key IDs shifting and some assumptions made during upgrade scripts.
Related
I was querying against SQL Server to get all columns, that are referenced to other columns. By accident I saw, that the column "tenantId" (table "AbpUsers") is not referenced to AbpTenants.Id.
I asked some of my collegues, that are "used" to know aspnetboilerplate, just to clarify. Everyone was surprised, as I am.
Just for testing purposes I created a new database by "Update-database". Before running the application, I added the "missing" foreign-Key-reference manually. And? Nothing happened. Nothing bad happened. Everything works, as it did without the foreign-key-reference...
ALTER TABLE [dbo].[AbpUsers] WITH CHECK ADD CONSTRAINT [FK_AbpUsers_AbpTenants_TenantId] FOREIGN KEY([TenantId])
REFERENCES [dbo].[AbpTenants] ([Id])
GO
ALTER TABLE [dbo].[AbpUsers] CHECK CONSTRAINT [FK_AbpUsers_AbpTenants_TenantId]
GO
As expected my whole application works fine, even when the initial content builder is running.
Keys exist mainly to protect referential integrity of the database. If you have no Cascade Update or Cascade Delete options on, then maybe this key was removed to make deleting things easier for someone who did not know what they were doing.
I want to migrate product, category from magento 1.9.3.0 to 2.1.7. How to do it? I used UberTheme Migration tool. But it could not work. Show
CDbException
CDbCommand failed to execute the SQL statement: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '539' for key 'PRIMARY'. The SQL statement executed was: INSERT INTO catalog_product_entity_media_gallery (attribute_id, media_type, disabled, value_id, value) VALUES (:yp0, :yp1, :yp2, :yp3, :yp4)
in setp5 then stop the script.
You don't need to use UberTheme Migration Tool. It's not working properly. Instead of that you can use Magento's default migration tool. Which can not even products but it will import orders, attributes, attributes set etc. Almost all the data from Magento 1 to Magento 2.
I had personally used it and it's really work fine. Below is the URL it may help you.
http://devdocs.magento.com/guides/v2.0/migration/migration-tool-install.html
I am evaluating a Laravel/PHP component meant to manage tree data in a SQL database using the "closure Table" design pattern. Code repository: https://github.com/franzose/ClosureTable
Oh my, this component gives me endless headaches. After some installation hickups (Lifetime cost: 2 days ...) I got one little step forward, and ran into what seems to be a really serious compatibility problem with the Microsoft SQL server. When the database ist created through the migration provided by the component, I get the following fatal SQL error:
[Illuminate\Database\QueryException]
SQLSTATE[42000]: [Microsoft][ODBC Driver 11 for SQL Server][SQL
Server]Introducing FOREIGN KEY constraint 'pages_parent_id_foreign' on
table 'pages' may cause cycles or multiple cascade paths. Specify ON
DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY
constraints. (SQL: alter table "pages" add constraint
"pages_parent_id_foreign" foreign key ("parent_id") references "pages"
("id") on delete set null)
A similar problem has been described here:
Foreign key constraint may cause cycles or multiple cascade paths?
Anyone having an idea how I can fix this, without breaking the component?
Thnx, Armin.
P.S. I also filed an issue hoping to get teh developer's attraction: Link to Git issue
When I tries to add the simple product to configurable product I am getting the below error
SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or
update a child row: a foreign key constraint fails
(db_mydb.catalog_product_super_link, CONSTRAINT
FK_CAT_PRD_SPR_LNK_PRD_ID_CAT_PRD_ENTT_ENTT_ID FOREIGN KEY
(product_id) REFERENCES catalog_product_entity (entity_id) ON DELE)
But this was working perfectly before. Anyone has idea, What could be the reason.?
Much appreciated your help.
But this was working perfectly before
Step one would be "what have you changed since before"? Installing custom extensions may change system behavior, so if you've installed anything recently (or even if you haven't, it's possible the bug's been lurking but you hadn't tried the specific save code path before) try disabling extensions in a development environment until the error doesn't happen anymore.
It's also worth checking out your catalog_product_super_link table and the specific query that's running when you get this foreign constraint error. It sounds like Magento tried to remove a product from this table, catalog_product_super_link, but doing do would cause a data integrity violation.
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '3262-1' for key 'UNQ_CATALOGINVENTORY_STOCK_ITEM_PRODUCT_ID_STOCK_ID'#
This appears when I am trying to add stock to my store, and obviously deletes what I have entered and doesn't let me add anything, help me fix this please, I'm not the most amazing on the computer, so please bare this in mind.
Thanks
Changing
$product->save();
to
$product->getResource()->save($product);
solved this problem for me
I have faced the same issue and debugging it since two days. finally I got the solution and fixed the issue.
This was occurred due to the inconsistency into database tables.
cataloginventory_stock_item
catalog_product_entity
I have removed the all inconsistency data using below query:
DELETE FROM cataloginventory_stock_item where product_id NOT IN (select entity_id from catalog_product_entity)
You can check how much records before perform the delete.
select count(*) from cataloginventory_stock_item where product_id NOT IN (select entity_id from catalog_product_entity)
May be this can help someone!
This error you can look in magento forum.
http://www.magentocommerce.com/boards/viewthread/300959/
This is error with sql index link. Yuo can use $product->getResource()->save($product); for resolve this problem.
https://stackoverflow.com/a/14152754/1844561
It took me hours on google trying to find the correct info that was easy to follow for an amature like me. Eventually using different sources, I figured out what I needed to delete and where I needed to delete it. The below worked for me, hope it works for you.
Go to your database
Find the table named "cateloginventory_stock_item
Delete the last few records on the list (at the bottom of the table)
Voila! You should now be able to enter new products.
1062 Duplicate entry '3262-1' for key 'UNQ_CATALOGINVENTORY_STOCK_ITEM_PRODUCT_ID_STOCK_ID'#
from this its clear that there is some unique constraint and 3262 value already exist in data base.
I suggest you run reindexing and then check.
Basically some entry 3262 didnt got deleted from your stock table so a new entry is throwing error.
I was facing similar issue and fix which I have applied is as follow :
Error : SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '59457-1' for key 'UNQ_CATALOGINVENTORY_STOCK_ITEM_PRODUCT_ID_STOCK_ID'
Solution : There is a table called eav_entity_store, you will have to modify a record where sku / product ID is mentioned, Increase the Increment ID to + 1
and update that record in database. Once you update the Increment ID then you will be able to add the stock.
For Example: If "eav_entity_store" table has last increment_last_id as = 730354, then
I will have to update that record to 730355 and my problem will get resolved :)
SQL Query: update eav_entity_store set increment_last_id = '730355' where eav_entity_store.entity_store_id =$YourStoreID;
if the error showing for the table 'cataloginventory_stock_item' having 'UNQ_CATALOGINVENTORY_STOCK_ITEM_PRODUCT_ID_STOCK_ID' index,
then please sure that you are passing different product SKU from your script each time.because if you pass the same SKU then it will fetch the id of the product on the basis of that SKU and get the duplicate entry of that particular product id.
Also Never Use
$product->save();
to
$product->getResource()->save($product);
because it will not update your product details completely.