-
Activating a replay no longer aborts running commands with a deadlock. It locked the projector states and then waited for an exclusive lock on the view schema tables, while a command that had read one of those tables waited for the projector states to publish its events. Activation now checks the view schema first and then takes both locks together; when one is not granted in time it releases both before trying again, for at most
projectors_replayer_total_lock_timeout. -
Starting a replay or catching up waits for a running change of aggregate partition keys to commit, and keeps new ones out until the replay has switched state.
update_aggregate_partition_keyslocks the replay states inROW EXCLUSIVEmode, which the state change itself also takes, so a change that checked just before the switch could still move events while the replay read them, replaying them twice or missing them. An application that moves partition keys itself should take the same lock and checkReplayState.replayingin the same transaction. -
Preparing a replay for activation vacuums the replayed tables after clustering them or running
VACUUM FULL. Both write a table anew with an empty visibility map, whichANALYZEdoes not fill, so index-only scans on the activated tables read the heap and the first aggressive vacuum read every page. -
A replay group reads only the events in its own range of
(partition_key, aggregate_id)again. Its event stream lost the separate bound onpartition_key, so PostgreSQL could not use the range as an index condition and every group read all matching events of its partition. -
aggregates_that_need_snapshotsstores theaggregate_type_idof its aggregate, soregister_snapshot_versions!anddelete_unknown_snapshot_versionsno longer read theaggregatestable, which is large in a big event store. Requires running the Sequent migrations.The migration fills the new column with one lookup in
aggregatesper row ofaggregates_that_need_snapshots, in a single transaction that holds an exclusive lock onaggregates_that_need_snapshotsuntil it commits. Until then, storing events that mark an aggregate for snapshotting, storing snapshots and the snapshotter all wait. On a big event store, run it during downtime, or split it: add the column nullable together with the newstore_aggregatesandstore_snapshots, fill it in batches, then make itNOT NULL, add the foreign key and install the remaining functions. -
Breaking:
sequent/test/time_comparisonis removed. It patched the comparison ofTime,DateTimeandActiveSupport::TimeWithZoneto ignore the digits beyond thetime_precision, and was deprecated. Specs that compare an event with its stored copy should create its times at the precision the event store keeps. -
Breaking:
==,eql?andhashof value objects, events and commands are strict. Two objects are equal when they are of the same class and their attributes, taken from the instance variables and not through the readers, are strictly equal: 1 is not 1.0, aHashWithIndifferentAccessis not aHash, a symbol key is not a string key, a hash with a default is not one without, and aDateTimeis only equal to aDateTime. ATimeand anActiveSupport::TimeWithZoneare equal when they are the same instant at full precision, and so are twoDateTimes, where the comparison used to stop at the second. This affectsSet, hash keys,uniqand comparisons in specs. Create values of the declared type, and define==on a value object that needs another equality. -
A
CHECKconstraint on theeventstable refuses asequence_numberbelow 1. The migration adds itNOT VALID, so it does not check the events already stored and takes its lock only briefly. Validate it when convenient withALTER TABLE sequent_schema.events VALIDATE CONSTRAINT events_sequence_number_check, which reads every event. Requires running the Sequent migrations. -
Breaking: a time precision beyond microseconds is not supported, since PostgreSQL keeps times to the microsecond. Setting
Sequent.configuration.time_precisionabove 6 fails, and so does storing events while it is above 6, also when it is taken fromActiveSupport::JSON::Encoding. -
The
ReplayOptimizedPostgresPersistorno longer leaves lazy transactions disabled on its connection. The COPY that loads the replayed records takes the raw connection, which made ActiveRecord send BEGIN and COMMIT for every later transaction on that connection, also for one that runs no query. -
before_apply,after_applyandaround_applyhooks run code before, after or around each event an aggregate root applies, for example to check a condition that must hold before and after every change. They do not run when the aggregate is loaded, and takeonly:orexcept:with the same event classes and message matchers ason. See hooks around applying events. -
ProjectorsReplayerrefuses to prepare for activation and to activate when the view schema tables of the replayed projectors changed since the replay was prepared, since activating replaces them with the replayed tables, which do not have the change. Prepare the replay again instead. Changes to the replay schema tables are allowed. A replay prepared before upgrading is not checked. Requires running the Sequent migrations. -
Breaking: the event store publishes the events as they are loaded from it, so projectors and workflows see the same values when the events are stored and when they are replayed: times truncated to the
time_precision, symbols as strings and attributes cast to their type. Event handlers can therefore receive other values than before. The aggregate keeps the values it applied. Storing an event whosecreated_atis not aTimeorActiveSupport::TimeWithZone, such as aString,DateorDateTime, or whosesequence_numberis not a positiveInteger, fails instead of converting it. The event store also fails on anaggregate_idthat is not a lowercase UUID, such as one in uppercase, which it used to store as its lowercase form. The test event store still accepts anyaggregate_id. An event whoseaggregate_iddiffers from that of its stream is refused, by the test event store and the dry run as well. Requires json 2.10 or later. -
Set
Sequent.configuration.verify_event_serialization, for instance in specs, to fail when an event changes when it is stored, other than by truncating its times, so the domain code can be fixed. SetSequent.configuration.event_serialization_error_handlerto report the error instead, for instance in production, without failing the command. -
Breaking: the support for event, command and snapshot JSON in text columns is removed, since the event store keeps these in jsonb columns since Sequent 8.
serialize_json?andEventRecord.serialize_to_jsonare removed,SerializesEventandSerializesCommandstore the JSON as a hash, and the event store deserializes loaded events directly from their JSON instead of using theevent_record_class, which makes loading events about 40% faster. -
Breaking: creating a record whose table has a
created_atcolumn without acreated_atfails with aPersistors::MissingCreatedAtError, with all persistors. The persistors used the current time, so the record got other timestamps when the events were replayed. Pass thecreated_atof the event, which is also used asupdated_atunless that is given.create_or_update_recordno longer defaults itscreated_atto the current time. -
Bug: the
ActiveRecordPersistorsetupdated_atto the current time when a block given todo_with_record,do_with_recordsorcreate_or_update_recordchanged an existing record without settingupdated_at, and whenupdate_recordchanged a record whoseupdated_atwas already the time of the event. A replay with theReplayOptimizedPostgresPersistorkept the earlierupdated_at. Block based updates now only changeupdated_atwhen it is set, so it is the same after a replay. -
Sequent uses Ruby's
jsongem instead of Oj to serialize and load events, commands and snapshots.Sequent::Core::JsonreplacesSequent::Core::Oj, which is deprecated and usesSequent::Core::Json. Sequent no longer depends on Oj, and no longer setsOj.default_options. Applications using Oj directly must depend on it and configure it themselves: withoutmode: :rails,Oj.dumpwrites a symbol key like:fooas":foo"instead of"foo". Differences with the JSON Oj wrote and loaded:- Numbers in untyped values, such as in a
Hashattribute, load asFloat, also when they have more digits than aFloatkeeps. Oj loaded those asBigDecimal.BigDecimalattributes are written as strings and load as before. <,>,&, U+2028 and U+2029 in strings are written as they are instead of escaped. The values are the same once loaded.- Times are written using
Sequent.configuration.time_precision, also when it differs from ActiveSupport's, and always in ISO 8601, also whenActiveSupport.use_standard_json_time_formatis disabled. Sequent::Core::Json.strict_loadfails with aJSON::ParserErroron an object with a duplicate key, where Oj kept the last value. Stored events have none, sincejsonbkeeps one value per key, but other JSON loaded with it, also throughSequent::Core::Oj, can.- JSON nested more than 100 levels deep fails with a
JSON::NestingError, when writing as well as when loading.
- Numbers in untyped values, such as in a
-
Sequent.configuration.time_precisionuses the current value ofActiveSupport::JSON::Encoding.time_precisionwhen it is not set, instead of the value ActiveSupport had when Sequent was loaded.Sequent::Configuration::DEFAULT_TIME_PRECISIONis removed. -
A record class that includes
Sequent::Core::ProjectionRecordcan only be written by projectors, unless writing is allowed usingSequent::Core::ProjectionWrites. Thehave_no_write_callbacksmatcher ofSequent::Test::ProjectionRecordHelperschecks that such a record class has no write callbacks or validations, which do not run when replaying. See read-only records. -
Persistor#commitandProjector#commitare renamed toflush.commitis a deprecated alias. Custom persistors must implementflush. -
Replaying passes the replayed events directly to the projectors instead of using an event publisher.
EventStore#replay_events_from_cursortakes a block that receives the events of each block, instead of anevent_publisher.Breaking for subclasses of the replayers:
with_sequent_configis removed, andreplay_eventstakes the projectors instead of the replay persistor. Create these usingreplay_projectors:projectors = replay_projectors(replay_persistor, projector_classes) replay_events(get_events, projectors, &on_progress)
-
Bug: activating a replay flushed another instance of the
offline_replay_persistor_classthan the one the projectors used, losing the changes of persistors that buffer them. -
MessageRouter#match_messagereturns a frozen empty set when no handler matches the message, instead of allocating a new set. This avoids an allocation for every message handler that does not handle a message, like aggregates applying events and event handlers that get every published event. -
Message handlers (like projectors and workflows) support hooks that run before, after or around each invocation of a handler block, for example to add instrumentation. The hooks are only run when a handler block is invoked, receive the messages it handles, and are inherited by subclasses:
class ApplicationProjector < Sequent::Projector self.abstract_class = true around_handler :instrument def instrument(messages) Instrumenter.instrument("#{messages.first.class}.#{self.class}") { yield } end end
An
around_handlerhook skips the handler block by not continuing. Prefer these hooks over overridingdispatch_message. -
Replaying projectors keeps the extended statistics objects (
CREATE STATISTICS) of the managed tables. They are copied to the replay schema when preparing, soANALYZEfills them before activation, and moved along with their tables when activating. Before,pg_dump --tableleft them out of the replay schema andALTER TABLE ... SET SCHEMAleft them behind on the archived tables. Preparing and activating fail when a statistics object on a managed table lives outside the view schema; drop it and recreate it in the view schema before preparing the replay, or after activating it. -
Activating a replay fails when a publication lists a managed table by name (
CREATE PUBLICATION ... FOR TABLE). The publication would keep the archived table and silently stop publishing the replayed one. Remove the table from the publication before activating, and resynchronize the subscribers afterwards. PublicationsFOR ALL TABLESorFOR TABLES IN SCHEMAinclude the replayed tables by themselves. -
load_eventslooks up an aggregate's events partition key first and then queries the events with that key as a parameter, so a custom plan can prune the events partitions while planning. It is nowSTABLE, which runs both queries against the same snapshot. It returns the snapshot and the events after it from separate statements, so the events come straight from the index in sequence number order instead of being sorted together with the snapshot.load_eventloads by partition key the same way. The other read-only functions (load_latest_snapshot,aggregates_that_need_snapshots,enrich_event_jsonandenrich_command_json) areSTABLEtoo, and the twoenrich_*functions arePARALLEL SAFE, so queries over theevent_recordsandcommand_recordsviews can use parallel workers. Applying partition key changes skips aggregates that another transaction has locked instead of waiting for them. -
Sequent requires PostgreSQL 16.13 or later.
-
The
AggregateRepositorycallsinvariants!on an aggregate after loading it from the event store and before committing its uncommitted events.AggregateRoot#invariants!does nothing; an aggregate overrides it to check its state. An exception raised byinvariants!is passed, with the aggregate and:loador:commit, to the configurableaggregate_invariant_violation_handler, which by default raises anAggregateInvariantViolationErrorwith the aggregate type, id and phase and the original exception as its cause. AnInvariantsAppliedEventsis raised wheninvariants!applies events. -
Sequent now supports zero-downtime deployments (rolling upgrades). To enable this feature you must use the
ActiveProjectorsEventPublisherto ensure events are only published to active projectors with the correct projector version number. Rake tasks are provided to prepare, replay, and activate projectors. See https://sequent.io/docs/concepts/migrations.html for more information. -
Database connection management has been removed from Sequent and must be provided by the hosting application. This is done automatically by Rails and can be done using the
sinatra-activerecordgem if you are using Sinatra.Otherwise you can add code like:
ActiveRecord::Base.configurations = YAML.load_file( 'db/database.yml', aliases: true, ) ActiveRecord::Base.establish_connection(Sequent.env&.to_sym)
The Sequent configuration options
database_config_directory,database_schema_directory,primary_database_key, andprimary_database_rolehave been removed. -
To prepare for rolling upgrades of Sequent based applications the snapshot of an aggregate can now be versioned. This means that whenever the snapshot format changes you should either delete all snapshot on deployment of the new version (and ensure no old code is running, which is a current requirement) or you should increment the snapshot version using
enable_snapshots version: 2. In this case the old version of the code will continue to use snapshot version 1 (the default version) while new code will only use snapshot version 2. -
Also in preperation of rolling upgrades the enabled projectors are now tracked in the
projector_statestable. Use theActiveProjectorsEventPublisheras theevent_publisherto enable this feature.Only projectors that are active will process events during normal operation. Events that are published while a newer projector is activating or active will fail with a
DifferentProjectorVersionIsActiveErrorerror. Event replay uses the normalEventPublisherwhich does not check for projector state, since replaying will write to temporary tables until replay is finalizedWhen an unknown projector is active all event processing will be blocked. This allows deploying a new version while the old version of the code is still running and processing events. Only after executing
Sequent#activate_current_configuration!will the new code start processing events, while the old code is blocked. At this moment traffic can be redirected from the old version to the new version.Activating the current configuration is part of the
migrate:offlinerake task, so the current deployment process (run online migrations, take old code offline, run offline migrations, start running the new code) will keep working as is. -
AggregateRepository#find_aggregates_by_unique_key_containing(scope, partial_key, clazz = nil)loads every aggregate whose unique key inscopecontainspartial_key, using PostgreSQL's jsonb@>: a key{employee_id: 'e1', period: '2024-01'}is found by{employee_id: 'e1'}. An optional block receives each matching key and decides which aggregates are loaded, for conditions a containment check cannot express. A GIN index on the scope and key makes the lookup efficient; copy the migration atdb/migrate/20260925120000_sequent_index_aggregate_unique_keys_by_scope_and_key.rbto create it. The index is built concurrently, so it does not block writes. It needs thebtree_ginextension for the scope column, which the migration creates in the event store schema;btree_ginis a trusted extension, so the database owner can create it. -
AggregateRepository#find_aggregate_by_unique_keyand#find_aggregates_by_unique_key_containingalso match the aggregates in the repository on their current unique keys. An aggregate that is added but not yet committed is now found, and one whose key changed since it was loaded is only found by its new key. -
ReplayOptimizedPostgresPersistor#commitloads the records of each table usingCOPY, also for small numbers of records that used to be inserted using oneINSERTstatement per record. Values that already have the Ruby class of their column type (integers, decimals, dates, timestamps, booleans and strings) are encoded by the C encoders of thepggem instead of being serialized by ActiveRecord, which makes committing about four times as fast. All other values are still serialized by ActiveRecord, so the stored values do not change. Theinsert_with_csv_sizeargument is no longer used and is deprecated.A column without a value whose default the database computes (like a serial column, including
id, or a default ofnow()) is left out of theCOPY, so the database computes its value, like ActiveRecord does. Records that leave out different columns are loaded using aCOPYper set of columns, in a single transaction per table; usually all records of a table leave out the same columns. Before, these columns were loaded asNULL, except forid, which was always left out, also when it had a value. A computed column updated tonilby the persistor is loaded asNULL, like ActiveRecord updates it. Specs check that the persistors store the same values, and document where they differ, like on views. -
The
ActiveRecordPersistorstorescreated_atasupdated_atwhen creating a record with onlycreated_at, like theReplayOptimizedPostgresPersistoralready did. Before, ActiveRecord setupdated_atto the current time, so replaying a projector changed theupdated_atof its records. TheReplayOptimizedPostgresPersistorno longer replaces a givenupdated_atwithcreated_at, and sets the timestamps without a value to the current time when creating a record (ifrecord_timestampsis enabled), like ActiveRecord does, instead of loading them asNULL.
- Bug: Fix resetting column information and table_name when using Single Table Inheritance.
- Improvement: Fail fast when passing a non managed_table to the Persistor
- Improvement: Log current event when replaying fails
-
The sequent gem now uses ActiveRecord migrations to handle the
sequent_schema. Theview_schemais still handled by sequent itself. You can install the sequent migrations in your project by runningrake sequent:install:migrationswhich will copy the necessary files to yourdb/migratedirectory.After upgrading Sequent you can run this task again to install any updates for the schema.
-
There is a new rake task
sequent:migrate:unique_keyswhich allows you to migrate aggregates when you change an aggregate's unique keys. The task loads each aggregate (optionally filtered by the type) from history, and updates the associated unique keys.
-
Revert type id assignment changes as it introduces potential deadlocks when new types are added. If you already aplied the changes in release 8.1.0 you will have to execute the following SQL when upgrading:
SET search_path TO sequent_schema; ALTER TABLE aggregate_types ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY; ALTER TABLE command_types ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY; ALTER TABLE event_types ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY; SELECT setval('aggregate_types_id_seq', COALESCE((SELECT MAX(id) + 1 FROM aggregate_types), 1), false); SELECT setval('command_types_id_seq', COALESCE((SELECT MAX(id) + 1 FROM command_types), 1), false); SELECT setval('event_types_id_seq', COALESCE((SELECT MAX(id) + 1 FROM event_types), 1), false);
-
Support specifying unique keys for aggregates that are checked when transaction is committed, reducing the need for having aggregates to ensure uniqueness or relying on projectors. See lib/sequent/core/helpers/unique_keys.rb for details.
This feature requires a new database, you can find an example migration at
db/migrate/20250108162754_aggregate_unique_keys.rb. -
CommandHandlerHelpershas been updated to:- Load aggregates using the
given_eventsso that unique keys can be tested. This may require changing your test to correctly set up the given events. - Run your test using the real or fake event store.
- Use RSpec matchers in
then_events. then_eventsnow only checks the events since the lastwhen_commandcall occurred.
- Load aggregates using the
-
You can now retrieve the current position of the event store using
EventStore#position_markand load all the events since this position usingEventStore#load_events_since_marked_position. This is used byCommandHandlerHelpersbut in the future might have other uses (such as tailing the event store as events are being committed). -
Use
max(id) + 1query to assign type ids to avoid exhausing the SMALLINT range. Sequences are not rolled back when a transaction is aborted so type ids may become exhausted. This is mainly a problem in development when running tests, but could occur in production if a transaction that adds a new type is buggy and gets rolled back multiple times.Re-apply the
sequent_pgsql.sqlfile to your Sequent schema to apply this fix.
- Add support for ActiveRecord 8. Thanks evsasse.
- Improvements for internal testing of Sequent.
- Fix Sequent CLI
- Check the upgrade guide for upgrading an existing application using Sequent < 8.
- Sequent now requires at least Ruby 3.2, ActiveRecord 7.1, and PostgreSQL 14.
- The internal database schema has been re-organized to support table
partitioning so the events of related aggregates can be stored
together. Partitioning is optional. You can override the
AggregateRoot#events_partition_keymethod to return the partition key of an aggregate that will be used by PostgreSQL to store the events in the correct partition. - Storage logic of Sequent is now done by PostgreSQL stored procedures. This reduces the number of round-trips necessary between the Ruby process and the PostgreSQL server and optimizes storage requirements.
AggregateRoot#take_snapshot!has been replaced withAggregateRoot#take_snapshotwhich returns the snapshot instead of adding it to the uncommitted events. Snapshots can be stored usingEventStore#store_snapshotsmethod.- The
stream_records,event_records, andcommand_recordsrelations are no longer tables but views on the underlyingaggregates,events, andcommandstables. These views take care of joining related tables using the correct partitioning key and type ids. The views are mainly for backwards compatibility with the*RecordRuby classes and can only be used for querying. For updates theEventStore(and higher-levelAggregateRepository) classes should be used. New APIs have been added so there is no longer a need to use ActiveRecord methods directly to manage the event store. - Events, commands, and snapshot are now serialized directly to a
JSONorJSONBcolumn. TheTEXTcolumn type is no longer supported. JSON size is minimized by extracting various repetitive fields (such asaggregate_id) into database columns. - Snapshots are now stored into a separate
snapshot_recordstable instead of being mixed in with events in theeventstable. This also makes it possible to store snapshots without an associated command record. Aggregates that need snapshots are tracked in a separateaggregates_that_need_snapshotsso that snapshots can be created more quickly by a background snapshotting process. - The
parent,originandchildrenmethods ofCommandRecordandEventRecordhave been replaced by more specific methods (origin_command,parent_event, etc) and will always return a record of the appropriate type. - Events that are updated or deleted (a rare occurrence) are archived
into the
saved_event_recordstable. - The
idcolumn ofaggregateshas been removed and the primary key is now theaggregate_idcolumn. - The
idcolumn ofeventshas been removed and the primary key are now theaggregate_idandsequence_numbercolumns.
- Many documentation improvements.
- Other small bug fixes.
Small bugfix for metadata tables migrations. See #418. Thanks evsasse.
BREAKING CHANGE:
- Replaying all events for the view schema (using
sequent:migrate:onlineandsequent:migrate:offline) now make use of the PostgreSQL committed transaction id (xact_id()) to track events that have already been replayed. The replayed ids table (specified by the removedSequent::configuration.replayed_ids_table_nameoption) is no longer used and can be dropped from your database. There is no activerecord migration provided for the event store to add thexact_idsince depending on the size of the event store you may want to take run this migration yourself. ReplaceSCHEMA_NAMEwith the name of the sequent schema:
BEGIN;
ALTER TABLE SCHEMA_NAME.event_records ADD COLUMN xact_id bigint;
COMMIT;
BEGIN;
# SET max_parallel_maintenance_workers = 8; # optionally set this depending on size of your event_records
# ALTER TABLE SCHEMA_NAME.event_records SET (parallel_workers = 8); # optionally set this depending on size of your event_records
CREATE INDEX event_records_xact_id_idx ON SCHEMA_NAME.event_records (xact_id) WHERE xact_id IS NOT NULL;
# ALTER TABLE SCHEMA_NAME.event_records RESET (parallel_workers); # optionally set this depending on size of your event_records
COMMIT;
ALTER TABLE SCHEMA_NAME.event_records ALTER COLUMN xact_id SET DEFAULT pg_current_xact_id()::text::bigint;
Next to this migration make sure you copy over the new sequent_schema.rb into your project so when you regenerate the database from scratch
in for instance your development environment you have the correct version.
Other notable changes:
- The
MessageDispatcherclass has been removed. - Instance-of routes in projectors and other message handlers now use an optimized lookup mechanism. These are the most common handlers (
on MyEvent do ... end). - Many optimizations were applied to the
ReplayOptimizedPostgresPersistor:- Multi-value indexes are no longer supported, each column is now individually indexed. When a where clauses references multiple indexed columns all applicable indexes are used. For backwards compatibility multi-column index definitions are automatically changed to single-column indexes (one for each colum in the multi-column definition).
- Default indexed columns can be specified when instantiating the
ReplayOptimizedPostgresPersistor. - Indexed values are now automatically frozen.
- Array matching and string/symbol matching in where-clauses now work for indexed columns as well.
- The internal struct classes are now generated differently and these classes are no longer associated with a Ruby constant so cannot be referenced from your code.
- Added possibility
enable_autoregistrationfor automatically registering all Command and EventHandlers - In a Rails app all code will be eager loaded when
enable_autoregistrationis set to true upon sequent initialization viaRails.autoloaders.main.eager_load(force: true). If other parts of your app (esp initializers) are dependent on code not being loaded yet you can ensure Sequent loads as last by renaming the initializer to e.g.zz_sequent.rbas Rails loads initializers in alphabetical order.
BREAKING CHANGES:
- Introduced
event_store_cache_event_typesas alternative for manually instantiating the EventStore yourself if you want to disable caching of event types. - Calling
Sequent.configuretwice will now create a new instance of the configuration instead of changing the current instance. This is done to better support Rails apps and the reload functionality during development.
- Drop support for ruby < 3
- Upgraded ActiveStar
- Add support for ruby 3.2
- Changed the default type of
aggregate_idinsequent_schematouuidsince Postgres support this for quite long. - Added support for applications using ActiveRecord multiple database connections feature
- Improved out-of-the-box Rails support by fixing various bugs and providing Rake task to ease integration. See for more details: https://www.sequent.io/docs/rails-sequent.html
- Introduce
SEQUENT_ENVinstead ofRACK_ENV.SEQUENT_ENVdefaults to the value ofRAILS_ENVorRACK_ENV. - Introduce
Sequent.configuration.time_precisionwhich defaults toActiveSupport::JSON::Encoding.time_precisionwhich is the precision "after seconds" to store time in json format when an event is serialized. - Custom command validations will now be translated according to the locale set by
Sequent.configuration.error_locale_resolver
BREAKING CHANGES:
- Since
DateTimeis deprecated in the Ruby std lib the standard attributecreated_atofEventandCommandis now aTime. This should not be a problem when serializing an deserializing but might be breaking if you rely on the fact it being aDateTimerather than aTime. - Renamed file of
Sequent::Test::WorkflowHelperstoworkflow_helpers. If you require this file manually you will need to update it's references - You now must "tag" specs using
Sequent::Test::WorkflowHelperswith the following metadataworkflows: trueto avoid collision with other specs - Bugfix:
rake sequent:migrate:onlinewill now callreset_column_informationwhen done. Otherwise a subsequentsequent:migrate:offlinecalled in the same memory space fails.
- Introduce several advanced features for
Sequent::Core::Helpers::MessageHandlers (ie.Sequent::AggregateRoot,Sequent::Projector,Sequent::WorkflowandSequent::CommandHandler), namely:- Message matching (see https://www.sequent.io/docs/concepts/advanced.html#message-matching)
- Load time options (see https://www.sequent.io/docs/concepts/advanced.html#message-handler-load-time-options)
on MyEvent, MyEventwill now raise an error stating the duplicate argumentsonwithout arguments will now raise an error- Declaring duplicate
attrswill now raise an error
- Add ability to to load aggregates up until a certain point in time (use with caution)
- Support for ActiveStar 7.x
- Support for Ruby 3.1
- Various documentation fixes
- Upgrade to latest ar 6.1.4.x version
- Various setup fixes when doing
sequent new myapp - Improve
dry_runfeature by using real event store
- Improve performance when running specs by not using
descendants - Support for ActiveRecord 6.1.x
- Fixed some rake tasks for snapshotting (Thanks HEROGWP)
- Improve
ReplayOptimizedPostgresPersistor::Index - Various improvements to the database config (to use database url and aliases) (Thanks Bér Kessels)
- Allow for event upcasting
- Add rubocop
- Changed default ruby to 3.0.0 release
- Added
database_schema_directoryconfiguration parameter to determine where to findsequent_schema.rbandsequent_migrations.rb. Currently it has the same default asdatabase_config_directory - Dropped support for ruby < 2.7
- Moved to Github Actions for CI
- Allow splitting of indices and table definition in sql files to speed up replaying projectors
- Changed default ruby to latest 2.6 release
- Added support for ActiveRecord 6.0
- Added documentation for using with Rails
- Added alter table capabilities to migrations. Useful for larger projections.
- Added
Sequent::Projector.manages_no_tables.
- Introduced
strict_check_attributes_on_apply_events. Sequent will fail when callingapplywith unknown attributes.
Introduces optional event_aggregate_id and event_sequence_number columns to the command_records table.
This enables keeping track of events causing commands in workflows.
To add these columns to an existing event store you can use this sql to add them:
Please note these sql statements use the uuid type for aggregate_id.
ALTER TABLE command_records ADD COLUMN event_aggregate_id uuid;
ALTER TABLE command_records ADD COLUMN event_sequence_number integer;
CREATE INDEX CONCURRENTLY index_command_records_on_event ON command_records(event_aggregate_id, event_sequence_number);
The most notable changes are:
- Added more documentation on https://www.sequent.io
- Added support for AR 5.2
- Added rake task to support installation on existing databases
The most notable changes are:
- Added extensive documentation for Sequent.
- Addition of more sophisticated way of replaying. See the documentation on how to configure.
- Dropped support for AR < 5.0
- Deprecated MigrateEvents as strategy for event migration
- Renamed Sequent::Core::BaseEventHandler to Sequent::Core::Projector
- Renamed Sequent::Core::Sessions::ActiveRecordSession to Sequent::Core::Persistors::ActiveRecordPersistor
- Renamed Sequent::Core::Sessions::ReplayEventsSession to Sequent::Core::Persistors::ReplayOptimzedPostgresPersistor
The most notable changes are:
To illustrate the difference see example below:
# command c1 results in event e1 on c1 do apply e1 end # workflow: event e1 results in new command c3 on e1 do execute_commands(c3) end # main execute_commands(c1, c2)
Prior to version 1.1 the order is as follows:
c1c3c2e1
As you can see command c3 is executed before c2 although c2 was scheduled before c3.
As of version 1.1 the order will be:
c1c2c3e1
Commands and events are added to the queues as they occur and than handled in that order. If you have never had workflows scheduling new commands in the foreground nothing changes. If you have used workflows in the foreground the order will be different, so ensure your system still behaves correctly.
The Sequent::Core::EventStore::PublishEventError is renamed to Sequent::Core::EventPublisher::PublishEventError
Another possible breaking change is the way the config is setup. The sequent config now global, so some sequent classes in the config do not take parameters anymore. You will need to change your sequent config, and will have affect on your tests. Please see the docs and the example apps for more information.
Full list of changes:
- New: Adding
TakeSnapshotcommand to enable fine-grained support for snapshotting aggregates #92 - Improvement: Minimize differences between test environment and normal environment #93
- Bugfix: Fix query to load multiple aggregates of which one is snapshotted #94
- Improvement: Speed up event query #95
- New: Added
create_recordsmethod available toBaseEventHandlersto insert multiple records in one go #96 #100 - New: Added queue-based command and event publishing to ensure commands and events are handled in order they occurred #97
- Improvement: Update
ojto mimic ActiveSupport version 5. Thanks @respire! #98 - Bugfixes: Fix sequent for AR => 5 #99
- Improvement: Global sequent config #101