Skip to content

Commit 03e1c22

Browse files
[1.x] Support DB configurations that _require_ a unique ID (#142)
* Support DB configurations that _require_ a unique ID * Add upgrading guide * Unset the ID for expectations * Fix code styling * Update UPGRADE.MD --------- Co-authored-by: timacdonald <[email protected]> Co-authored-by: James Brooks <[email protected]>
1 parent e6e0258 commit 03e1c22

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

UPGRADE.MD

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Upgrade Guide
2+
3+
# Beta to 1.x
4+
5+
- [Auto-incrementing IDs were added to Pulse's tables](https://github.com/laravel/pulse/pull/142). This is recommended if you are using a configuration that requires tables to have a unique key on every table, e.g., PlanetScale.
6+

database/migrations/2023_06_07_000001_create_pulse_tables.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public function up(): void
2222
{
2323
Schema::create('pulse_values', function (Blueprint $table) {
2424
$table->engine = 'InnoDB';
25+
$table->id();
2526
$table->unsignedInteger('timestamp');
2627
$table->string('type');
2728
$table->text('key');
@@ -35,6 +36,7 @@ public function up(): void
3536

3637
Schema::create('pulse_entries', function (Blueprint $table) {
3738
$table->engine = 'InnoDB';
39+
$table->id();
3840
$table->unsignedInteger('timestamp');
3941
$table->string('type');
4042
$table->text('key');
@@ -49,6 +51,7 @@ public function up(): void
4951

5052
Schema::create('pulse_aggregates', function (Blueprint $table) {
5153
$table->engine = 'InnoDB';
54+
$table->id();
5255
$table->unsignedInteger('bucket');
5356
$table->unsignedMediumInteger('period');
5457
$table->string('type');

tests/Pest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@
5555
expect()->extend('toContainAggregateForAllPeriods', function (string|array $type, string $aggregate, string $key, int $value, int $count = null, int $timestamp = null) {
5656
$this->toBeInstanceOf(Collection::class);
5757

58+
$values = $this->value->each(function (stdClass $value) {
59+
unset($value->id);
60+
});
61+
5862
$types = (array) $type;
5963
$timestamp ??= now()->timestamp;
6064

0 commit comments

Comments
 (0)