-
Notifications
You must be signed in to change notification settings - Fork 506
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3925 from ushahidi/twitter-urls-fix
fix(Twitter): urls are now formatted with the std https://twitter.com…
- Loading branch information
Showing
3 changed files
with
62 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
use Phinx\Migration\AbstractMigration; | ||
|
||
class RewriteTwitterUrls extends AbstractMigration | ||
{ | ||
/** | ||
* Change Method. | ||
* | ||
* Write your reversible migrations using this method. | ||
* | ||
* More information on writing migrations is available here: | ||
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class | ||
* | ||
* The following commands can be used in this method and Phinx will | ||
* automatically reverse them when rolling back: | ||
* | ||
* createTable | ||
* renameTable | ||
* addColumn | ||
* renameColumn | ||
* addIndex | ||
* addForeignKey | ||
* | ||
* Remember to call "create()" or "update()" and NOT "save()" when working | ||
* with the Table class. | ||
*/ | ||
public function up() | ||
{ | ||
$sql = "UPDATE messages INNER JOIN contacts on contacts.id = messages.contact_id " . | ||
"SET messages.message = " . | ||
"REPLACE(messages.message, concat('https://twitter.com/statuses/', messages.data_source_message_id), " . | ||
"concat('https://twitter.com/', contacts.contact, '/status/', messages.data_source_message_id)) " . | ||
"WHERE `messages`.`type` = 'twitter'"; | ||
$this->execute($sql); | ||
} | ||
|
||
public function down() | ||
{ | ||
// phpcs:ignore | ||
$sql = "UPDATE messages INNER JOIN contacts on contacts.id = messages.contact_id " . | ||
"SET messages.message = REPLACE(messages.message, " . | ||
"concat('https://twitter.com/', contacts.contact, '/status/', messages.data_source_message_id), " . | ||
"concat('https://twitter.com/statuses/', messages.data_source_message_id)) " . | ||
"WHERE `messages`.`type` = 'twitter'"; | ||
$this->execute($sql); | ||
} | ||
} |
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