Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zeelot/391063 to your computer and use it in GitHub Desktop.
Save zeelot/391063 to your computer and use it in GitHub Desktop.
Sample Doctrine Migration
<?php defined('SYSPATH') or die('No direct script access.');
class TicketsCommentsStatusesLabels extends Doctrine_Migration_Base
{
public function up()
{
// Types
$int = array('type' => 'integer', 'length' => 8);
$varchar = array('type' => 'varchar', 'length' => 255);
$text = array('type' => 'text');
// Attributes
$notnull = array('notnull' => TRUE);
$unsigned = array('unsigned' => TRUE);
$pk = array('primary' => TRUE);
$ai = array('autoincrement' => TRUE);
$this->createTable('tickets', array
(
'id' => $int + $notnull + $unsigned + $ai + $pk,
'user_id' => $int + $notnull + $unsigned,
'project_id' => $int + $notnull + $unsigned,
'status_id' => $int + $notnull + $unsigned,
'title' => $varchar,
'description' => $text,
'created_on' => $int + $notnull + $unsigned,
'last_update' => $int + $notnull + $unsigned,
),
array
(
'type' => 'INNODB',
'charset' => 'utf8'
));
$this->createTable('comments', array
(
'id' => $int + $notnull + $unsigned + $ai + $pk,
'ticket_id' => $int + $notnull + $unsigned,
'user_id' => $int + $notnull + $unsigned,
'content' => $text,
'created_on' => $int + $notnull + $unsigned,
'last_update' => $int + $notnull + $unsigned,
),
array
(
'type' => 'INNODB',
'charset' => 'utf8'
));
$this->createTable('statuses', array
(
'id' => $int + $notnull + $unsigned + $ai + $pk,
'name' => array('length' => 50) + $varchar,
),
array
(
'type' => 'INNODB',
'charset' => 'utf8'
));
$this->createTable('labels', array(
'id' => $int + $notnull + $unsigned + $ai + $pk,
'name' => array('length' => 50) + $varchar,
'color' => array('length' => 6) + $varchar,
),
array
(
'type' => 'INNODB',
'charset' => 'utf8'
));
$this->createTable('tickets_labels', array
(
'ticket_id' => $int + $notnull + $unsigned,
'label_id' => $int + $notnull + $unsigned,
),
array
(
'type' => 'INNODB',
'charset' => 'utf8'
));
}
public function down()
{
$this->dropTable('tickets');
$this->dropTable('statuses');
$this->dropTable('comments');
$this->dropTable('labels');
$this->dropTable('tickets_labels');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment