jan-vandenberg / cruddiy

No-code Bootstrap PHP CRUD generator
http://cruddiy.com
GNU Affero General Public License v3.0
253 stars 80 forks source link

fix #102 Duplicate key name '<tablename>_ibfk_1' #103

Closed germain-italic closed 12 months ago

germain-italic commented 12 months ago

Problem #102 solved. I won't specify a constraint name and will let MySQL handle it, as it automatically generates a name for it. This auto-generated name typically follows a pattern like tablename_ibfk_n, where n is a number that increments for each new unnamed foreign key constraint added to the table.

Which is exactly what the original code was trying to do, minus the increment.

Bonus: I also add a feature to retrieve the correct key name in the confirmation message, because if you add multiple constraints on the same column, you have to query the last one that was added.

The confirmation error is still displayed at the top of the page without the Boostrap .alert style, but we'll deal with that later.