Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [foreign-key]

Denotes questions related to relational database foreign key

0
votes
1answer
23 views

Magneto Shipping country ID is shown as NULL in the reports

I'm using PostgreSQL in my data ware house for reporting purposes, and for a certain report I have to show the sum of revenue for each month grouped by country. When i pulled the report the ...
0
votes
0answers
18 views

Declarative schema: Incorrect Foreign Key Diff

We created a new table using M2's declarative scheme like this: <schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/...
0
votes
1answer
39 views

Magento 2 - Add foreign key with Existing table using db_schema.xml

I try to add 2 foreign key to my table using db_schema.xml <table name="test_table" engine="innodb" resource="default" > <column xsi:type="smallint" name="entity_id" identity="true" ...
0
votes
0answers
9 views

How to apply Foreign key to customer EAV in magento 2?

I have inserted the eav attribute using InstallData.php for customers like this, it's working fine but now i need to connect this attribute to school table in the database using foreign key. Can i ...
0
votes
1answer
132 views

Foreign key constraint is incorrectly formed after upgrade to 2.3.0

Please help!!!!!! I am upgrading from 2.1.7 to ver 2.3.0 I am stuck. I am not sure how no one else has the same issue. nothing related to this table on any forum. I am unable to Truncate, Delete this ...
2
votes
1answer
439 views

Magento 2 : Foreign key constraint is incorrectly formed, ALTER TABLE customer_group

After upgrade from magento 2.1.7 to 2.2.3 and am stuck. I have tried everything. In Pdo.php line 235: SQLSTATE[HY000]: General error: 1025 Error on rename of './zwwnzwzjhe/#sql-1bd1_25f9' to ...
5
votes
1answer
180 views

Magento 2.3 Error on Delete All Test Data from Database

We are in the process of migrating to Magento 2.3, but need to remove all test data from the database and reset all increment ID's back to 1. Having some troubles removing all order information: SET ...
1
vote
1answer
116 views

Error Add Foreign Key Using Install Schema Magento 2

<?php namespace Magneto\BookFreeLayout\Setup; use Magento\Framework\Setup\InstallSchemaInterface; use Magento\Framework\Setup\ModuleContextInterface; use Magento\Framework\Setup\...
1
vote
0answers
130 views

Foreign key constraint fails

I update schema newsletter_subscriber, certain I added firstname column which is a foreign key to customer_entity firstname, and when I post data the object with value is sent and in Magento insert ...
0
votes
1answer
236 views

Magento 2: foreign key for catalog_product_entity

Good evening. I am trying to create new table (product_store): <?php /** * @author Convert Team * @copyright Copyright (c) Convert (http://www.convert.no/) */ namespace Convert\...
0
votes
2answers
77 views

Moving Live database to a staging Server (M1)

I am moving my live database to a staging server in order to setup a development environment. I took two dumps of my live database structure without data dump data dump excluding the log tables ...
2
votes
0answers
39 views

In how many tables, product custom attribute entries saved?

Suppose I have a product custom attribute 'brand', after choosing one of the brand options & saving the product in how many tables this product attribute will be saved? attribute "brand" type is ...
0
votes
0answers
407 views

Cannot add or update a child row: a foreign key constraint fails

When I ran the manual query:- INSERT INTO `catalog_product_entity_varchar` (`attribute_id`, `store_id`, `entity_id`, `value`) VALUES (611, 0, 11, 559); from the database then DB then getting ...
0
votes
0answers
70 views

How to handle `catalog_product_entity` foreign key constraint while migrating M1 to M2

In M1, foreign key constraint was referenced to entity_id and now in M2 I see that core code is referenced to row_id. I have an extension's table in M1, which has entity_id as foreign key and now ...
0
votes
0answers
38 views

Deadlock order save creates invalid transaction thus breaking FK contraint

I have a weird problem when saving an order in a deadlock situation - which can happen with magento as we all know. It does not happen very often - maybe 1 time within 1000 orders. The order is saved ...
0
votes
0answers
322 views

Foreign key constraint fails Entity_Type_ID

Transferring my website database from 1.9.2.2 to 2.2.3 is successful. However if I then export and import again my database with foreign key checks enabled the below error is displayed. -- ...
1
vote
0answers
73 views

Database tables have no foreign keys

