For some reason, the migration system is not behaving well with auto_increment primary keys. Is it a bug? (I'm using phalcon 2.0.1)
I have the following auto generated migration:
class LanguagesMigration_100 extends Migration
{
public function up()
{
$this->morphTable(
'languages',
array(
'columns' => array(
new Column(
'id',
array(
'type' => Column::TYPE_INTEGER,
'notNull' => true,
'autoIncrement' => true,
'size' => 11,
'first' => true
)
),
new Column(
'ccode',
array(
'type' => Column::TYPE_VARCHAR,
'notNull' => true,
'size' => 6,
'after' => 'id'
)
),
new Column(
'active',
array(
'type' => Column::TYPE_INTEGER,
'notNull' => true,
'size' => 1,
'after' => 'ccode'
)
)
),
'indexes' => array(
new Index('PRIMARY', array('id')),
new Index('UNIQ_A0D153794EE11504', array('ccode'))
),
'options' => array(
'TABLE_TYPE' => 'BASE TABLE',
'AUTO_INCREMENT' => '9',
'ENGINE' => 'InnoDB',
'TABLE_COLLATION' => 'utf8_unicode_ci'
)
)
);
}
}
But when I run that migration, the generated sql does:
==> default: Phalcon DevTools (2.0.1)
==> default: 1432127144.0475
==> default: :
==> default: SELECT IF(COUNT(*)>0, 1 , 0) FROM `INFORMATION_SCHEMA`.`TABLES` WHERE `TABLE_NAME`= 'languages' AND `TABLE_SCHEMA` = 'euromillions'
==> default: =>
==> default: 1432127144.0619
==> default: (
==> default: 0.014361143112183
==> default: )
==> default: 1432127144.0767
==> default: :
==> default: DESCRIBE `euromillions`.`languages`
==> default: =>
==> default: 1432127144.1014
==> default: (
==> default: 0.024682998657227
==> default: )
==> default: 1432127144.1033
==> default: :
==> default: ALTER TABLE `languages` MODIFY `id` INT(11) NOT NULL
==> default: => 1432127144.1488 (0.045513153076172)
==> default: 1432127144.1489: ALTER TABLE `languages` ADD `active` INT(1) NOT NULL AFTER ccode
==> default: => 1432127144.17 (0.021080017089844)
==> default: 1432127144.1701: SHOW INDEXES FROM `euromillions`.`languages`
==> default: => 1432127144.1715 (0.001410961151123)
==> default: 1432127144.1717: ALTER TABLE `languages` ADD INDEX `UNIQ_A0D153794EE11504` (`ccode`)
==> default: => 1432127144.181 (0.0093460083007812)
==> default: 1432127144.1811: ALTER TABLE `languages` DROP INDEX `ccode`
==> default: => 1432127144.185 (0.0038588047027588)
==> default: 1432127144.185: ALTER TABLE `languages` DROP INDEX `ccode_2`
==> default: => 1432127144.1883 (0.0032830238342285)
==> default:
==> default: Success: Version 1.0.0 was successfully migrated
As you can see, the id field is modified not including an auto_increment.