Created
May 5, 2010 16:17
-
-
Save JustLikeIcarus/391028 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php defined('SYSPATH') or die('No direct script access.'); | |
class TicketsCommentsStatusesLabels extends Doctrine_Migration_Base | |
{ | |
public function up() | |
{ | |
$this->createTable('tickets', array( | |
'id' => array( | |
'type' => 'integer', | |
'length' => 8, | |
'notnull' => true, | |
'unsigned' => true, | |
'primary' => true, | |
'autoincrement' => true | |
), | |
'user_id' => array( | |
'type' => 'integer', | |
'length' => 8, | |
'notnull' => true, | |
'unsigned' => true, | |
), | |
'project_id' => array( | |
'type' => 'integer', | |
'length' => 8, | |
'notnull' => true, | |
'unsigned' => true, | |
), | |
'status_id' => array( | |
'type' => 'integer', | |
'length' => 8, | |
'notnull' => true, | |
'unsigned' => true, | |
), | |
'title' => array( | |
'type' => 'varchar', | |
'length' => 255 | |
), | |
'description' => array( | |
'type' => 'text' | |
), | |
'created_on' => array( | |
'type' => 'integer', | |
'length' => 8, | |
'notnull' => true, | |
'unsigned' => true, | |
), | |
'last_update' => array( | |
'type' => 'integer', | |
'length' => 8, | |
'notnull' => true, | |
'unsigned' => true, | |
), | |
), | |
array( | |
'type' => 'INNODB', | |
'charset' => 'utf8' | |
) | |
); | |
$this->createTable('comments', array( | |
'id' => array( | |
'type' => 'integer', | |
'length' => 8, | |
'notnull' => true, | |
'unsigned' => true, | |
'primary' => true, | |
'autoincrement' => true | |
), | |
'ticket_id' => array( | |
'type' => 'integer', | |
'length' => 8, | |
'notnull' => true, | |
'unsigned' => true, | |
), | |
'user_id' => array( | |
'type' => 'integer', | |
'length' => 8, | |
'notnull' => true, | |
'unsigned' => true, | |
), | |
'content' => array( | |
'type' => 'text' | |
), | |
'created_on' => array( | |
'type' => 'integer', | |
'length' => 8, | |
'notnull' => true, | |
'unsigned' => true, | |
), | |
'last_update' => array( | |
'type' => 'integer', | |
'length' => 8, | |
'notnull' => true, | |
'unsigned' => true, | |
), | |
), | |
array( | |
'type' => 'INNODB', | |
'charset' => 'utf8' | |
) | |
); | |
$this->createTable('statuses', array( | |
'id' => array( | |
'type' => 'integer', | |
'length' => 8, | |
'notnull' => true, | |
'unsigned' => true, | |
'primary' => true, | |
'autoincrement' => true | |
), | |
'name' => array( | |
'type' => 'varchar', | |
'length' => 50, | |
), | |
), | |
array( | |
'type' => 'INNODB', | |
'charset' => 'utf8' | |
) | |
); | |
$this->createTable('labels', array( | |
'id' => array( | |
'type' => 'integer', | |
'length' => 8, | |
'notnull' => true, | |
'unsigned' => true, | |
'primary' => true, | |
'autoincrement' => true | |
), | |
'name' => array( | |
'type' => 'varchar', | |
'length' => 50, | |
), | |
'color' => array( | |
'type' => 'varchar', | |
'length' => 6, | |
), | |
), | |
array( | |
'type' => 'INNODB', | |
'charset' => 'utf8' | |
) | |
); | |
$this->createTable('tickets_labels', array( | |
'ticket_id' => array( | |
'type' => 'integer', | |
'length' => 8, | |
'notnull' => true, | |
'unsigned' => true, | |
), | |
'label_id' => array( | |
'type' => 'integer', | |
'length' => 8, | |
'notnull' => true, | |
'unsigned' => true, | |
), | |
), | |
array( | |
'type' => 'INNODB', | |
'charset' => 'utf8' | |
) | |
); | |
} | |
public function down() | |
{ | |
$this->dropTable('tickets'); | |
$this->dropTable('statuses'); | |
$this->dropTable('comments'); | |
$this->dropTable('labels'); | |
$this->dropTable('tickets_labels'); | |
} | |
} |
Two reasons. The length of an INT type has no affect on the value it stores, it's just used for display purposes. Also, doctrine converts int's as follows.
if ($length <= 1) {
return 'TINYINT';
} elseif ($length == 2) {
return 'SMALLINT';
} elseif ($length == 3) {
return 'MEDIUMINT';
} elseif ($length == 4) {
return 'INT';
} elseif ($length > 4) {
return 'BIGINT';
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
why are you using length 8?