I have taken over a Magento 2 website and I have noticed quiet a few tables with no foreign keys e.g. a table is missing CONSTRAING 'CATALOG_PRODUCT_ENTITY_VARCHAR_STORE_ID_STORE_ID' FOREIGN KEY ('...
3
votes
1answer
1k views

Magento 2 failed database rollback cannot add foreign key constraints

I recently updated from magento v. 2.1.7 to 2.1.9 and then tried to update directly after that to 2.2.1. That failed and when i try to do a rollback (backup created before updating from 2.1.7) that ...
0
votes
0answers
67 views

Changing Status of Review creates duplicate in “review_detail” table

I've deleted my previous question and narrowed down the true issue causing this problem. For some reason, the review_detail table is creating duplicates whenever a review has it's status changed. ...
3
votes
1answer
84 views

Right syntax for the foreign key in InstallScript

When I adding a foreign key, I write something like: ->addForeignKey( $installer->getFkName('my_table_name', 'website_id', 'store_website', 'website_id'), 'website_id', '...
9
votes
1answer
244 views

Why Magento 2 `addForeignKey` function does not have `onUpdate` and how to add it while adding foreign key

I have started with Magento 2 setup scripts and I found one small change with Magento's addForeignKey function parameters. In Magento 1, the arguments for the function is like, public function ...
0
votes
0answers
540 views

Magento 2 Insert data to table that contain foreign key error SQLSTATE[23000]: Integrity constraint violation

i want to insert data to a table that contain foreign key, but it always gives me an error like this: [2017-01-18 04:45:51] main.ERROR: PDOException: SQLSTATE[23000]: Integrity constraint ...
1
vote
3answers
17k views

How to disable or remove foreign key before importing database to phpmyadmin?

We can import any heavy database into phpmyadmin from command prompt. But many tables have foreign key and it is not allowed to insert a table having foreign key. So how to remove or disable foreign ...
2
votes
0answers
199 views

Connecting Component Manager with Marketplace Account

We just created an instance of a 2.1 EE version. Everything works well and seems to work. But when we try to sign in into the component manager with our Magento account we get a RuntimeException with ...
0
votes
1answer
172 views

SQL error when trying to save product

There is an integrety violation when I try to save a product. I did some searches and some suggested to join tables and check for null values. I tried that without luck. How can I solve/debug this? ...
5
votes
1answer
3k views

Magento 2 : Upgrade Script Alter Column with Foreign Key via API

In a Magento 2 upgrade script, I wanted to modify (alter) a column to change its comment. Now that column has a foreign key. Whenever I call the modify column method of the setup class, Mysql reports ...
1
vote
1answer
1k views

Magento 2 foreign key error saving configurable product

I created a Magento 2.0.2 store and used : https://github.com/ubertheme/magento2_data_migration/releases to import from my 1.9.2 store. When i try to save one of my configurable products I get this ...
1
vote
2answers
2k views

Magento2 InstallSchema Error 1215

I am trying to create InstallSchema script in magento2. However, I get the fallowing error: SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint The code is as fallows: $table = $...
0
votes
1answer
473 views

Error on foreign key

I have added a product_id column in my table vaibhav_customtabs_product_entity. Now I am trying to add foreign key on product_id from catalog_product_entity->entity_id column, but it is throwing error....
2
votes
1answer
572 views

Copy sales_flat_quote_item table with foreign keys

I need to alter sales_flat_quote_item having large amount of data and do not want to hammer add to cart functionality. Then i have decided to alter table by copying data and structure of table. ...
0
votes
2answers
2k views

Foreign key fields auto increments conflicts in magento 2 install schema

I just converted the Magento 1(created by Ultimate Module Creator) module Install script for the new magento 2 Install-Schema script, here I got some trouble. The referencing fields also has the auto ...
0
votes
1answer
687 views

Can't reindex Product Prices: a foreign key constraint fails

I receive an error when trying to reindex Product Prices: "Some problem with reindexing process." Digging some more, I extracted this error message on exception.log: 2015-10-06T17:17:52+00:00 DEBUG (...
0
votes
1answer
737 views

Error saving programmatically created categories when flat categories enabled

I've been creating categories programmatically for a few years with no issues. Since the volume of categories has increased to a point where there is a significant performance degradation building ...
2
votes
1answer
247 views

EcomDev_PHPUnit - product price is null

I am trying to run the priceCalculation test from Ecomdev_PHPUnit manual (http://www.ecomdev.org/wp-content/uploads/2011/05/EcomDev_PHPUnit-0.2.0-Manual.pdf) but I get the following error: PHP Fatal ...
21
votes
1answer
12k views

How to add a foreign key to a table programmatically?

I am trying to add a set of new tables and I'm trying to add a foreign key to link these tables. I have looked online to try and find some information about addForeignKey() but cannot find anything. ...