Project

styxable

0.0
The project is in a healthy, maintained state
Styxable turns deletion into a three-stage lifecycle for ActiveRecord models: active, archived, purged. Calling styx_archive soft-deletes a record — it (optionally) vanishes from default scopes like being in a trash can or recycle bin, but the row survives, so foreign keys, joins, reports and audits keep working. Archived records can still be listed, counted and restored during a configurable grace or retention period, giving you an undo window or restore window instead of an irreversible destroy. While a record sits in the archive it is immutable: writes are rejected, so nothing can be silently edited between archiving and erasure — like in a vault. styx_unarchive brings a record back, unless it cannot, for example when a newer record has claimed a unique attribute in the meantime. Archiving cascades along dependent: associations, so closing an account, deactivating a user or tearing down a tenant can archive everything it owns in a single call, with callbacks around each step. Each model declares its own data retention period. A recurring background job then permanently destroys records whose retention window has expired, expressing your retention schedule, records disposition and automatic purge in code rather than in a runbook — useful for GDPR storage limitation and right to erasure ("right to be forgotten") obligations, or any policy with a TTL or expiry date. A before-purge callback lets you detach ActiveStorage blobs, delete remote files or notify external systems before a record crosses the Styx for good.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

>= 2.2
>= 1.15
>= 13.2
~> 3.13
~> 1.75

Runtime

>= 2.6
 Project Readme

Styxable

Archivable ActiveRecords / immutable soft-delete, with (GDPR) data retention and permanent purging.

THIS IS STILL WORK IN PROGRESS OR NOT FUNCTIONAL YET!

Styxable turns deletion into a three-stage lifecycle for ActiveRecord models: active, archived, purged. Calling styx_archive soft-deletes a record — it (optionally) vanishes from default scopes like being in a trash can or recycle bin, but the row survives, so foreign keys, joins, reports and audits keep working. Archived records can still be listed, counted and restored during a configurable grace or retention period, giving you an undo window or restore window instead of an irreversible destroy.

While a record sits in the archive it is immutable: writes are rejected, so nothing can be silently edited between archiving and erasure — like in a vault. styx_unarchive brings a record back, unless it cannot, for example when a newer record has claimed a unique attribute in the meantime. Archiving cascades along dependent: associations, so closing an account, deactivating a user or tearing down a tenant can archive everything it owns in a single call, with callbacks around each step.

Each model declares its own data retention period. A recurring background job then permanently destroys records whose retention window has expired, expressing your retention schedule, records disposition and automatic purge in code rather than in a runbook — useful for GDPR storage limitation and right to erasure ("right to be forgotten") obligations, or any policy with a TTL or expiry date. A before-purge callback lets you detach ActiveStorage blobs, delete remote files or notify external systems before a record crosses the Styx for good.

Installation

Install the gem and add to the application's Gemfile by executing:

bundle add styxable

If bundler is not being used to manage dependencies, install the gem by executing:

gem install styxable

Usage

TODO: Write usage instructions here

Who or what is 'Styx'? Why 'Styxable'?

In greek mythology Styx is the river dividing the world of the living from the realm of the dead — and also a goddess, a daughter of Oceanus and Tethys. For being the first to side with Zeus in the war against the Titans, he made her waters the oath by which the gods themselves must swear, and an oath sworn on the Styx cannot be broken.

Four things about that story map onto what this gem does.

In the myth In Styxable
The Styx is a boundary, not an ending. Souls cross out of the living world; they do not stop existing styx_archive moves a record out of your default scopes and out of the working set. The row survives, so foreign keys, joins, reports and audits still resolve
An oath sworn on the Styx is unbreakable Archived records are immutable. Writes are rejected for as long as the record stays archived
The return is possible, but conditional. Orpheus crossed and was granted Eurydice back — on a condition he failed to keep, and lost her a second time styx_unarchive can bring a record back, unless the world moved on and a newer record has claimed a unique attribute in the meantime
The unburied wait on the shore before the final crossing The retention period. An archived record waits out its window, is then permanently destroyed, and nothing remembers it afterwards
Thetis dipped the infant Achilles into the Styx to make him invulnerable, holding him by the heel — the one spot the water never touched. (Which sounds awefully familiar to the Germanic hero Siegfried of the Nibelungenlied.) Styxable has a heel too. Immutability is enforced through ActiveRecord validations, so anything that bypasses validations bypasses the vault: update_column, update_all, delete_all and raw SQL will all happily change or destroy an archived record. The guard protects you from ordinary application code, not from deliberate circumvention.

And the obvious reason: the name archivable was already taken in all its mutations, so I needed an alternative / prefix.

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.

Maintainers and Contributors

Issues

Bug reports and pull requests are welcome on GitHub at https://github.com/mediafinger/styxable. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

Installation

After checking out the repo, run bin/setup and then bundle execute rake ci to run the tests and rubocop.

You can also run bin/console to open an irb session with the Styxable pre-loaded that will allow you to experiment.

To build and install this gem onto your local machine, run bundle exec rake install.

Maintainers only:

To release a new version, bump the version number in version.rb, commit this change, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the Styxable project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.