You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 2.0/llms-full.txt
+166Lines changed: 166 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -5327,6 +5327,11 @@ Those overrides are not limited to reads or projection rebuilds. `WorkflowStub::
5327
5327
5328
5328
Keep custom subclasses schema-compatible with the built-in models. If a subclass also changes table names or other Eloquent conventions that the package models normally infer, override the affected relations on that subclass as well so `currentRun()`, `runs()`, and similar lookups stay aligned with your custom schema.
5329
5329
5330
+
See the [Customization Matrix](./customization-matrix.md) for the frozen v2
5331
+
support contract, including which overrides are safe as inherited subclasses,
5332
+
which ones need explicit relation overrides, and how serializer, repository,
5333
+
health, import, migration, and write-side behavior fit together.
5334
+
5330
5335
## Payload Codec
5331
5336
5332
5337
v2 uses `avro` for new workflow payloads:
@@ -5691,12 +5696,168 @@ To ensure that your activities run on the same server so that they can share dat
5691
5696
5692
5697
In order to run a queue worker that only processes the `my_dedicated_queue` queue, you can use the `php artisan queue:work --queue=my_dedicated_queue` command. Alternatively, you can use Laravel Horizon to manage your queues. Horizon is a queue manager that provides a dashboard for monitoring the status of your queues and workers.
This page freezes the supported Durable Workflow v2 customization contract.
5704
+
Use it when you need to move v2 durable models onto a different connection,
5705
+
swap model subclasses, replace the PHP operator-observability repository, or
5706
+
decide whether an older serializer setting is still valid during migration.
5707
+
5708
+
## Supported override matrix
5709
+
5710
+
| Surface | Supported contract | Notes |
5711
+
| --- | --- | --- |
5712
+
| `workflows.v2.instance_model` with a schema-compatible subclass that keeps the basename `WorkflowInstance` | Supported | Use this shape when you only need a different connection, casts, or app namespace. The inherited relations keep the package's `workflow_instance_id` foreign-key contract. |
5713
+
| `workflows.v2.instance_model` with a table-swapped or basename-changing subclass | Supported with explicit relation overrides | Override `runs()`, `commands()`, and `updates()` so they keep `workflow_instance_id`. The package now validates this at boot and rejects inherited relation inference that would change those keys. `currentRun()` already pins `current_run_id` explicitly and does not need an override. |
5714
+
| Other `workflows.v2.*_model` overrides (`run_model`, `task_model`, `history_event_model`, projections, schedules, activity rows, failures, messages, memos, search attributes, child calls) | Supported for schema-compatible subclasses | Keep the package column names, primary keys, and foreign keys. These relations already pin the keys they use, so table-swapped subclasses can stay on the inherited relation methods when the schema stays compatible. |
5715
+
| Custom table names plus custom foreign-key column names | Unsupported | The v2 runtime and operator surfaces assume the package column and key names. If you change them, you are outside the supported contract. |
5716
+
| `OperatorObservabilityRepository` replacement | Supported by container binding | Bind your implementation to `Workflow\V2\Contracts\OperatorObservabilityRepository`. This is a PHP runtime integration contract for Waterline and `WorkflowStub::historyExport()`, not a stable cross-language API. The repository receives package model objects. |
5717
+
| `serializer` | Supported only for `avro` and legacy drain/import codecs | New v2 runs always use Avro semantics. `workflow-serializer-y` and `workflow-serializer-base64` remain valid only for finishing or importing v1 history that still needs PHP-native decoding. Custom serializer classes from v1 are unsupported in v2. |
5718
+
| Health and doctor diagnostics | Supported | `php artisan workflow:v2:doctor` and Waterline v2 health/stats reflect the configured model classes and flag stale serializer settings as migration debt. |
5719
+
| Package migrations on a non-default connection | Supported with published migrations | Auto-loaded package migrations run on Laravel's default connection. If your durable models use another connection, publish the migrations and set the migration `$connection` explicitly. |
5720
+
| Core write-side runtime (`WorkflowStub::make()`, `load()`, task creation, current-run resolution) | Supported through the configured durable models | The runtime honors the configured `instance_model`, `run_model`, and `task_model`. Keep write-side tables schema-compatible with the package columns and keys. |
5721
+
5722
+
## Exact v2 model keys
5723
+
5724
+
The published `workflows.php` config exposes these durable model keys under
5725
+
`workflows.v2`:
5726
+
5727
+
- `instance_model`
5728
+
- `run_model`
5729
+
- `history_event_model`
5730
+
- `task_model`
5731
+
- `command_model`
5732
+
- `link_model`
5733
+
- `activity_execution_model`
5734
+
- `activity_attempt_model`
5735
+
- `timer_model`
5736
+
- `failure_model`
5737
+
- `run_summary_model`
5738
+
- `run_wait_model`
5739
+
- `run_timeline_entry_model`
5740
+
- `run_timer_entry_model`
5741
+
- `run_lineage_entry_model`
5742
+
- `schedule_model`
5743
+
- `schedule_history_event_model`
5744
+
5745
+
Use subclasses of the package models for those keys. Keep the package's column
5746
+
names and foreign keys unless a page in this docs set says otherwise.
5747
+
5748
+
## Instance-model override rule
5749
+
5750
+
The only current v2 override that needs extra relation work is
5751
+
`workflows.v2.instance_model` when your subclass changes the inferred foreign
5752
+
key away from `workflow_instance_id`.
5753
+
5754
+
Typical safe example:
5755
+
5756
+
```php
5757
+
namespace App\Models\V2;
5758
+
5759
+
use Workflow\V2\Models\WorkflowInstance as BaseWorkflowInstance;
5760
+
5761
+
final class WorkflowInstance extends BaseWorkflowInstance
5762
+
{
5763
+
protected $connection = 'workflow';
5764
+
}
5765
+
```
5766
+
5767
+
Because the subclass basename is still `WorkflowInstance`, Eloquent keeps the
5768
+
same inferred foreign key and the inherited relations remain aligned.
5769
+
5770
+
If you use a different basename or a table-swapped storage model, override the
5771
+
affected relations explicitly:
5772
+
5773
+
```php
5774
+
namespace App\Workflow\Storage;
5775
+
5776
+
use Illuminate\Database\Eloquent\Relations\HasMany;
5777
+
use Workflow\V2\Models\WorkflowCommand;
5778
+
use Workflow\V2\Models\WorkflowInstance as BaseWorkflowInstance;
5779
+
use Workflow\V2\Models\WorkflowRun;
5780
+
use Workflow\V2\Models\WorkflowUpdate;
5781
+
use Workflow\V2\Support\ConfiguredV2Models;
5782
+
5783
+
final class TenantWorkflowInstance extends BaseWorkflowInstance
Here is an overview of the steps needed to customize the database connection used for the workflow v2 durable models. This is *only* required if you want to use a different database connection than the default connection you specified for your Laravel application.
5699
5856
5857
+
For the full v2 override contract, including table-swapped subclasses,
5858
+
serializer rules, repository replacement, health diagnostics, and migration
5859
+
expectations, see the [Customization Matrix](./customization-matrix.md).
5860
+
5700
5861
1. Create classes in your app models directory that extend the base v2 model classes
5701
5862
2. Set the desired `$connection` option in each class
5702
5863
3. Publish the workflow config file
@@ -5753,6 +5914,11 @@ Publish the workflow config file and update the `workflows.v2.*_model` bindings
5753
5914
5754
5915
The package resolves models through `Workflow\V2\Support\ConfiguredV2Models`, so any relation or query that hits a v2 model will transparently pick up the configured connection.
5755
5916
5917
+
If you move beyond schema-compatible subclasses and change the inferred foreign
5918
+
key of your custom `instance_model`, the package now validates that the
5919
+
`runs()`, `commands()`, and `updates()` relations were overridden explicitly at
5920
+
boot.
5921
+
5756
5922
## Migrations
5757
5923
5758
5924
Workflow migrations are auto-loaded from the package (`WorkflowServiceProvider::loadMigrationsFrom`) and run against the default database connection. When you route the v2 tables at a non-default connection, publish the migrations with `php artisan vendor:publish --tag=migrations` and set `protected $connection = 'mysql';` on each published migration class so `php artisan migrate` runs them against the correct database.
0 commit comments