コード例 #1
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`');
}
コード例 #2
0
ファイル: DbTest.php プロジェクト: cargomedia/cm
 public function testExistsIndex()
 {
     $this->assertSame(true, CM_Db_Db::existsIndex('test', 'foo'));
     $this->assertSame(false, CM_Db_Db::existsIndex('test', 'test'));
 }
コード例 #3
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`');
    }
}
コード例 #4
0
ファイル: 5.php プロジェクト: cargomedia/cm
<?php

if (!CM_Db_Db::existsIndex('cm_stream_subscribe', 'channelId-key')) {
    CM_Db_Db::exec('ALTER TABLE  `cm_stream_subscribe` DROP INDEX `key`');
    CM_Db_Db::exec('ALTER TABLE  `cm_stream_subscribe` DROP INDEX `channelId`');
    CM_Db_Db::exec('ALTER TABLE  `cm_stream_subscribe` ADD UNIQUE `channelId-key` (`channelId`, `key`)');
}
if (!CM_Db_Db::existsIndex('cm_stream_publish', 'channelId-key')) {
    CM_Db_Db::exec('ALTER TABLE  `cm_stream_publish` DROP INDEX `key`');
    CM_Db_Db::exec('ALTER TABLE  `cm_stream_publish` DROP INDEX `channelId`');
    CM_Db_Db::exec('ALTER TABLE  `cm_stream_publish` ADD UNIQUE `channelId-key` (`channelId`, `key`)');
}
if (!CM_Db_Db::describeColumn('cm_stream_publish', 'allowedUntil')->getAllowNull()) {
    CM_Db_Db::exec('ALTER TABLE  `cm_stream_publish` CHANGE  `allowedUntil`  `allowedUntil` INT( 10 ) UNSIGNED NULL');
}
if (!CM_Db_Db::describeColumn('cm_stream_subscribe', 'allowedUntil')->getAllowNull()) {
    CM_Db_Db::exec('ALTER TABLE  `cm_stream_subscribe` CHANGE  `allowedUntil`  `allowedUntil` INT( 10 ) UNSIGNED NULL');
}
コード例 #5
0
ファイル: 6.php プロジェクト: cargomedia/cm
<?php

if (CM_Db_Db::existsIndex('cm_streamChannel', 'key-adapterType')) {
    CM_Db_Db::exec('ALTER TABLE `cm_streamChannel` DROP INDEX `key-adapterType`');
    CM_Db_Db::exec('ALTER TABLE `cm_streamChannel` ADD UNIQUE `adapterType-key` (`adapterType`, `key`)');
}
if (CM_Db_Db::existsIndex('cm_streamChannel', 'key')) {
    CM_Db_Db::exec('ALTER TABLE `cm_streamChannel` DROP INDEX `key`');
}
コード例 #6
0
ファイル: 12.php プロジェクト: cargomedia/cm
<?php

if (CM_Db_Db::existsIndex('cm_splittestVariation_fixture', 'fixtureId')) {
    CM_Db_Db::exec('
		ALTER TABLE cm_splittestVariation_fixture
			DROP INDEX fixtureId,
			DROP PRIMARY KEY');
}
if (CM_Db_Db::existsColumn('cm_splittestVariation_fixture', 'fixtureId')) {
    CM_Db_Db::exec('
		ALTER TABLE `cm_splittestVariation_fixture`
			CHANGE `fixtureId` `userId` INT(10) UNSIGNED NULL,
			ADD COLUMN `requestClientId` INT(10) UNSIGNED NULL AFTER `splittestId`');
}
if (!CM_Db_Db::existsIndex('cm_splittestVariation_fixture', 'userSplittest')) {
    CM_Db_Db::exec('
		ALTER TABLE cm_splittestVariation_fixture
			ADD UNIQUE `userSplittest` (`userId`, `splittestId`)');
}
if (!CM_Db_Db::existsIndex('cm_splittestVariation_fixture', 'requestClientSplittest')) {
    CM_Db_Db::exec('
		ALTER TABLE cm_splittestVariation_fixture
			ADD UNIQUE `requestClientSplittest` (`requestClientId`, `splittestId`)');
}
コード例 #7
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()));
}
コード例 #8
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`');
}