@@ -49,8 +49,8 @@ discard block |
||
49 | 49 | public function handle() |
50 | 50 | { |
51 | 51 | if ($this->option('force') == 'true' || $this->confirm("Are you sure you want to make a new table '{$this->config->get('cqrses.eventstore_table')}'" |
52 | - . " on connection '{$this->config->get('cqrses.eventstore_connection')}'" |
|
53 | - . " Do you wish to continue?") |
|
52 | + . " on connection '{$this->config->get('cqrses.eventstore_connection')}'" |
|
53 | + . " Do you wish to continue?") |
|
54 | 54 | ) { |
55 | 55 | try { |
56 | 56 | return $this->buildEventStoreTable(); |
@@ -67,16 +67,16 @@ discard block |
||
67 | 67 | protected function buildEventStoreTable() |
68 | 68 | { |
69 | 69 | Schema::connection($this->config->get('cqrses.eventstore_connection')) |
70 | - ->create($this->config->get('cqrses.eventstore_table'), |
|
71 | - function (Blueprint $table) { |
|
72 | - $table->increments('id'); |
|
73 | - $table->string('uuid', 56); |
|
74 | - $table->integer('playhead')->unsigned(); |
|
75 | - $table->text('metadata'); |
|
76 | - $table->longText('payload'); |
|
77 | - $table->nullableTimestamps('recorded_on', 32)->index(); |
|
78 | - $table->string('type', 255)->index(); |
|
79 | - $table->unique(['uuid', 'playhead']); |
|
80 | - }); |
|
70 | + ->create($this->config->get('cqrses.eventstore_table'), |
|
71 | + function (Blueprint $table) { |
|
72 | + $table->increments('id'); |
|
73 | + $table->string('uuid', 56); |
|
74 | + $table->integer('playhead')->unsigned(); |
|
75 | + $table->text('metadata'); |
|
76 | + $table->longText('payload'); |
|
77 | + $table->nullableTimestamps('recorded_on', 32)->index(); |
|
78 | + $table->string('type', 255)->index(); |
|
79 | + $table->unique(['uuid', 'playhead']); |
|
80 | + }); |
|
81 | 81 | } |
82 | 82 | } |
83 | 83 | \ No newline at end of file |
@@ -54,10 +54,10 @@ discard block |
||
54 | 54 | public function load($id) |
55 | 55 | { |
56 | 56 | $rows = $this->db->table($this->eventStoreTableName) |
57 | - ->select(['uuid', 'playhead', 'metadata', 'payload', 'recorded_on']) |
|
58 | - ->where('uuid', $id) |
|
59 | - ->orderBy('playhead', 'asc') |
|
60 | - ->get(); |
|
57 | + ->select(['uuid', 'playhead', 'metadata', 'payload', 'recorded_on']) |
|
58 | + ->where('uuid', $id) |
|
59 | + ->orderBy('playhead', 'asc') |
|
60 | + ->get(); |
|
61 | 61 | $events = []; |
62 | 62 | |
63 | 63 | foreach ($rows as $row) { |
@@ -154,12 +154,12 @@ discard block |
||
154 | 154 | public function getEventsByType($eventTypes, $skip, $take) |
155 | 155 | { |
156 | 156 | $rows = $this->db->table($this->eventStoreTableName) |
157 | - ->select(['uuid', 'playhead', 'metadata', 'payload', 'recorded_on']) |
|
158 | - ->whereIn('type', $eventTypes) |
|
159 | - ->skip($skip) |
|
160 | - ->take($take) |
|
161 | - ->orderBy('recorded_on', 'asc') |
|
162 | - ->get(); |
|
157 | + ->select(['uuid', 'playhead', 'metadata', 'payload', 'recorded_on']) |
|
158 | + ->whereIn('type', $eventTypes) |
|
159 | + ->skip($skip) |
|
160 | + ->take($take) |
|
161 | + ->orderBy('recorded_on', 'asc') |
|
162 | + ->get(); |
|
163 | 163 | $events = []; |
164 | 164 | |
165 | 165 | foreach ($rows as $row) { |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | */ |
82 | 82 | public function append($id, DomainEventStream $eventStream, bool $ignorePlayhead = false) |
83 | 83 | { |
84 | - $id = (string)$id; //Used to thrown errors if ID will not cast to string |
|
84 | + $id = (string) $id; //Used to thrown errors if ID will not cast to string |
|
85 | 85 | |
86 | 86 | $this->db->beginTransaction(); |
87 | 87 | |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | } catch (\PDOException $ex) { |
111 | 111 | if ((string) $ex->getCode() === '23000') { |
112 | 112 | if ($ignorePlayhead) { |
113 | - $eventRow['playhead'] ++; |
|
113 | + $eventRow['playhead']++; |
|
114 | 114 | return $this->insertEvent($eventRow, true); |
115 | 115 | } |
116 | 116 | throw new DuplicateAggregatePlayhead($eventRow['uuid'], $eventRow['playhead']); |
@@ -176,11 +176,11 @@ discard block |
||
176 | 176 | private function domainMessageToArray(DomainMessage $domainMessage): array |
177 | 177 | { |
178 | 178 | return [ |
179 | - 'uuid' => (string)$domainMessage->getId(), |
|
179 | + 'uuid' => (string) $domainMessage->getId(), |
|
180 | 180 | 'playhead' => $domainMessage->getPlayHead(), |
181 | 181 | 'metadata' => json_encode($this->serializer->serialize($domainMessage->getMetadata())), |
182 | 182 | 'payload' => json_encode($this->serializer->serialize($domainMessage->getPayload())), |
183 | - 'recorded_on' => (string)$domainMessage->getRecordedOn(), |
|
183 | + 'recorded_on' => (string) $domainMessage->getRecordedOn(), |
|
184 | 184 | 'type' => $domainMessage->getType(), |
185 | 185 | ]; |
186 | 186 | } |