On your migration
$this->createTable('products', 'id, price decimal(10.2) index, name, is_promoted, created_by');
will automatically add indexes to boolean fields like is_index and to predictable foreign keys like created_by.
You implicitly can select the fields to index by using the keys index or idx
You also have an
$this->addIndex()
method
ADOdb Data Dictionary syntax can also be used on your migrations.
Thanks! I'm aware of the 'addIndex' function.
My wording was unclear, sorry. What I meant to say was how do I create a COMPOUND index key, which contains three columns inside it.
Reading through the ADOdb Data Dictionary link above it would appear that something like this should work (not tested)
$this->createTable('products', 'key1 TINYINT index idx_cmp, key2 TINYINT index idx_cmp, key3 TINYINT index idx_cmp, created_by');
But now if I use cloneRecord and any other Akelos active record functions, Akelos complains that it can't find the primary key column id. Does Akelos not handle Primary keys which are compound? Hmm. For now I'll work around it and add a regular 'id' key as the primary, but should that really be necessary? Food for thought.
Ok, after much experimenting, why does not this work?
$this->createTable('default_spots', array('columns' =>
'id,'.
'warehouse_id I2(1) NOTNULL INDEX idx_cmp,'.
'spot_id I2(1) NOTNULL INDEX idx_cmp,'.
'part_id I2(1) NOTNULL INDEX idx_cmp',
)
);
When I do yadda yadda install, it creates a table with four indexes. One for each column. According to 'ADOdb Data Dictionary', the ability to define index's with the INDEX keyword was added in v4.94. Would someone care to try the point out why it does not create only two index's (one for id, and one compound)? Thanks!
1 to 4 of 4