Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save JustLikeIcarus/391028 to your computer and use it in GitHub Desktop.
Save JustLikeIcarus/391028 to your computer and use it in GitHub Desktop.
<?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');
}
}
@zeelot
Copy link

zeelot commented May 5, 2010

why are you using length 8?

@JustLikeIcarus
Copy link
Author

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