Monday, September 24, 2012

Re: schema dump added auto increment on non auto increment table

This has nothing at all to do with CakePHP. In a join table, the
columns are foreign keys pointing to the id of some other tables.
THOSE values are usually (but not always) auto_increment. There's no
sense in making your FKs auto_inc because they're not being generated
out of thin air (for the join table).

You're also using InnoDB so you may as well explicitly define the FKs
and add constraints.

On Sun, Sep 23, 2012 at 10:06 PM, John Moses <moses.john.r@gmail.com> wrote:
> Hey guys,
> I was going to report a bug, but wanted to make sure it wasn't an error on
> my part or something in a model I was unaware of. A quick search didn't
> show anything in the groups or stackoverflow for this exact issue. There is
> a related issue at
> https://rails.lighthouseapp.com/projects/8994/tickets/4721-schema-dump-does-not-respect-autoincrement
>
> Here is the schema dump for the table in question:
>
>> CREATE TABLE `events`.`attendees_packages` (
>> `attendee_id` int(11) NOT NULL AUTO_INCREMENT,
>> `package_id` int(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (`attendee_id`,
>> `package_id`)) DEFAULT CHARSET=latin1,
>> COLLATE=latin1_swedish_ci,
>> ENGINE=InnoDB;
>
>
> And here is the column information in mysql:
>>
>> mysql> show full columns from attendees_packages;
>>
>> +-------------+---------+-----------+------+-----+---------+-------+---------------------------------+---------+
>> | Field | Type | Collation | Null | Key | Default | Extra |
>> Privileges | Comment |
>>
>> +-------------+---------+-----------+------+-----+---------+-------+---------------------------------+---------+
>> | attendee_id | int(11) | NULL | NO | PRI | NULL | |
>> select,insert,update,references | |
>> | package_id | int(11) | NULL | NO | PRI | NULL | |
>> select,insert,update,references | |
>>
>> +-------------+---------+-----------+------+-----+---------+-------+---------------------------------+---------+
>> 2 rows in set (0.11 sec)
>
>
> It is all of my hasMany association tables.
>
> Has anybody seen this before? Is it a configuration item I am missing?
> Thanks.
> John
>
> --
> Like Us on FacekBook https://www.facebook.com/CakePHP
> Find us on Twitter http://twitter.com/CakePHP
>
> ---
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com.
> To unsubscribe from this group, send email to
> cake-php+unsubscribe@googlegroups.com.
> Visit this group at http://groups.google.com/group/cake-php?hl=en.
>
>

--
Like Us on FacekBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate