Skip to content

Database

The SDK needs a database for one thing: the outbox table in your application’s database. Everything else (control-plane calls, auth, sync) goes over HTTP. If you do not use the outbox you need no table.

Database Driver Notes
MySQL 8.0+ database Needs native JSON columns.
PostgreSQL 12+ database JSONB headers. Pushes also pg_notify on insert.
MongoDB 4.4+ mongodb Needs mongodb/laravel-mongodb. No transaction fence, no push notify.

The README lists doctrine/dbal for the SQL databases; install it if your Laravel version’s schema builder asks for it.

Terminal window
php artisan vendor:publish --tag=flowcatalyst-migrations
php artisan migrate

The tag publishes one migration, which creates outbox_messages. The SDK never runs it by itself. To use another table name or connection, set FLOWCATALYST_OUTBOX_TABLE and FLOWCATALYST_OUTBOX_CONNECTION (and edit the published migration to match). The table name may be schema-qualified (schema.table) but must be a plain identifier.

The relay that drains the table can be provisioned for the same table with the platform tooling; see Outbox processor. fcdev outbox creates the table on first run for PostgreSQL.

Columns, as the migration defines them:

Column Type Purpose
id string(26), primary key Message id (a TSID).
type string(20) EVENT, DISPATCH_JOB, AUDIT_LOG or PUSH.
message_group string(255), null Ordering group.
payload longText JSON body.
status smallint, default 0 0 pending. The relay owns later values.
retry_count smallint, default 0 Relay bookkeeping.
created_at, updated_at DATETIME(3) (MySQL), TIMESTAMPTZ(3) (PostgreSQL), datetime (SQLite) Row times, in UTC with millisecond precision.
error_message text, null Last relay error.
client_id string(26), null SDK column.
payload_size integer, null SDK column.
headers json, null SDK column.

Indexes: (status, message_group, created_at) for pending rows, (status, created_at) for stuck rows, (client_id, status, created_at) for client polling.

The SDK stamps created_at and updated_at in UTC with milliseconds (2026-12-01 10:15:02.481), whatever PHP’s default time zone. Before 0.27.0 they were PHP’s local time to the second. On PostgreSQL the driver sends the time with +00:00, so a TIMESTAMPTZ column stores the right instant whatever the session’s time zone. On MySQL, if your columns are TIMESTAMP (not DATETIME), the value is converted from the session’s time zone: keep that session in UTC. The MongoDB driver reads the times as UTC and keeps the milliseconds.

The published migration now creates the two columns with millisecond precision. A table made by an earlier version keeps its columns, and works, but stores whole seconds. To get the precision, alter them yourself:

-- MySQL
ALTER TABLE outbox_messages MODIFY created_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3);
ALTER TABLE outbox_messages MODIFY updated_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3);
-- PostgreSQL, if the stored values are UTC
ALTER TABLE outbox_messages ALTER COLUMN created_at TYPE timestamptz(3) USING created_at AT TIME ZONE 'UTC';
ALTER TABLE outbox_messages ALTER COLUMN updated_at TYPE timestamptz(3) USING updated_at AT TIME ZONE 'UTC';

The outbox may be large: alter it in a quiet period, or with your database’s online schema-change tool, as you would any large table.

Terminal window
composer require mongodb/laravel-mongodb

Add a mongodb connection to config/database.php, then:

FLOWCATALYST_OUTBOX_DRIVER=mongodb
FLOWCATALYST_OUTBOX_CONNECTION=mongodb

Create the collection and its indexes yourself (the SDK ships no migration for it):

db.createCollection('outbox_messages');
db.outbox_messages.createIndex(
{ clientId: 1, status: 1, createdAt: 1 },
{ name: 'idx_outbox_pending' },
);
db.outbox_messages.createIndex({ status: 1, createdAt: 1 }, { name: 'idx_outbox_status' });

Documents use camelCase fields (_id, messageGroup, retryCount, createdAt, updatedAt, errorMessage, clientId, payloadSize, headers), with timestamps as BSON dates. Without the package installed, a write throws OutboxException.

Because MongoDriver has no transaction check, make sure your own write and the outbox write share a MongoDB session if you need atomicity.