Hello, I'm trying to do a ALTER TABLE to add a foreign key. The code is: execute "ALTER TABLE table1 ADD CONSTRAINT FOREIGN KEY `const_fk_table1_table2_id` (`table2_id`) REFERENCES `table2` (`id`) ON DELETE CASCADE" Instead of creating a foreign key constraint with the name "const_fk_table1_table2_id" it will create one with the name "table2_ibfk_1". First I've added an index with : add_index :table1, :table2_id, :name => 'fk_table1_table2_id' Am I doing something wrong?
on 2007-06-26 15:07
on 2007-06-26 15:14
Problem fixed. The name comes after the CONSTRAINT not the FOREIGN KEY keywords.