I'm using ErWin 9.5 to generate DDL for MySQL 5.6 and have hit a snag when creating a foreign key. MYSQL does not use foreign key name generated by ErWin because the CONSTRAINT
statement is not included in the DDL.
The DDL ErWin generates for a simple FK relationship is:
ALTER TABLE table_two
ADD FOREIGN KEY table_two_ibfk_99b (table_one_id) REFERENCES table_one (table_one_id);
When this runs, MySQL generates the constraint with the name table_two_ibfk_1
and increments from there.
However, if I change the target database in ErWin to anything else it uses the proper syntax with the CONSTRAINT
statement. For example, with the target DB set to ODBC V3
, ErWin generates the following DDL:
ALTER TABLE table_two
ADD CONSTRAINT table_two_ibfk_99a FOREIGN KEY (table_one_id) REFERENCES table_one (table_one_id);
Problem with just using ODBC is that I loose the ability to AUTO_INCREMENT
my PKs.
Has anyone found a solution for this?