示例#1
0
文件: DbTest.php 项目: cargomedia/cm
 public function testExistsColumn()
 {
     $this->assertSame(true, CM_Db_Db::existsColumn('test', 'foo'));
     $this->assertSame(false, CM_Db_Db::existsColumn('test', 'test'));
 }
示例#2
0
文件: 15.php 项目: cargomedia/cm
<?php

if (CM_Db_Db::existsColumn('cm_stream_publish', 'userId')) {
    CM_Db_Db::exec('ALTER TABLE  `cm_stream_publish` MODIFY  `userId` int(10) unsigned DEFAULT NULL');
}
示例#3
0
文件: 13.php 项目: cargomedia/cm
<?php

if (!CM_Db_Db::existsColumn('cm_locationState', 'abbreviation')) {
    CM_Db_Db::exec('ALTER TABLE `cm_locationState` ADD `abbreviation` char(2) AFTER `name`');
}
CM_Model_Location::createUSStatesAbbreviation();
示例#4
0
文件: 63.php 项目: cargomedia/cm
<?php

if (CM_Db_Db::existsColumn('cm_streamChannelArchive_media', 'userId')) {
    CM_Db_Db::exec("ALTER TABLE cm_streamChannelArchive_media DROP userId");
}
示例#5
0
文件: 30.php 项目: cargomedia/cm
<?php

if (CM_Db_Db::existsTable('cm_model_location_city_ip') && !CM_Db_Db::existsTable('cm_model_location_ip')) {
    CM_Db_Db::exec('RENAME TABLE `cm_model_location_city_ip` TO `cm_model_location_ip`');
}
if (CM_Db_Db::existsTable('cm_model_location_ip')) {
    if (CM_Db_Db::existsIndex('cm_model_location_ip', 'cityId')) {
        CM_Db_Db::exec('DROP INDEX `cityId` ON `cm_model_location_ip`');
    }
    if (CM_Db_Db::existsColumn('cm_model_location_ip', 'cityId') && !CM_Db_Db::existsColumn('cm_model_location_ip', 'id')) {
        CM_Db_Db::exec('ALTER TABLE `cm_model_location_ip` CHANGE COLUMN `cityId` `id` int(10) unsigned NOT NULL ');
    }
    if (!CM_Db_Db::existsColumn('cm_model_location_ip', 'level')) {
        CM_Db_Db::exec('ALTER TABLE `cm_model_location_ip` ADD COLUMN `level` int(10) unsigned NOT NULL AFTER `id`');
    }
    if (CM_Db_Db::existsColumn('cm_model_location_ip', 'level')) {
        CM_Db_Db::update('cm_model_location_ip', array('level' => CM_Model_Location::LEVEL_CITY), array('level' => 0));
    }
    if (CM_Db_Db::existsTable('cm_model_location_country_ip')) {
        $result = CM_Db_Db::select('cm_model_location_country_ip', array('countryId', 'ipStart', 'ipEnd'));
        foreach ($result->fetchAll() as $row) {
            CM_Db_Db::insert('cm_model_location_ip', array('id' => $row['countryId'], 'level' => CM_Model_Location::LEVEL_COUNTRY, 'ipStart' => $row['ipStart'], 'ipEnd' => $row['ipEnd']));
        }
        CM_Db_Db::exec('DROP TABLE `cm_model_location_country_ip`');
    }
}
示例#6
0
文件: 27.php 项目: cargomedia/cm
<?php

