Permalink
Browse files

Adds migrations

- Adds javascriptMethodFailed to log table
- Adds duplicateMethodFailed to log table
- Removes sproutinvisiblecaptcha_keys table
  • Loading branch information...
BenParizek committed Feb 16, 2015
1 parent 395280b commit 171b4e870d4f50aa0df73a86f250e1fd96a84cd9
@@ -0,0 +1,52 @@
<?php
namespace Craft;
/**
* The class name is the UTC timestamp in the format of mYYMMDD_HHMMSS_pluginHandle_migrationName
*/
class m150215_000000_sproutInvisibleCaptcha_addLogColumns extends BaseMigration
{
/**
* Any migration code in here is wrapped inside of a transaction.
*
* @return bool
*/
public function safeUp()
{
// ADD A COLUMN TO A TABLE IN THE DATABASE
// The Table you wish to modify. 'craft_' prefix will be added automatically.
$tableName = 'sproutinvisiblecaptcha_log';
// The Column you wish to add
$columnNames = array('javascriptMethodFailed', 'duplicateMethodFailed');
// Add your Column after
$afterColumn = 'originMethodFailed';
if (craft()->db->tableExists($tableName))
{
foreach ($columnNames as $key => $columnName)
{
if (($column = craft()->db->columnExists($tableName, $columnName)) == null)
{
Craft::log("Adding `$columnName` column to the `$tableName` table.", LogLevel::Info, true);
$this->addColumnAfter($tableName, $columnName, array(AttributeType::Bool, 'required' => false, 'default' => 0), $afterColumn);
Craft::log("Added `$columnName` column to the `$tableName` table.", LogLevel::Info, true);
}
else
{
Craft::log("Tried to add a `$columnName` column to the `$tableName` table, but there is already one there.", LogLevel::Warning);
}
}
}
else
{
Craft::log("Could not find an `$tableName` table.", LogLevel::Error);
}
return true;
}
}
@@ -0,0 +1,28 @@
<?php
namespace Craft;
/**
* The class name is the UTC timestamp in the format of mYYMMDD_HHMMSS_pluginHandle_migrationName
*/
class m150215_000001_sproutInvisibleCaptcha_removeKeysTable extends BaseMigration
{
/**
* Any migration code in here is wrapped inside of a transaction.
*
* @return bool
*/
public function safeUp()
{
// REMOVE A TABLE TO THE DATABASE
// The Table you wish to add. 'craft_' prefix will be added automatically.
$tableName = 'sproutinvisiblecaptcha_keys';
if ($this->dropTableIfExists($tableName))
{
Craft::log('Deleting the `$tableName` table.', LogLevel::Info, true);
}
return true;
}
}

0 comments on commit 171b4e8

Please sign in to comment.