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

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

    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

    ok let me check it

  • U0500RK40NR
    U0500RK40NR Posts: 57 πŸ§‘πŸ»β€πŸš€ - Cadet

    I have changed it but still getting same error

  • U0500RK40NR
    U0500RK40NR Posts: 57 πŸ§‘πŸ»β€πŸš€ - Cadet

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

  • U0500RK40NR
    U0500RK40NR Posts: 57 πŸ§‘πŸ»β€πŸš€ - Cadet

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

  • U01BZ7Q3XRV
    U01BZ7Q3XRV Posts: 148 πŸ§‘πŸ»β€πŸš€ - Cadet

    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

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

  • U01BZ7Q3XRV
    U01BZ7Q3XRV Posts: 148 πŸ§‘πŸ»β€πŸš€ - Cadet

    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