Skip to main content

Questions tagged [foreign-key]

Denotes questions related to relational database foreign key

Filter by
Sorted by
Tagged with
0 votes
1 answer
70 views

How to add new Foriegn Key in existing table in Magento 2.4.5

I am trying to add a new foriegn key in existing table using db_schema.xml but it is not working at all I tried to delete the table and delete module from setup_module table as well but still nothing ...
Syed Hassan Zamir's user avatar
0 votes
1 answer
142 views

db_schema can't set foreign key - Table [prefix]_sales_order do not have column with name "name"

I must add column1 to sales_order_grid and create foreign key to table sales_grid.column1 When i try use bin/magento setup:upgrade i get next message Table [myPrefix]_sales_order do not have column ...
esca7a's user avatar
  • 21
0 votes
1 answer
750 views

foreign key db_schema.xml automatic renamed to FK_ magento 2

I have this db_schema.xml <?xml version="1.0"?> <!-- /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ --> <schema xmlns:xsi=&...
fudu's user avatar
  • 1,298
0 votes
1 answer
1k views

Magento 2 - create a table with foreign key constraint

I try to add this database table. It has a foreign key constraint to the customer_entity table. I need to configure it so if the customer is getting deleted that record is also getting deleted. This ...
Black's user avatar
  • 3,392
4 votes
1 answer
712 views

How "cms_block_store" and "cms_page_store" tables are working with Primary keys in Magento?

I have a general doubt in MySql foreign key constraints and Magento. As per MySql, a table should have only one primary key for a table and a Primary key should contain unique values. I checked in &...
Siranjeevi K S's user avatar
1 vote
2 answers
6k views

how to SET FOREIGN_KEY_CHECKS = 0 in phpMyAdmin [closed]

I am trying to truncate some mySQL tables from phpMyAdmin web interface, but for foreign keys constraint I am not able to do it. Is there a way to SET FOREIGN_KEY_CHECKS = 0 in phpMyAdmin?
hln's user avatar
  • 125
0 votes
2 answers
279 views

Database not creating tables for new extensions on bin/magento setup:upgrade. Declarative Schema is not up to date

I installed Magento 2.3 successfully, with custom style sheet and Mageplaza Blog ext which all works fine. I wanted to install a slider module and I have done this through ssh. Composer installs the ...
F1sh's user avatar
  • 1
0 votes
1 answer
284 views

How does sales_quote and sales_quote_adress table relate?

In the sales_flat_quote table, there is a store_id column. In my perspective the customer order in the front-end (website) and in the back-end, Magento creates each quote for different stores, if my ...
Sathish Thangathurai's user avatar
1 vote
2 answers
2k views

disable or remove foreign keys during upgrade

During upgrade from v1.5.1.0 to v1.6.0 it is trying to drop a key but can't because of a foreign key. relevant lines in update script $installer->getConnection()->dropIndex( $installer->...
Brenda.ZMPOV's user avatar
0 votes
1 answer
104 views

Magento 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 ...
Sandeep's user avatar
  • 115
1 vote
1 answer
976 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/...
Tyler V.'s user avatar
  • 2,987
1 vote
1 answer
3k 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" ...
sayou's user avatar
  • 363
0 votes
1 answer
1k 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 ...
roger's user avatar
  • 551
5 votes
1 answer
4k 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 ...
roger's user avatar
  • 551
5 votes
1 answer
1k 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 ...
AJK's user avatar
  • 751
1 vote
1 answer
2k 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\...
Harsh Jayswal's user avatar
1 vote
0 answers
561 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 ...
Newb's user avatar
  • 95
1 vote
1 answer
2k 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\...
Denissio Inkognito's user avatar
0 votes
2 answers
291 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 ...
umair.ashfr's user avatar
2 votes
0 answers
197 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 ...
Wakar Ahamad's user avatar
0 votes
0 answers
687 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. -- ...
Stuart's user avatar
  • 107
1 vote
0 answers
213 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 ('...
Joe's user avatar
  • 11
3 votes
1 answer
3k 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 ...
rawley-swe's user avatar
0 votes
0 answers
138 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. ...
Steven J's user avatar
  • 808
3 votes
1 answer
110 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', '...
Siarhey Uchukhlebau's user avatar
10 votes
1 answer
340 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 ...
Jaimin Sutariya's user avatar
0 votes
0 answers
1k 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 ...
Idham Choudry's user avatar
1 vote
3 answers
57k 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 ...
Kazim Noorani's user avatar
2 votes
0 answers
299 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 ...
Andreas Daoutis's user avatar
0 votes
1 answer
205 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? ...
Akif's user avatar
  • 1,551
5 votes
1 answer
5k 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 ...
hakre's user avatar
  • 2,841
1 vote
1 answer
2k 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 ...
Jackie Lowery's user avatar
1 vote
2 answers
4k 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 = $...
Lachezar Raychev's user avatar
0 votes
1 answer
628 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....
Vaibhav Dass's user avatar
2 votes
1 answer
754 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. ...
Aniruddha A Deshpande's user avatar
0 votes
2 answers
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 ...
Dev's user avatar
  • 1,154
0 votes
1 answer
793 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 (...
Peanuts's user avatar
  • 365
0 votes
1 answer
964 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 ...
Mark's user avatar
  • 53
2 votes
1 answer
263 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 ...
Maciek Lewkowicz's user avatar
22 votes
1 answer
14k 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. ...
tony09uk's user avatar
  • 1,707