Ticket #950 (closed defect: fixed)
Auto Create INDEX on FOREIGN KEY REFERENCE on MySQL (exportClasses)
| Reported by: | cferry | Owned by: | jwage |
|---|---|---|---|
| Priority: | minor | Milestone: | |
| Component: | Attributes | Version: | 0.11.0 |
| Severity: | Keywords: | ||
| Cc: | Has Test: | no | |
| Status: | Pending Core Response | Has Patch: | no |
Description
Hi!
I found a little bug in exportClasses method.
In fact, when i create a FOREIGN KEY using :
$this->hasOne('CountryRecord as Country', array('local' => 'pays', 'foreign' => 'iso'));
I get the following message :
SQLSTATE[HY000]: General error: 1005 Can't create table './mydatabase/#sql-c5f_b0.frm' (errno: 150).
because MySQL need an INDEX on FOREIGN KEY REFERENCE (iso field)
if I add $this->index('iso', array('fields' => 'iso')); in CountryRecord.
The problem is solved.
I think the best way is exportClasses auto add an index on foreign key reference to prevent this error.
Thank you in advance
regards
Cédric FERRY
www.emisfr.com
Change History
Note: See
TracTickets for help on using
tickets.