- Модуль: sale
- Путь к файлу: ~/bitrix/modules/sale/lib/location/migration/migrate.php
- Класс: BitrixSaleLocationMigrationCUpdaterLocationPro
- Вызов: CUpdaterLocationPro::updateDBSchemaRenameIndexes
static function updateDBSchemaRenameIndexes()
{
global $DB;
$updater = new CUpdater();
$updater->Init($curPath = "", 'mysql', $updaterName = "", $curDir = "", "sale", "DB");
$locationTableExists = $updater->TableExists("b_sale_location");
if($locationTableExists) // module might not be installed, but tables may exist
{
// b_sale_location
if(static::checkIndexExistsByName('IX_SALE_LOCATION_CODE', 'b_sale_location'))
{
static::dropIndexByName('IX_SALE_LOCATION_CODE', 'b_sale_location');
$DB->query('create unique index IX_B_SALE_LOC_CODE on b_sale_location (CODE)');
}
if(static::checkIndexExistsByName('IX_SALE_LOCATION_MARGINS', 'b_sale_location'))
{
static::dropIndexByName('IX_SALE_LOCATION_MARGINS', 'b_sale_location');
$DB->query('create index IX_B_SALE_LOC_MARGINS on b_sale_location (LEFT_MARGIN, RIGHT_MARGIN)');
}
if(static::checkIndexExistsByName('IX_SALE_LOCATION_MARGINS_REV', 'b_sale_location'))
{
static::dropIndexByName('IX_SALE_LOCATION_MARGINS_REV', 'b_sale_location');
$DB->query('create index IX_B_SALE_LOC_MARGINS_REV on b_sale_location (RIGHT_MARGIN, LEFT_MARGIN)');
}
if(static::checkIndexExistsByName('IX_SALE_LOCATION_PARENT', 'b_sale_location'))
{
static::dropIndexByName('IX_SALE_LOCATION_PARENT', 'b_sale_location');
$DB->query('create index IX_B_SALE_LOC_PARENT on b_sale_location (PARENT_ID)');
}
if(static::checkIndexExistsByName('IX_SALE_LOCATION_DL', 'b_sale_location'))
{
static::dropIndexByName('IX_SALE_LOCATION_DL', 'b_sale_location');
$DB->query('create index IX_B_SALE_LOC_DL on b_sale_location (DEPTH_LEVEL)');
}
if(static::checkIndexExistsByName('IX_SALE_LOCATION_TYPE', 'b_sale_location'))
{
static::dropIndexByName('IX_SALE_LOCATION_TYPE', 'b_sale_location');
$DB->query('create index IX_B_SALE_LOC_TYPE on b_sale_location (TYPE_ID)');
}
// b_sale_loc_name
if(static::checkIndexExistsByName('IX_SALE_L_NAME_NAME_UPPER', 'b_sale_loc_name'))
{
static::dropIndexByName('IX_SALE_L_NAME_NAME_UPPER', 'b_sale_loc_name');
$DB->query('create index IX_B_SALE_LOC_NAME_NAME_U on b_sale_loc_name (NAME_UPPER)');
}
if(static::checkIndexExistsByName('IX_SALE_L_NAME_LID_LID', 'b_sale_loc_name'))
{
static::dropIndexByName('IX_SALE_L_NAME_LID_LID', 'b_sale_loc_name');
$DB->query('create index IX_B_SALE_LOC_NAME_LI_LI on b_sale_loc_name (LOCATION_ID, LANGUAGE_ID)');
}
// b_sale_loc_type_name
if(static::checkIndexExistsByName('IX_SALE_L_TYPE_NAME_TID_LID', 'b_sale_loc_type_name'))
{
static::dropIndexByName('IX_SALE_L_TYPE_NAME_TID_LID', 'b_sale_loc_type_name');
$DB->query('create index IX_B_SALE_LOC_TYPE_NAME_TI_LI on b_sale_loc_type_name (TYPE_ID, LANGUAGE_ID)');
}
// b_sale_location_group
if(static::checkIndexExistsByName('IX_SALE_LOCATION_GROUP_CODE', 'b_sale_location_group'))
{
static::dropIndexByName('IX_SALE_LOCATION_GROUP_CODE', 'b_sale_location_group');
$DB->query('create unique index IX_B_SALE_LOC_GROUP_CODE on b_sale_location_group (CODE)');
}
}
}