Skip to content

Commit

Permalink
Fix down migration.
Browse files Browse the repository at this point in the history
Provide default value for NOT NULL columns.
  • Loading branch information
yunosh committed Mar 27, 2014
1 parent 1861b20 commit 12ebe91
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions wicked/migration/4_wicked_single_revisions.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,14 @@ public function up()
public function down()
{
/* Pages */
$this->addColumn('wicked_pages', 'page_majorversion', 'integer', array('null' => false));
$this->addColumn('wicked_pages', 'page_minorversion', 'integer', array('null' => false));
$this->addColumn('wicked_pages', 'page_majorversion', 'integer', array('null' => false, 'default' => 0));
$this->addColumn('wicked_pages', 'page_minorversion', 'integer', array('null' => false, 'default' => 0));
$this->update('UPDATE wicked_pages SET page_majorversion = page_version, page_minorversion = 0');
$this->removeColumn('wicked_pages', 'page_version');

$this->removePrimaryKey('wicked_history');
$this->addColumn('wicked_history', 'page_majorversion', 'integer', array('null' => false));
$this->addColumn('wicked_history', 'page_minorversion', 'integer', array('null' => false));
$this->addColumn('wicked_history', 'page_majorversion', 'integer', array('null' => false, 'default' => 0));
$this->addColumn('wicked_history', 'page_minorversion', 'integer', array('null' => false, 'default' => 0));
$this->update('UPDATE wicked_history SET page_majorversion = page_version, page_minorversion = 0');
$this->removeColumn('wicked_history', 'page_version');
$this->addPrimaryKey('wicked_history', array('page_id', 'page_majorversion', 'page_minorversion'));
Expand All @@ -182,14 +182,14 @@ public function down()
$attachment['attachment_version'] . '.0');
}

$this->addColumn('wicked_attachments', 'attachment_majorversion', 'integer', array('null' => false));
$this->addColumn('wicked_attachments', 'attachment_minorversion', 'integer', array('null' => false));
$this->addColumn('wicked_attachments', 'attachment_majorversion', 'integer', array('null' => false, 'default' => 0));
$this->addColumn('wicked_attachments', 'attachment_minorversion', 'integer', array('null' => false, 'default' => 0));
$this->update('UPDATE wicked_attachments SET attachment_majorversion = attachment_version, attachment_minorversion = 0');
$this->removeColumn('wicked_attachments', 'attachment_version');

$this->removePrimaryKey('wicked_attachment_history');
$this->addColumn('wicked_attachment_history', 'attachment_majorversion', 'integer', array('null' => false));
$this->addColumn('wicked_attachment_history', 'attachment_minorversion', 'integer', array('null' => false));
$this->addColumn('wicked_attachment_history', 'attachment_majorversion', 'integer', array('null' => false, 'default' => 0));
$this->addColumn('wicked_attachment_history', 'attachment_minorversion', 'integer', array('null' => false, 'default' => 0));
$this->update('UPDATE wicked_attachment_history SET attachment_majorversion = attachment_version, attachment_minorversion = 0');
$this->removeColumn('wicked_attachment_history', 'attachment_version');
$this->addPrimaryKey('wicked_attachment_history', array('page_id', 'attachment_name', 'attachment_majorversion', 'attachment_minorversion'));
Expand Down

0 comments on commit 12ebe91

Please sign in to comment.