Database tables foreign key error

Permalink
I'm trying to create several database tables in a db.xml file. However I keep getting an error related to the foreign key constraints.

This is what I have:
<field name="group_id" type="I">
  <constraint>
    , foreign key(group_id) references BuilderGroup(id)
  </constraint>
</field>
<field name="plan_id" type="I">
  <constraint>
    , foreign key(plan_id) references Plans(id)
  </constraint>
</field>


I keep getting an error that says the syntax is wrong.

mysql error: [1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'foreign key(group_id) references BuilderGroup(id)' at line 2] in EXECUTE("ALTER TABLE Price MODIFY COLUMN group_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT , foreign key(group_id) references BuilderGroup(id) ")

What am I doing wrong?

Silasj
 
Silasj replied on at Permalink Best Answer Reply
Silasj
This now works, but I don't know what I changed that did it.