The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
- Fixed autoloading the VERSION constants
- Fixed Ensuring inheritance issues with STI tabled
- Enabled gaplock protection when using trilogy mysql adapter
- Added Ruby 3.3 to build matrix
- Added optional initial transition
- Added multi-database support #522
- This now uses the correct ActiveRecord connection for the model or transition in a multi-database environment
- Updated to support ActiveRecord > 7.2
- Remove support for:
- Ruby; 2.7
- Postgres; 9.6, 10, 11
- MySQL; 5.7
- Fixed calls to reloading internal cache is the state_machine was made private / protected
- Calling
active_record.reload
resets the adapter's internal cache
- Fixed an edge case where
adapter.reset
were failing if the cache is empty
- Fixed caching of
last_transition
#505
- Add the source location of the guard callback to
Statesman::GuardFailedError
- Added support for Ruby 3.1 #462
- Added
remove_state
andremove_transitions
methods toStatesman::Machine
#464
- Removed support for Ruby 2.5 and 2.6 #462
- Deprecate
ActiveRecord::Base.default_timezone
in favour ofActiveRecord.default_timezone
#446
- Added Ruby 3.0 support
- Removed Ruby 2.4
- Implement
Machine#last_transition_to
, to find the last transition to a given state #438
- Fixed a bug where the
history
of a model was left in an incorrect state after a transition conflict #433
- Fixed
no implicit conversion of nil into String
error when quoting null values #427
- Use AR Arel table to type cast booleans in order to avoid deprecation warning #421
- Support relationships that doesn't use
id
as a Primary Key #422
- Add #reset method to state machine and adapter interfaces #417
- Gem Metadata to make finding changes between releases even easier.
- Use correct Arel for null #409
- Set non-empty password for postgres tests #398
- Handle transitions differently for MySQL #399
- pg requirement from >= 0.18, <= 1.1 to >= 0.18, <= 1.3 #400
- Lazily enable mysql gaplock protection #402
- Fix
to_s
onTransitionFailedError
&GuardFailedError
..message
and.to_s
diverged whenfrom
andto
accessors where added in v4.1.3
- Fix deprecation warning with Ruby 2.7 #386
- Drop official support for Rails 4.2, 5.0 and 5.1, following our compatibility policy.
- Drop official support for Ruby 2.2 and 2.3 following our compatibility policy.
- Issue
most_recent_transition_join
query as a single-line string #381
- Correct
Statesman::Adapters::ActiveRecordQueries
error text @Bramjetten - Removes duplicate
map
call Isaac Seymour
- Update changelog with instructions of how to use
ActiveRecordQueries
added in v5.0.0 - Pass exception into
after_transition_failure
andafter_guard_failure
callbacks @credric-cordenier
-
Adds new syntax and restrictions to ActiveRecordQueries PR#358. With the introduction of this, defining
self.transition_class
orself.initial_state
is deprecated and will be removed in the next major release. Changeinclude Statesman::Adapters::ActiveRecordQueries def self.initial_state :initial end def self.transition_class MyTransition end
to
include Statesman::Adapters::ActiveRecordQueries[ initial_state: :initial, transition_class: MyTransition ]
- Reverts the breaking changes from PR#358 &
v4.1.3
that where included in the last minor release. If you have changed your code to work with these changesv5.0.0
will be a copy ofv4.1.3
with a bugfix applied.
- Add accessible from / to state attributes on the
TransitionFailedError
to avoid parsing strings @ahjmorton - Add
after_transition_failure
mechanism @credric-cordenier
- Add support for Rails 6 @greysteil
- Fix statesman index detection for indexes that start t-z @hmarr
- Correct access of metadata via
state_machine
@glenpike
- Add better support for mysql (and others) in
transition_conflict_error?
@greysteil (#342)
- Fixes an issue with
after_commit
transition blocks that where being executed even if the transaction rolled back. (patch by @matid)
- Forces Statesman to use a new transactions with
requires_new: true
(#249)
- Expose
most_recent_transition_join
- ActiveRecordsor
requires that both sides of the query match up. Exposing this methods makes things easier if one side of theor
usesin_state
ornot_in_state
. (patch by @adambutler) - Various Readme and CI related changes.
- Support ActiveRecord transition classes which don't include
Statesman::Adapters::ActiveRecordTransition
, and thus don't have a.updated_timestamp_column
method (see #310 for further details) (patch by @timrogers)
- When unsetting the
most_recent
flag during a transition, don't assume that transitions have anupdated_at
attribute, but rather allow the "updated timestamp column" to be re-configured or disabled entirely (patch by @timrogers)
- Touch
updated_at
on transitions when unsettingmost_recent
flag (patch by @NGMarmaduke) - Fix
force_reload
for ActiveRecord models with loaded transitions (patch by @jacobpgn)
- Allow specifying metadata with
Machine#allowed_transitions
(patch by @vvondra)
- Add support for Rails 5.0.x and 5.1.x (patch by @kenchan0130 and @timrogers)
- Run tests in CircleCI instead of TravisCI (patch by @timrogers)
- Update Rubocop and fix offences (patch by @timrogers)
- Drop support for Rails < 4.2
- Drop support for Ruby < 2.2
For details on our compatibility policy, see docs/COMPATIBILITY.md
.
- Better handling of custom transition association names (patch by @greysteil)
- Add foreign keys to transition table generator (patch by @greysteil)
- Support partial indexes in transition table update generator (patch by @kenchan0130)
- Add support for Rails 5 (excluding Mongoid adapter)
- No changes from v2.0.0.rc1
- Unset most_recent after before transitions
- TL;DR: set
autosave: false
on thehas_many
association between your parent and transition model and this change will almost certainly not affect your integration - Previously the
most_recent
flag would be set tofalse
on all transitions during anybefore_transition
callbacks - After this change, the
most_recent
flag will still betrue
for the previous transition during these callbacks - Whilst this behaviour is almost certainly what your integration already expected, as a result of it any attempt to save the new, as yet unpersisted, transition during a
before_transition
callback will result in a uniqueness error. In particular, if you have not setautosave: false
on thehas_many
association between your parent and transition model then any attempt to save the parent model during abefore_transition
will result in an error
- TL;DR: set
- Require a most_recent column on transition tables
- The
most_recent
column, added in v1.2.0, is now required on all transition tables - This greatly speeds up queries on large tables
- A zero-downtime migration path is outlined in the changelog for v1.2.0. You should use that migration path before upgrading to v2.0.0
- The
- Increase default initial sort key to 10
- Drop support for Ruby 1.9.3, which reached end-of-life in February 2015
- Move support for events to a companion gem
- Previously, Statesman supported the use of "events" to trigger transitions
- To keep Statesman lightweight we've moved event functionality into the
statesman-events
gem - If you are using events, add
statesman-events
to your gemfile and includeStatesman::Events
in your state machines
- Add after_destroy hook to ActiveRecord transition model templates
- Add
in_state?
instance method toStatesman::Machine
- Add
force_reload
option toStatesman::Machine#last_transition
- Fix
in_state
queries with a customtransition_name
(patch by 0tsuki) - Fix
backfill_most_recent
rake task for databases that support partial indexes (patch by greysteil)
- Rename
last_transition
alias inActiveRecordQueries
tomost_recent_#{model_name}
, to allow merging of two such queries (patch by @isaacseymour)
- Make
backfill_most_recent
rake task db-agnostic (patch by @timothyp)
- Clarify error messages when misusing
Statesman::Adapters::ActiveRecordTransition
(patch by @isaacseymour)
- Fix use of most_recent column in MySQL (partial indexes aren't supported) (patch by @greysteil)
- Add support for namespaced transition models (patch by @DanielWright)
- Add support for Postgres 9.4's
jsonb
column type (patch by @isaacseymour)
- Add a
most_recent
column to transition tables to greatly speed up queries (ActiveRecord adapter only).- All queries are backwards-compatible, so everything still works without the new column.
- The upgrade path is:
- Generate and run a migration for adding the column, by running
rails generate statesman:add_most_recent <ParentModel> <TransitionModel>
. - Backfill the
most_recent
column on old records by runningrake statesman:backfill_most_recent[ParentModel]
. - Add constraints and indexes to the transition table that make use of the new field, by running
rails g statesman:add_constraints_to_most_recent <ParentModel> <TransitionModel>
.
- Generate and run a migration for adding the column, by running
- The upgrade path has been designed to be zero-downtime, even on large tables. As a result, please note that queries will only use the
most_recent
field after the constraints have been added.
ActiveRecordQueries.{not_,}in_state
now accepts an array of states.
- Support for Rails 4.2.0.rc2:
- Remove use of serialized_attributes when using 4.2+. (patch by @greysteil)
- Use reflect_on_association rather than directly using the reflections hash. (patch by @timrogers)
- Fix
ActiveRecordQueries.in_state
whenModel.initial_state
is defined as a symbol. (patch by @isaacseymour)
- Transition metadata now defaults to
{}
rather thannil
. (patch by @greysteil)
No changes from v1.0.0.beta2
- Rename
ActiveRecordModel
toActiveRecordQueries
, to reflect the fact that it mixes in some helpful scopes, but is not required.
- Classes which include
ActiveRecordModel
must define aninitial_state
class method.
ActiveRecordModel.in_state
andActiveRecordModel.not_in_state
now handle initial states correctly (patch by @isaacseymour)
- Transition tables created by generated migrations have
NOT NULL
constraints onto_state
,sort_key
and foreign key columns (patch by @greysteil) before_transition
andafter_transition
allow an array of to states (patch by @isaacseymour)
- Optimisation for Machine#available_events (patch by @pacso)
- Stop generating a default value for the metadata column if using MySQL.
- Adds check in Machine#transition to make sure the 'to' state is not an empty array (patch by @barisbalic)
- Events. Machines can now define events as a logical grouping of transitions (patch by @iurimatias)
- Retries. Individual transitions can be executed with a retry policy by wrapping the method call in a
Machine.retry_conflicts {}
block (patch by @greysteil)
Adapters::ActiveRecord
now handlesActiveRecord::RecordNotUnique
errors explicitly and re-raises with aStatesman::TransitionConflictError
if it is due to duplicate sort_keys (patch by @greysteil)
- Fixes an issue where the wrong transition was passed to after_transition callbacks for the second and subsequent transition of a given state machine (patch by @alan)
- Generators now handle namespaced classes (patch by @hrmrebecca)
Machine#transition_to
now only swallows Statesman generated errors. An exception in your guard or callback will no longer be caught by Statesman (patch by @paulspringett)
- Scope methods. Adds a module which can be mixed in to an ActiveRecord model to provide
.in_state
and.not_in_state
query scopes. - Adds
Machine#after_initialize
hook (patch by @att14)
- Adds after_commit flag to after_transition for callbacks to be executed after the transaction has been committed on the ActiveRecord adapter. These callbacks will still be executed on non transactional adapters.
- Adds Machine#allowed_transitions method (patch by @prikha)
- Don't add attr_accessible to generated transition model if running in Rails 4
- Adds Ruby 1.9.3 support (patch by @jakehow)
- All Mongo dependent tests are tagged so they can be excluded from test runs
- Specs now crash immediately if Mongo is not running
- Adds Mongoid adapter and generators (patch by @dluxemburg)
- Replaces
config#transition_class
withStatesman::Adapters::ActiveRecordTransition
mixin. (inspired by @cjbell88) - Renames the active record transition generator from
statesman:transition
tostatesman:active_record_transition
. - Moves to using
require_relative
internally where possible to avoid stomping on application load paths.
- Initial release