-
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.
- Loading branch information
Showing
8 changed files
with
123 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ | |
'chart' => TRUE, | ||
'timeline' => TRUE, | ||
'activity' => TRUE, | ||
'plan' => FALSE, | ||
], | ||
|
||
// Data sources | ||
|
23 changes: 23 additions & 0 deletions
23
migrations/20160322013857_add_message_notification_post_id.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,23 @@ | ||
<?php | ||
|
||
use Phinx\Migration\AbstractMigration; | ||
|
||
class AddMessageNotificationPostId extends AbstractMigration | ||
{ | ||
/** | ||
* Change Method. | ||
**/ | ||
public function change() | ||
{ | ||
$this->table('messages') | ||
->addColumn('notification_post_id', 'integer', [ | ||
'comment' => "Source post this message is a notification for", | ||
'null' => true, | ||
]) | ||
->addForeignKey('notification_post_id', 'posts', 'id', [ | ||
'delete' => 'SET NULL', | ||
'update' => 'CASCADE', | ||
]) | ||
->update(); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
migrations/20160322020552_move_message_post_id_to_notification_post_id.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,45 @@ | ||
<?php | ||
|
||
use Phinx\Migration\AbstractMigration; | ||
|
||
class MoveMessagePostIdToNotificationPostId extends AbstractMigration | ||
{ | ||
|
||
/** | ||
* Migrate Up. | ||
*/ | ||
public function up() | ||
{ | ||
$this->execute(" | ||
UPDATE messages | ||
SET notification_post_id = post_id | ||
WHERE direction = 'outgoing' | ||
AND post_id IS NOT NULL | ||
"); | ||
$this->execute("UPDATE messages | ||
SET post_id = NULL | ||
WHERE direction = 'outgoing' | ||
AND post_id IS NOT NULL | ||
AND post_id = notification_post_id; | ||
"); | ||
} | ||
|
||
/** | ||
* Migrate Down. | ||
*/ | ||
public function down() | ||
{ | ||
$this->execute(" | ||
UPDATE messages | ||
SET post_id = notification_post_id | ||
WHERE direction = 'outgoing' | ||
AND notification_post_id IS NOT NULL | ||
"); | ||
$this->execute("UPDATE messages | ||
SET notification_post_id = NULL | ||
WHERE direction = 'outgoing' | ||
AND notification_post_id IS NOT NULL | ||
AND notification_post_id = post_id; | ||
"); | ||
} | ||
} |
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