-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: add wait/handle time to
ProcessedMessage
- Loading branch information
Showing
5 changed files
with
64 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,42 @@ | ||
# Upgrade Guide | ||
|
||
## 0.5.0 | ||
|
||
Two new `integer` columns were added to the `processed_messages` table: | ||
`wait_time` and `handle_time`. You will need to create a migration to | ||
add these columns to your database. They are not nullable so your | ||
migration will need to account for existing data. You can either | ||
truncate (purge) the `processed_messages` table have your migration | ||
calculate these values based on the existing data. | ||
|
||
Here's a calculation example for MySQL: | ||
|
||
```php | ||
use Doctrine\DBAL\Schema\Schema; | ||
use Doctrine\Migrations\AbstractMigration; | ||
|
||
final class VersionXXX extends AbstractMigration | ||
{ | ||
public function getDescription(): string | ||
{ | ||
return 'Add processed_messages.wait_time and handle_time columns'; | ||
} | ||
|
||
public function up(Schema $schema): void | ||
{ | ||
// Add the columns as nullable | ||
$this->addSql('ALTER TABLE processed_messages ADD wait_time INT DEFAULT NULL, ADD handle_time INT DEFAULT NULL'); | ||
|
||
// set the times from existing data | ||
$this->addSql('UPDATE processed_messages SET wait_time = TIMESTAMPDIFF(SECOND, dispatched_at, received_at), handle_time = TIMESTAMPDIFF(SECOND, received_at, finished_at)'); | ||
|
||
// Make the columns not nullable | ||
$this->addSql('ALTER TABLE processed_messages CHANGE wait_time wait_time INT NOT NULL, CHANGE handle_time handle_time INT NOT NULL'); | ||
} | ||
|
||
public function down(Schema $schema): void | ||
{ | ||
$this->addSql('ALTER TABLE processed_messages DROP wait_time, DROP handle_time'); | ||
} | ||
} | ||
``` |
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