Calling Developers!
We are reenergizing our code contribution process! Learn More

What are the Slack Archives?

It’s a history of our time together in the Slack Community! There’s a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.

Because this space is not active, you won’t be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..

hi team , i have created new table test_article . and inside table i have a column order_id . I want

Options
U0500RK40NR
U0500RK40NR Posts: 57 🧑🏻‍🚀 - Cadet

hi team , i have created new table test_article . and inside table i have a column order_id . I want to make it foreign key with id_sales_order which is located in spy_sales_order table. But i am getting this error

Comments

  • U01BZ7Q3XRV
    U01BZ7Q3XRV Posts: 148 🧑🏻‍🚀 - Cadet
    Options

    its probably because you have a different column type (VARCHAR) for your local order_id, while spy_sales_order.id_sales_order is probably an integer -> They have to have the same type and size

  • U0500RK40NR
    U0500RK40NR Posts: 57 🧑🏻‍🚀 - Cadet
    Options

    ok let me check it

  • U0500RK40NR
    U0500RK40NR Posts: 57 🧑🏻‍🚀 - Cadet
    Options

    I have changed it but still getting same error

  • U0500RK40NR
    U0500RK40NR Posts: 57 🧑🏻‍🚀 - Cadet
    Options

    also i have deleted all the data from test_article table ..

  • U0500RK40NR
    U0500RK40NR Posts: 57 🧑🏻‍🚀 - Cadet
    Options

    and i was trying to delete sales_order table data but due to foreign key data is not deleting

  • U01BZ7Q3XRV
    U01BZ7Q3XRV Posts: 148 🧑🏻‍🚀 - Cadet
    Options

    hm ok. You could have a look at the table directly, if the type has been changed. And / or you could try to execture the ALTER TABLE statement directly in mysql to see if you get additional information about the error

  • U0500RK40NR
    U0500RK40NR Posts: 57 🧑🏻‍🚀 - Cadet
    Options

    the error is resolved now . It is mendatory to add onDelete="RESTRICT"

  • U01BZ7Q3XRV
    U01BZ7Q3XRV Posts: 148 🧑🏻‍🚀 - Cadet
    Options

    ok, good to hear. Not sure though, what restrict does tbh. In my last example I had on delete CASCADE, which also worked and should delete the foregin key data row when the row from the other table is deleted