Adding a composite primary key for MySQL using Yii Migrations

Last updated:

Creating a composite PK(primary key) for a table so that GII can know you want a MANY_TO_MANY relation:

$this->createTable('bibliographic_item_checkout', array(
            'bibliographic_item_id'=>'int NOT NULL',
            'checkout_id'=>'int NOT NULL',
            'PRIMARY KEY (bibliographic_item_id,checkout_id)'
        ),'engine InnoDB');

where bibliographic_item_checkout is a table to simulate an N to N relationship between bibliographic_item and checkout.

This works for MySQL. Not sure about other DBMSs.

Dialogue & Discussion