Skip to content

Commit

Permalink
Skip the tag migrations if the Content migration has not been run.
Browse files Browse the repository at this point in the history
This would ony happen on a clean system when running horde-db-migrate. In
this case, there would be no data to migrate anyway, so it's safe to ignore
the tag migrations in the interest of allowing the migrations to run in any order.
  • Loading branch information
mrubinsk committed Mar 25, 2014
1 parent 91d397f commit 08f6040
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 11 deletions.
8 changes: 8 additions & 0 deletions ansel/migration/4_ansel_upgrade_tagstocontent.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ public function up()
if (!class_exists('Content_Tagger')) {
throw new Ansel_Exception('The Content_Tagger class could not be found. Make sure the Content application is installed.');
}
$tableList = $this->tables();
if (!in_array('rampage_types')) {
// Migrations on a clean install may not have run the Content
// migration yet...and since it's a clean install, we won't have
// any data to migrate here anyway.
$this->announce('Skipping migration since the Content tables are not available.');
return;
}
$type_mgr = $GLOBALS['injector']->getInstance('Content_Types_Manager');
$types = $type_mgr->ensureTypes(array('gallery', 'image'));
$this->_type_ids = array(
Expand Down
8 changes: 8 additions & 0 deletions ansel/migration/5_ansel_upgrade_categoriestotags.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ public function up()
if (!class_exists('Content_Tagger')) {
throw new Horde_Exception('The Content_Tagger class could not be found. Make sure the Content application is installed.');
}
$tableList = $this->tables();
if (!in_array('rampage_types')) {
// Migrations on a clean install may not have run the Content
// migration yet...and since it's a clean install, we won't have
// any data to migrate here anyway.
$this->announce('Skipping migration since the Content tables are not available.');
return;
}
$type_mgr = $GLOBALS['injector']->getInstance('Content_Types_Manager');
$types = $type_mgr->ensureTypes(array('gallery', 'image'));
$this->_type_ids = array(
Expand Down
18 changes: 16 additions & 2 deletions kronolith/migration/18_kronolith_upgrade_categoriestotags.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,27 @@ protected function _init()
if (!class_exists('Content_Tagger')) {
throw new Horde_Exception('The Content_Tagger class could not be found. Make sure the Content application is installed.');
}
$tableList = $this->tables();
if (!in_array('rampage_types')) {
// Migrations on a clean install may not have run the Content
// migration yet...and since it's a clean install, we won't have
// any data to migrate here anyway.
return false;
}
$type_mgr = $GLOBALS['injector']->getInstance('Content_Types_Manager');
$types = $type_mgr->ensureTypes(array('calendar', 'event'));
$this->_type_ids = array('calendar' => (int)$types[0], 'event' => (int)$types[1]);
$this->_tagger = $GLOBALS['injector']->getInstance('Content_Tagger');
$this->_shares = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Share')->create('kronolith');
return true;
}

public function up()
{
$this->_init();
if (!$this->_init()) {
$this->announce('Skipping migration since the Content tables are not available.');
return;
}
$sql = 'SELECT event_uid, event_category, event_creator_id, calendar_id FROM kronolith_events';
$this->announce('Migrating event categories to tags.');
$rows = $this->select($sql);
Expand Down Expand Up @@ -62,7 +73,10 @@ public function up()

public function down()
{
$this->_init();
if (!$this->_init()) {
$this->announce('Skipping migration since the Content tables are not available.');
return;
}
$this->addColumn('kronolith_events', 'event_category', 'string', array('limit' => 80));
$this->announce('Migrating event tags to categories.');
$sql = 'UPDATE kronolith_events SET event_category = ? WHERE event_uid = ?';
Expand Down
19 changes: 16 additions & 3 deletions mnemo/migration/6_mnemo_upgrade_categoriestotags.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@ protected function _init()
if (!class_exists('Content_Tagger')) {
throw new Horde_Exception('The Content_Tagger class could not be found. Make sure the Content application is installed.');
}

$tableList = $this->tables();
if (!in_array('rampage_types')) {
// Migrations on a clean install may not have run the Content
// migration yet...and since it's a clean install, we won't have
// any data to migrate here anyway.
return false;
}
$type_mgr = $GLOBALS['injector']->getInstance('Content_Types_Manager');
$types = $type_mgr->ensureTypes(array('note'));
$this->_type_ids = array('note' => (int)$types[0]);
Expand All @@ -38,11 +44,15 @@ protected function _init()
$this->_shares = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Share')->create('mnemo');
} catch (Exception $e) {
}
return true;
}

public function up()
{
$this->_init();
if (!$this->_init()) {
$this->announce('Skipping migration since the Content tables are not available.');
return;
}
if ($this->_shares) {
$sql = 'SELECT memo_uid, memo_category, memo_owner FROM mnemo_memos';
$this->announce('Migrating note categories to tags.');
Expand All @@ -67,7 +77,10 @@ public function up()

public function down()
{
$this->_init();
if (!$this->_init()) {
$this->announce('Skipping migration since the Content tables are not available.');
return;
}
$this->addColumn('mnemo_memos', 'memo_category', 'string', array('limit' => 80));
$this->announce('Migrating note tags to categories.');
$sql = 'UPDATE mnemo_memos SET memo_category = ? WHERE memo_uid = ?';
Expand Down
19 changes: 16 additions & 3 deletions nag/migration/10_nag_upgrade_categoriestotags.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@ protected function _init()
if (!class_exists('Content_Tagger')) {
throw new Horde_Exception('The Content_Tagger class could not be found. Make sure the Content application is installed.');
}

$tableList = $this->tables();
if (!in_array('rampage_types')) {
// Migrations on a clean install may not have run the Content
// migration yet...and since it's a clean install, we won't have
// any data to migrate here anyway.
return false;
}
$type_mgr = $GLOBALS['injector']->getInstance('Content_Types_Manager');
$types = $type_mgr->ensureTypes(array('task'));
$this->_type_ids = array('task' => (int)$types[0]);
Expand All @@ -37,11 +43,15 @@ protected function _init()
$this->_shares = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Share')->create('nag');
} catch (Exception $e) {
}
return true
}

public function up()
{
$this->_init();
if (!$this->_init()) {
$this->announce('Skipping migration since the Content tables are not available.');
return;
}
$sql = 'SELECT task_uid, task_category, task_creator, task_owner FROM nag_tasks';
$this->announce('Migrating task categories to tags.');
$rows = $this->select($sql);
Expand Down Expand Up @@ -76,7 +86,10 @@ public function up()

public function down()
{
$this->_init();
if (!$this->_init()) {
$this->announce('Skipping migration since the Content tables are not available.');
return;
}
$this->addColumn('nag_tasks', 'task_category', 'string', array('limit' => 80));
$this->announce('Migrating task tags to categories.');
$sql = 'UPDATE nag_tasks SET task_category = ? WHERE task_uid = ?';
Expand Down
20 changes: 17 additions & 3 deletions turba/migration/10_turba_upgrade_categoriestotags.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,13 @@ protected function _init()
if (!class_exists('Content_Tagger')) {
throw new Horde_Exception('The Content_Tagger class could not be found. Make sure the Content application is installed.');
}

$tableList = $this->tables();
if (!in_array('rampage_types')) {
// Migrations on a clean install may not have run the Content
// migration yet...and since it's a clean install, we won't have
// any data to migrate here anyway.
return false;
}
$type_mgr = $GLOBALS['injector']->getInstance('Content_Types_Manager');
$types = $type_mgr->ensureTypes(array('contact'));
$this->_type_ids = array('contact' => (int)$types[0]);
Expand All @@ -55,11 +61,16 @@ protected function _init()
->create('turba');
} catch (Exception $e) {
}

return true;
}

public function up()
{
$this->_init();
if (!$this->_init()) {
$this->announce('Skipping migration since the Content tables are not available.');
return;
}
if ($this->_shares) {
$sql = 'SELECT object_uid, object_category, owner_id FROM turba_objects';
$this->announce('Migrating contact categories to tags.');
Expand Down Expand Up @@ -88,7 +99,10 @@ public function up()

public function down()
{
$this->_init();
if (!$this->_init()) {
$this->announce('Skipping migration since the Content tables are not available.');
return;
}
$this->addColumn('turba_objects', 'object_category', 'string', array('limit' => 80));
$this->announce('Migrating contact tags to categories.');
$sql = 'UPDATE turba_objects SET object_category = ? WHERE object_uid = ?';
Expand Down

0 comments on commit 08f6040

Please sign in to comment.