Example #1
0
    public function testDescribeColumnThrowsException()
    {
        CM_Db_Db::exec('
			CREATE TABLE `test2` (
				`id` int(12) unsigned NOT NULL AUTO_INCREMENT,
				PRIMARY KEY (`id`)
			)');
        try {
            CM_Db_Db::describeColumn('test2', 'id');
            CM_Db_Db::describeColumn('test2', 'id1');
            $this->fail('Column doesn\'t exist');
        } catch (CM_Db_Exception $e) {
            $this->assertContains('`id1`', $e->getMessage());
        }
        try {
            CM_Db_Db::describeColumn('test_', 'id');
            $this->fail('Table doesn\'t exist');
        } catch (CM_Db_Exception $e) {
            $this->assertContains('`id`', $e->getMessage());
        }
        CM_Db_Db::exec('DROP TABLE `test2`');
    }
Example #2
0
    public function testDescribeColumnThrowsException()
    {
        CM_Db_Db::exec('
			CREATE TABLE `test2` (
				`id` INT(12) UNSIGNED NOT NULL AUTO_INCREMENT,
				PRIMARY KEY (`id`)
			)');
        try {
            CM_Db_Db::describeColumn('test2', 'id');
            CM_Db_Db::describeColumn('test2', 'id1');
            $this->fail('Column doesn\'t exist');
        } catch (CM_Db_Exception $e) {
            $this->assertSame('Column not found', $e->getMessage());
            $this->assertSame(['column' => 'id1'], $e->getMetaInfo());
        }
        try {
            CM_Db_Db::describeColumn('test_', 'id');
            $this->fail('Table doesn\'t exist');
        } catch (CM_Db_Exception $e) {
            $this->assertContains('`id`', $e->getMetaInfo()['query']);
        }
        CM_Db_Db::exec('DROP TABLE `test2`');
    }
Example #3
0
File: 39.php Project: cargomedia/cm
<?php

if ('1.00' === CM_Db_Db::describeColumn('cm_splittestVariation_fixture', 'conversionWeight')->getDefaultValue()) {
    CM_Db_Db::exec('ALTER TABLE cm_splittestVariation_fixture
      MODIFY COLUMN conversionWeight decimal(10,2) NOT NULL DEFAULT 0');
    CM_Db_Db::update('cm_splittestVariation_fixture', array('conversionWeight' => 0), array('conversionStamp' => null));
}
Example #4
0
File: 42.php Project: cargomedia/cm
<?php

// To be run in prod beforehand:
// pt-online-schema-change --execute --charset=utf8 --user=root --ask-pass --database=skadate t=cm_user --alter='CHANGE `site` `site` int(10) unsigned DEFAULT NULL'
if ('INT' !== CM_Db_Db::describeColumn('cm_user', 'site')->getType()) {
    CM_Db_Db::exec("ALTER TABLE `cm_user` CHANGE `site` `site` int(10) unsigned DEFAULT NULL;");
}
Example #5
0
File: 64.php Project: cargomedia/cm
<?php

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 DEFAULT NULL");
}
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 DEFAULT NULL");
}
Example #6
0
File: 17.php Project: cargomedia/cm
<?php

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 NOT 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 NOT NULL');
}
Example #7
0
File: 19.php Project: cargomedia/cm
<?php

if (!CM_Db_Db::describeColumn('cm_streamChannelArchive_video', 'userId')->getAllowNull()) {
    CM_Db_Db::exec('ALTER TABLE  `cm_streamChannelArchive_video` CHANGE  `userId`  `userId` INT( 10 ) UNSIGNED NULL ;');
}