This repository has been archived by the owner on Oct 15, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
381 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
migrations/m170212_000000_seomatic_addGoogleAnalyticsAnonymizeIp.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
namespace Craft; | ||
|
||
/** | ||
* The class name is the UTC timestamp in the format of mYYMMDD_HHMMSS_pluginHandle_migrationName | ||
*/ | ||
class m170212_000000_seomatic_addGoogleAnalyticsAnonymizeIp extends BaseMigration | ||
{ | ||
/** | ||
* Any migration code in here is wrapped inside of a transaction. | ||
* | ||
* @return bool | ||
*/ | ||
public function safeUp() | ||
{ | ||
// specify columns and AttributeType | ||
$newColumns = array ( | ||
'googleAnalyticsAnonymizeIp' => ColumnType::Bool, | ||
); | ||
|
||
$this->_addColumnsAfter("seomatic_settings", $newColumns, "googleAnalyticsLinker"); | ||
|
||
// return true and let craft know its done | ||
return true; | ||
} | ||
|
||
private function _addColumnsAfter($tableName, $newColumns, $afterColumnHandle) | ||
{ | ||
|
||
// this is a foreach loop, enough said | ||
foreach ($newColumns as $columnName => $columnType) | ||
{ | ||
// check if the column does NOT exist | ||
if (!craft()->db->columnExists($tableName, $columnName)) | ||
{ | ||
$this->addColumnAfter($tableName, $columnName, array( | ||
'column' => $columnType, | ||
'null' => false, | ||
), | ||
$afterColumnHandle | ||
); | ||
|
||
// log that we created the new column | ||
SeomaticPlugin::log("Created the `$columnName` in the `$tableName` table.", LogLevel::Info, true); | ||
|
||
} | ||
|
||
// if the column already exists in the table | ||
else { | ||
|
||
// tell craft that we couldn't create the column as it alredy exists. | ||
SeomaticPlugin::log("Column `$columnName` already exists in the `$tableName` table.", LogLevel::Info, true); | ||
|
||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
namespace Craft; | ||
|
||
/** | ||
* The class name is the UTC timestamp in the format of mYYMMDD_HHMMSS_pluginHandle_migrationName | ||
*/ | ||
class m170212_000000_seomatic_addWikipedia extends BaseMigration | ||
{ | ||
/** | ||
* Any migration code in here is wrapped inside of a transaction. | ||
* | ||
* @return bool | ||
*/ | ||
public function safeUp() | ||
{ | ||
// specify columns and AttributeType | ||
$newColumns = array ( | ||
'wikipediaUrl' => ColumnType::Varchar | ||
); | ||
|
||
$this->_addColumnsAfter("seomatic_settings", $newColumns, "vimeoHandle"); | ||
$this->alterColumn('seomatic_settings', 'wikipediaUrl', array(ColumnType::Varchar, 'maxLength' => 100)); | ||
|
||
// return true and let craft know its done | ||
return true; | ||
} | ||
|
||
private function _addColumnsAfter($tableName, $newColumns, $afterColumnHandle) | ||
{ | ||
|
||
// this is a foreach loop, enough said | ||
foreach ($newColumns as $columnName => $columnType) | ||
{ | ||
// check if the column does NOT exist | ||
if (!craft()->db->columnExists($tableName, $columnName)) | ||
{ | ||
$this->addColumnAfter($tableName, $columnName, array( | ||
'column' => $columnType, | ||
'null' => false, | ||
), | ||
$afterColumnHandle | ||
); | ||
|
||
// log that we created the new column | ||
SeomaticPlugin::log("Created the `$columnName` in the `$tableName` table.", LogLevel::Info, true); | ||
|
||
} | ||
|
||
// if the column already exists in the table | ||
else { | ||
|
||
// tell craft that we couldn't create the column as it alredy exists. | ||
SeomaticPlugin::log("Column `$columnName` already exists in the `$tableName` table.", LogLevel::Info, true); | ||
|
||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.