Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save JustLikeIcarus/391028 to your computer and use it in GitHub Desktop.

Select an option

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

zeelot commented May 5, 2010

Copy link
Copy Markdown

why are you using length 8?

@JustLikeIcarus

Copy link
Copy Markdown
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