SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP 'posts_user_id_foreign'; check that column/key exists

Error SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP 'posts_user_id_foreign'; check that column/key exists occurs when you try to delete the foreign key which does not already exist in your table.

Answers 1
  • Check constraints name 'posts_user_id_foreign' exists or not in SQL

    SELECT `TABLE_SCHEMA`, `TABLE_NAME` FROM `information_schema`.`KEY_COLUMN_USAGE` WHERE `CONSTRAINT_NAME` IN ('posts_user_id_foreign')
    
    0

    You can use the SQL query to check the CONSTRAINT_NAME 'posts_user_id_foreign' exists or not.

  • Back to code snippet queries related laravel