Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions core/migrations/Migration20200917000000AuthLinkIndex.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

use Hubzero\Content\Migration\Base;

// no direct access
defined('_HZEXEC_') or die();

/**
* Migration script for adding indexes to the #__auth_link table.
**/
class Migration202000171000000AuthLinkIndex extends Base
{
public function up()
{
if ($this->db->tableExists('#__auth_link'))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only Run IF the index isn't already there.

{
if (!$this->db->tableHasKey('#__auth_link', 'auth_domain_id_idx'))
{
$query = "ALTER TABLE `#__auth_link` ADD INDEX auth_domain_id_idx (auth_domain_id);";
$this->db->setQuery($query);
$this->db->query();
}

if (!$this->db->tableHasKey('#__auth_link', 'user_id_idx'))
{
$query = "ALTER TABLE `#__auth_link` ADD INDEX user_id_idx (user_id);";
$this->db->setQuery($query);
$this->db->query();
}
}
}

public function down()
{
if ($this->db->tableExists('#__auth_link'))
{
if ($this->db->tableHasKey('#__auth_link', 'auth_domain_id_idx'))
{
$query = "ALTER TABLE `#__auth_link` DROP INDEX auth_domain_id_idx;";
$this->db->setQuery($query);
$this->db->query();
}

if ($this->db->tableHasKey('#__auth_link', 'user_id_idx'))
{
$query = "ALTER TABLE `#__auth_link` DROP INDEX user_id_idx;";
$this->db->setQuery($query);
$this->db->query();
}
}
}

}
35 changes: 35 additions & 0 deletions core/migrations/Migration20200917100000AuthDomainIndex.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

use Hubzero\Content\Migration\Base;

// no direct access
defined('_HZEXEC_') or die();

/**
* Migration script for adding indexes to the #__auth_domain table.
**/
class Migration202000171000000AuthDomainIndex extends Base
{
public function up()
{
if ($this->db->tableExists('#__auth_domain') &&
!$this->db->tableHasKey('#__auth_domain', 'authenticator_idx'))
{
$query = "ALTER TABLE `#__auth_domain` ADD INDEX authenticator_idx (authenticator);";
$this->db->setQuery($query);
$this->db->query();
}
}

public function down()
{
if ($this->db->tableExists('#__auth_domain') &&
$this->db->tableHasKey('#__auth_domain', 'authenticator_idx'))
{
$query = "ALTER TABLE `#__auth_domain` DROP INDEX authenticator_idx;";
$this->db->setQuery($query);
$this->db->query();
}
}

}