if (CM_Db_Db::existsIndex('cm_svm', 'trainingChanges')) {
    CM_Db_Db::exec('DROP INDEX `trainingChanges` on `cm_svm`');
}
if (CM_Db_Db::existsColumn('cm_svm', 'trainingChanges')) {
    CM_Db_Db::exec('
        ALTER TABLE `cm_svm`
          DROP COLUMN `trainingChanges`,
          ADD COLUMN `updateStamp` int(10) unsigned NOT NULL');
    CM_Db_Db::update('cm_svm', array('updateStamp' => time()));
}
示例#7
0
文件: 14.php 项目: cargomedia/cm
<?php

if (CM_Db_Db::existsColumn('cm_languageKey', 'accessStamp')) {
    CM_Db_Db::exec('ALTER TABLE  `cm_languageKey` CHANGE  `accessStamp`  `updateCountResetVersion` int(10) unsigned DEFAULT NULL');
}
示例#8
0
文件: 59.php 项目: cargomedia/cm
<?php

if (!CM_Db_Db::existsColumn('cm_streamChannelArchive_media', 'key')) {
    CM_Db_Db::exec("ALTER TABLE cm_streamChannelArchive_media ADD `key` VARCHAR(64) DEFAULT NULL, ADD INDEX (`key`)");
}
示例#9
0
文件: 47.php 项目: cargomedia/cm
<?php

if (!CM_Db_Db::existsColumn('cm_mail', 'customHeaders')) {
    CM_Db_Db::exec('
        ALTER TABLE `cm_mail` ADD COLUMN `customHeaders` text AFTER `bcc`;');
}
示例#10
0
文件: 45.php 项目: cargomedia/cm
<?php

if (!CM_Db_Db::existsColumn('cm_ipBlocked', 'expirationStamp')) {
    CM_Db_Db::exec("ALTER TABLE `cm_ipBlocked`\n                    ADD `expirationStamp` int(10) unsigned NOT NULL,\n                    ADD KEY `expirationStamp` (`expirationStamp`);");
}
$config = CM_Config::get();
CM_Db_Db::exec("UPDATE `cm_ipBlocked` SET `expirationStamp` = `createStamp` + " . $config->CM_Paging_Ip_Blocked->maxAge . " WHERE `expirationStamp` = 0");
示例#11
0
文件: 33.php 项目: cargomedia/cm
<?php

if (!CM_Db_Db::existsColumn('cm_languageKey', 'variables')) {
    CM_Db_Db::exec("ALTER TABLE `cm_languageKey` ADD `variables` text CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL AFTER name");
}
if (CM_Db_Db::existsTable('cm_languageKey_variable')) {
    $results = CM_Db_Db::select('cm_languageKey_variable', '*')->fetchAll();
    $variableList = array();
    foreach ($results as $result) {
        $variableList[$result['languageKeyId']][] = $result['name'];
    }
    foreach ($variableList as $languageKeyId => $variables) {
        CM_Db_Db::update('cm_languageKey', array('variables' => json_encode($variables)), array('id' => $languageKeyId));
    }
    CM_Db_Db::exec('DROP TABLE `cm_languageKey_variable`');
}
示例#12
0
文件: 71.php 项目: cargomedia/cm
<?php

if (CM_Db_Db::existsColumn('cm_cli_command_manager_process', 'hostId')) {
    CM_Db_Db::exec('
        ALTER TABLE `cm_cli_command_manager_process`
          DROP KEY `hostId`,
          DROP COLUMN `hostId`,
          ADD COLUMN `machineId` varchar(100) NOT NULL AFTER `commandName`,
          ADD KEY `machineId` (`machineId`)
    ');
    CM_Db_Db::delete('cm_cli_command_manager_process');
}
示例#13
0
文件: 1.php 项目: cargomedia/cm
<?php

if (!CM_Db_Db::existsColumn('cm_splittestVariation_fixture', 'conversionWeight')) {
    CM_Db_Db::exec('ALTER TABLE `cm_splittestVariation_fixture` ADD `conversionWeight` DECIMAL(10,2) DEFAULT 1 NOT NULL');
}
示例#14
0
文件: 49.php 项目: cargomedia/cm
<?php

if (!CM_Db_Db::existsTable('cm_model_currency')) {
    CM_Db_Db::exec("CREATE TABLE `cm_model_currency` (\n                      `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n                      `code` varchar(3) NOT NULL DEFAULT '',\n                      `abbreviation` varchar(3) NOT NULL DEFAULT '',\n                      PRIMARY KEY (`id`),\n                      UNIQUE KEY `code` (`code`),\n                      UNIQUE KEY `string` (`abbreviation`)\n                    ) ENGINE=MyISAM DEFAULT CHARSET=utf8;");
}
if (!CM_Db_Db::existsTable('cm_model_currency_country')) {
    CM_Db_Db::exec("CREATE TABLE `cm_model_currency_country` (\n                      `currencyId` int(10) NOT NULL,\n                      `countryId` int(10) NOT NULL,\n                      UNIQUE KEY `countryId` (`countryId`)\n                    ) ENGINE=MyISAM DEFAULT CHARSET=utf8;");
}
if (!CM_Db_Db::existsColumn('cm_user', 'currencyId')) {
    CM_Db_Db::exec("ALTER TABLE `cm_user` ADD `currencyId` INT(10) UNSIGNED DEFAULT NULL");
}
示例#15
0
文件: 4.php 项目: cargomedia/cm
<?php

if (!CM_Db_Db::existsColumn('cm_streamChannel', 'adapterType')) {
    CM_Db_Db::exec('ALTER TABLE  `cm_streamChannel` ADD  `adapterType` INT NOT NULL');
    CM_Db_Db::exec('ALTER TABLE  `cm_streamChannel` ADD INDEX `type` (`type`)');
    CM_Db_Db::exec('ALTER TABLE  `cm_streamChannel` ADD UNIQUE `key-adapterType` (`key`, `adapterType`)');
}
示例#16
0
文件: 41.php 项目: cargomedia/cm
<?php

if (!CM_Db_Db::existsColumn('cm_splittestVariation_fixture', 'id')) {
    CM_Db_Db::exec("\n      ALTER TABLE `cm_splittestVariation_fixture`\n      ADD `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT FIRST,\n      ADD PRIMARY KEY (`id`)\n    ");
}
示例#17
0
文件: 38.php 项目: cargomedia/cm
<?php

if (!CM_Db_Db::existsColumn('cm_user_online', 'offlineStamp')) {
    CM_Db_Db::exec("ALTER TABLE `cm_user_online` ADD `offlineStamp` int(10) unsigned DEFAULT NULL, ADD INDEX `offlineStamp` (`offlineStamp`)");
}
示例#18
0
文件: 31.php 项目: cargomedia/cm
<?php

if (!CM_Db_Db::existsColumn('cm_tmp_location', 'nameFull')) {
    CM_Db_Db::exec('ALTER TABLE `cm_tmp_location` ADD COLUMN `nameFull` varchar(480) DEFAULT NULL AFTER `name`;');
    $searchCli = new CM_Elasticsearch_Index_Cli(null, new CM_OutputStream_Stream_Output());
    $searchCli->create('location');
}
示例#19
0
文件: 62.php 项目: cargomedia/cm
<?php

if (!CM_Db_Db::existsTable('cm_streamchannel_thumbnail')) {
    CM_Db_Db::exec("CREATE TABLE `cm_streamchannel_thumbnail` (\n          `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,\n          `channelId` INT(10) UNSIGNED NOT NULL,\n          `createStamp` INT(10) UNSIGNED NOT NULL,\n          PRIMARY KEY (`id`),\n          KEY `channelId-createStamp` (`channelId`, `createStamp`)\n        ) ENGINE=MyISAM DEFAULT CHARSET=utf8;");
}
if (CM_Db_Db::existsColumn('cm_streamChannel_media', 'thumbnailCount')) {
    CM_Db_Db::exec("ALTER TABLE cm_streamChannel_media DROP thumbnailCount, DROP `data`");
}
if (CM_Db_Db::existsColumn('cm_streamChannelArchive_media', 'thumbnailCount')) {
    CM_Db_Db::exec("ALTER TABLE cm_streamChannelArchive_media DROP thumbnailCount, DROP `data`");
}
示例#20
0
文件: 46.php 项目: cargomedia/cm
<?php

if (!CM_Db_Db::existsColumn('cm_splittest', 'optimized')) {
    CM_Db_Db::exec('
        ALTER TABLE `cm_splittest` ADD COLUMN `optimized` int(1) unsigned NOT NULL AFTER `name`');
}
if (!CM_Db_Db::existsIndex('cm_splittestVariation_fixture', 'splittestVariationCreateStamp')) {
    CM_Db_Db::exec('
        ALTER TABLE `cm_splittestVariation_fixture`
          ADD INDEX `splittestVariationCreateStamp` (`splittestId`,`variationId`,`createStamp`),
          ADD INDEX `splittestVariationConversionStamp` (`splittestId`,`variationId`,`conversionStamp`),
          DROP INDEX `splittestId`,
          DROP INDEX `createStamp`,
          DROP INDEX `conversionStamp`');
}
示例#21
0
文件: 7.php 项目: cargomedia/cm
<?php

if (CM_Db_Db::existsTable('cm_smileySet')) {
    CM_Db_Db::exec('DROP TABLE `cm_smileySet`;');
}
if (!CM_Db_Db::existsIndex('cm_smiley', 'code')) {
    CM_Db_Db::exec('ALTER TABLE `cm_smiley` ADD UNIQUE KEY (`code`);');
}
if (CM_Db_Db::existsColumn('cm_smiley', 'setId')) {
    CM_Db_Db::exec('ALTER TABLE `cm_smiley` DROP `setId`');
}
if (CM_Db_Db::existsTable('cm_smiley')) {
    CM_Db_Db::exec('RENAME TABLE `cm_smiley` TO `cm_emoticon`');
}
if (!CM_Db_Db::existsColumn('cm_emoticon', 'codeAdditional')) {
    CM_Db_Db::exec('ALTER TABLE `cm_emoticon` ADD `codeAdditional` varchar(50) AFTER `code`');
}