Pre-1.0. Not intended for public use yet. The API is subject to undocumented change, and these pages may already be wrong about it.

Skip to content

Schema ​

Introduction ​

Storyfeed's migrations create ten tables. Publish them with storyfeed:install or the following command:

bash
php artisan vendor:publish --tag=storyfeed-migrations

Set table names in Configuration. The migrations include indexes for feed queries. They declare no foreign key constraints: the keys below are the ones Storyfeed joins on. Storage Architecture shows which rows a publish writes and how a feed is retrieved from them.

Every entity key column (each role's {role}_id, model_id, entity_id and actor_id) is a string(36). On MySQL and MariaDB these columns use the ascii charset and the ascii_bin binary collation.

Tables at a Glance ​

The 10 tables Storyfeed creates, and how they reference each othersolid: an id column Storyfeed joins on · dashed: a morph reference, or a keyheld in another column · no foreign key constraints are declaredbatch rows: hash = feed_batches.uidfeed_activitiesidPKuidULID · uniqueverbindexcached_{role}_idsnapshot × 7{role}_type, {role}_idmorph × 7datajsonpublished_attimestamp(6)created_at, updated_atdeleted_atsoft delete(published_at, id)({role}_type, {role}_id, published_at, id) actor, object, target, contextfeed_snapshotsidPKmodel_type, model_iduniquelabeldata, bodyjsoncontent, media_typeattributed_toshapeindexsource_updated_atmetajsonfeed_entitiesidPKkeyuniquename, typekindparty or recorddatajsonfeed_tombstonesidPKmodel_type, model_iduniquerestorable, approximatebooldeleted_at, labelmetajsonfeed_groupingsidPKactivity_id→ activitybucketaxis namehashgroup keywinnerbool or nullunique (activity_id, bucket)(activity_id, winner, bucket)(bucket, hash, activity_id, winner)feed_participantsactivity_id→ activityroleentity_type, entity_idpublished_atcopiedPK (activity_id, entity_type, entity_id)(entity_type, entity_id, published_at, activity_id, distance)feed_batchesidPKuidULID · uniqueactor_type, actor_idopened_at, closes_atclosed_atnull = openactivities_count(actor_type, actor_id)(closed_at)feed_batch_locksactor_type, actor_idPKopen_batchesjsonlocked_atfeed_grouping_burstskeyPKhashburst hashopened_at, last_activity_atwithin_seconds, ceiling_secondslocked_atfeed_metakeyuniquevaluesync_token

Each role is stored as a morph pair, {role}_type and {role}_id, holding the model's morph alias and key. Next to it, cached_{role}_id points at the entity's snapshot.

Activity Storage ​

feed_activities ​

Stores one record per activity. deleteFromFeed() soft-deletes these records. The uid ULID becomes the payload's id. Role columns store morph aliases; removing or changing an alias leaves affected roles unresolved.

ColumnTypeAttributesPurpose
idbigint, incrementsPKPrimary key.
uiduliduniqueThe activity's public identifier, the payload's id.
verbstring(255)indexThe verb, as a plain string.
actor_typestring(255)nullableThe actor's morph alias. Null when no actor is recorded.
actor_idstring(36)nullableThe actor's key.
object_typestring(255)nullableThe object's morph alias.
object_idstring(36)nullableThe object's key.
target_typestring(255)nullableThe target's morph alias.
target_idstring(36)nullableThe target's key.
context_typestring(255)nullableThe context's morph alias.
context_idstring(36)nullableThe context's key.
origin_typestring(255)nullableThe origin's morph alias.
origin_idstring(36)nullableThe origin's key.
result_typestring(255)nullableThe result's morph alias.
result_idstring(36)nullableThe result's key.
instrument_typestring(255)nullableThe instrument's morph alias.
instrument_idstring(36)nullableThe instrument's key.
location_typestring(255)nullableThe location's morph alias.
location_idstring(36)nullableThe location's key.
generator_typestring(255)nullableThe generator's morph alias.
generator_idstring(36)nullableThe generator's key.
cached_actor_idunsigned bigintindex, nullableThe actor's row in feed_snapshots.
cached_object_idunsigned bigintindex, nullableThe object's row in feed_snapshots.
cached_target_idunsigned bigintindex, nullableThe target's row in feed_snapshots.
cached_context_idunsigned bigintindex, nullableThe context's row in feed_snapshots.
cached_origin_idunsigned bigintnullableThe origin's row in feed_snapshots.
cached_result_idunsigned bigintnullableThe result's row in feed_snapshots.
cached_instrument_idunsigned bigintnullableThe instrument's row in feed_snapshots.
cached_location_idunsigned bigintnullableThe location's row in feed_snapshots.
cached_generator_idunsigned bigintnullableThe generator's row in feed_snapshots.
datajsonnullableThe values passed to data().
entitiesjsonnullableRoles filled by an entity with no model behind it, stored inline with the activity: label, url, data and body by role. Null when every role has a model.
bindingsjsonnullableLiteral headline values passed to bind(), by token name; see Binding Literal Values.
featuredstring(16)nullable, default 'object'The role whose entity the row draws as its body, set with featuring…(). Null draws none.
published_attimestamp(6)nullableWhen the activity happened. The feed orders by it, and only shows activities whose time has come.
starts_attimestamp(6)nullableWhen what the activity describes began, set with startsAt(). Null when the range has no start.
ends_attimestamp(6)nullableWhen what the activity describes ended, set with endsAt(). Null when the range has no end.
created_attimestamp(6)nullableWhen the row was written.
updated_attimestamp(6)nullableWhen the row last changed.
deleted_attimestamp(6)nullableSet when an activity is soft-deleted, by deleteFromFeed() for example. Soft-deleted activities are not shown.
IndexColumns
indexorigin_type, origin_id
indexresult_type, result_id
indexinstrument_type, instrument_id
indexlocation_type, location_id
indexgenerator_type, generator_id
indexpublished_at, id
indexactor_type, actor_id, published_at, id
indexobject_type, object_id, published_at, id
indextarget_type, target_id, published_at, id
indexcontext_type, context_id, published_at, id
indexobject_type, object_id, verb, published_at

feed_snapshots ​

Stores each model's label, data, and bodies from toFeed(). Feed retrieval uses these snapshots to resolve entity labels and links. storyfeed:trickle creates and refreshes snapshots; storyfeed:rebuild rebuilds them. Model keys are stored as strings, so integer, UUID and ULID keys all work, including a mix of them in one app.

ColumnTypeAttributesPurpose
idbigint, incrementsPKPrimary key. Activities point here through cached_{role}_id.
model_typestring(255)The entity's morph alias.
model_idstring(36)The entity's key.
labelstring(255)nullableThe label from toFeed().
datajsonnullableThe data from toFeed().
shapestring(40)nullableA fingerprint of the toFeed() output's structure. storyfeed:trickle refreshes rows whose fingerprint no longer matches.
contenttextnullableThe entity's authored text, from toFeed().
media_typetextnullableThe encoding of content.
attributed_totextnullableThe entity's author IRI, from toFeed().
bodyjsonnullableThe entity's bodies, from toFeed().
metajsonnullablePackage metadata: the route key and closest-parent identity when declared.
source_updated_atdatetime(6)nullableThe model's updated_at when the snapshot was taken, in UTC. Older writes are rejected only when both source timestamps are known; an incoming unknown timestamp is accepted and clears this watermark.
created_attimestampnullableWhen the snapshot was first written.
updated_attimestampnullableWhen the snapshot was last written.
IndexColumns
uniquemodel_type, model_id
indexmodel_type, shape

Grouping and Batching ​

feed_groupings ​

Stores candidate groups and the selected axis for each activity. Rebuild it with storyfeed:curate --rehash.

ColumnTypeAttributesPurpose
idbigint, incrementsPKPrimary key.
activity_idunsigned bigintThe activity this row places in a group.
hashstring(255)The group's key on this axis. Activities sharing a bucket and hash form one group.
bucketstring(255)nullableThe axis: actors, actors_target, targets, object, repeat, batch or composite.
winnerbooleannullableTrue on the row curation chose for live(). Null on rows that are never curated.
IndexColumns
uniqueactivity_id, bucket
indexactivity_id, winner, bucket
indexbucket, hash, activity_id, winner
indexwinner, bucket, hash

feed_grouping_bursts ​

Stores the latest burst window and publishing lock for each logical axis key. Closed memberships remain in feed_groupings.

ColumnTypeAttributesPurpose
keychar(64)PKSHA-256 logical axis key; also serializes publishers on the same key.
hashstring(200)nullableThe current burst membership hash.
opened_atdatetime(6)nullablePublication time of the first activity in the current burst.
last_activity_atdatetime(6)nullablePublication time of the latest activity in the current burst.
within_secondsunsigned intnullableQuiet gap used for the current burst.
ceiling_secondsunsigned intnullableMaximum duration used for the current burst.
locked_attimestampnullableWhen a publisher last locked this key.

feed_batches ​

Stores an actor's activities as batches, open until the configured window has elapsed.

The meta column holds your application's metadata as free-form JSON, written with ->meta([...]) when an activity joins the batch. When the batch closes, BatchClosed listeners receive a frozen copy in the batch snapshot's meta field.

ColumnTypeAttributesPurpose
idbigint, incrementsPKPrimary key.
uiduliduniqueThe batch's identifier. A batch grouping row's hash holds it.
actor_typestring(255)nullableThe actor's morph alias.
actor_idstring(36)nullableThe actor's key.
opened_attimestampThe published_at of the batch's first activity.
closed_attimestampindex, nullableWhen the batch closed. Null while it is open.
activities_countunsigned intdefault 0How many activities joined the batch.
last_activity_attimestampnullableThe latest published_at among its activities.
closes_attimestampnullableWhen the batch ends. Each activity moves it to its own published_at plus its verb's window, never earlier.
metajsonnullableYour application's metadata about the batch. Top-level storyfeed. keys are reserved.
created_attimestampnullableWhen the row was written.
updated_attimestampnullableWhen the row last changed.
IndexColumns
indexactor_type, actor_id

feed_batch_locks ​

Stores one lock per batched actor so concurrent publications join the same batch.

ColumnTypeAttributesPurpose
actor_typestring(255)The actor's morph alias.
actor_idstring(36)The actor's key, as a string.
open_batchesjsonnullableThe ids of the actor's open batches.
locked_attimestampnullableWhen a publish last locked the row.
IndexColumns
primary keyactor_type, actor_id

Participants ​

feed_entities ​

Named participants with no model in your app. The kind column distinguishes parties from the reserved record kind.

Pre-0.23 installs keep feed_parties and storyfeed.party when their published configuration pins the old table name and morph alias.

ColumnTypeAttributesPurpose
idbigint, incrementsPKPrimary key.
keystring(255)uniqueThe party's name as a slug, unless a key is given.
namestring(255)The party's label in the feed.
typestring(255)default 'Service'The party's Activity Streams type.
kindstring(16)default 'party'Entity kind: party for a named participant; record is reserved for non-model objects.
datajsonnullableThe data given to Party::make().
created_attimestampnullableWhen the party was created.
updated_attimestampnullableWhen the party last changed.

feed_participants ​

Indexes each activity's filled roles for involving() and $model->storyfeed() queries. Rebuild it with storyfeed:participants.

ColumnTypeAttributesPurpose
activity_idunsigned bigintThe activity.
rolestring(20)A direct role or ancestor; each entity has one row per activity.
entity_typestring(255)The entity's morph alias.
entity_idstring(36)The entity's key, as a string.
distanceunsigned tinyintdefault 0Stored distance: zero for direct participation; the minimum distance from object, target or context for an ancestor. Included in the covering entity index.
published_attimestamp(6)nullableCopied from the activity. The entity index narrows matching activity IDs for involving(); final ordering is on the outer activity query.
IndexColumns
primary keyactivity_id, entity_type, entity_id
indexentity_type, entity_id, published_at, activity_id, distance

Deletion and Metadata ​

feed_tombstones ​

Stores a tombstone for each deleted model, referenced by its activities. The alias is always storyfeed.tombstone, regardless of the morph map. See Deleted Models.

The meta column holds your application's metadata as free-form JSON, written with PendingTombstone::meta() in the model's tombstone declaration.

ColumnTypeAttributesPurpose
idbigint, incrementsPKPrimary key. Activities point at a tombstone with the storyfeed.tombstone alias.
model_typestring(255)The deleted model's morph alias.
model_idstring(36)The deleted model's key, as a string.
restorablebooleandefault falseTrue while the model is soft-deleted and can come back.
approximatebooleandefault falseTrue when storyfeed:trickle found the deletion, so deleted_at is when it was found.
deleted_attimestampnullableWhen the model was deleted.
labelstring(255)nullableThe label kept for the deleted model, when it keeps one.
metajsonnullableYour application's metadata about the deletion. Top-level storyfeed. keys are reserved.
created_attimestampnullableWhen the tombstone was created.
updated_attimestampnullableWhen the tombstone last changed.
IndexColumns
uniquemodel_type, model_id

feed_meta ​

Stores Storyfeed metadata, including the sync token.

ColumnTypeAttributesPurpose
idbigint, incrementsPKPrimary key.
keystring(255)uniquesync_token, trickle cursors, or maintenance:curate:<ULID> / maintenance:trickle:<ULID> entries in bounded maintenance-run history.
valuestring(255)The value; maintenance-run entries contain JSON counters for that completed run.
created_attimestampnullableWhen the row was written.
updated_attimestampnullableWhen the row last changed.

Released under the MIT License.