{"id":22025181,"url":"https://github.com/drexed/lite-archive","last_synced_at":"2026-04-20T10:02:50.518Z","repository":{"id":34994422,"uuid":"194705030","full_name":"drexed/lite-archive","owner":"drexed","description":"Archive (soft-delete) ActiveRecord database records","archived":false,"fork":false,"pushed_at":"2023-01-19T01:39:29.000Z","size":72,"stargazers_count":1,"open_issues_count":7,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-29T01:13:01.963Z","etag":null,"topics":["activerecord","archive","paranoid","rails","ruby","soft-delete"],"latest_commit_sha":null,"homepage":"https://drexed.github.io/lite-archive","language":"Ruby","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/drexed.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-07-01T16:07:38.000Z","updated_at":"2024-01-12T18:09:38.000Z","dependencies_parsed_at":"2023-02-10T19:31:29.234Z","dependency_job_id":null,"html_url":"https://github.com/drexed/lite-archive","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/drexed/lite-archive","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drexed%2Flite-archive","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drexed%2Flite-archive/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drexed%2Flite-archive/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drexed%2Flite-archive/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/drexed","download_url":"https://codeload.github.com/drexed/lite-archive/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drexed%2Flite-archive/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32042293,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-20T00:18:06.643Z","status":"online","status_checked_at":"2026-04-20T02:00:06.527Z","response_time":94,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["activerecord","archive","paranoid","rails","ruby","soft-delete"],"created_at":"2024-11-30T07:14:51.926Z","updated_at":"2026-04-20T10:02:50.500Z","avatar_url":"https://github.com/drexed.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Lite::Archive\n\n[![Gem Version](https://badge.fury.io/rb/lite-archive.svg)](http://badge.fury.io/rb/lite-archive)\n[![Build Status](https://travis-ci.org/drexed/lite-archive.svg?branch=master)](https://travis-ci.org/drexed/lite-archive)\n\nLite::Archive is a library for archiving (soft-delete) database records.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'lite-archive'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install lite-archive\n\n## Table of Contents\n\n* [Configurations](#configurations)\n* [Usage](#usage)\n* [Methods](#methods)\n* [Scopes](#scopes)\n* [Callbacks](#callbacks)\n\n## Configurations\n\n`rails g lite:archive:install` will generate the following file in your application root:\n`config/initalizers/lite_archive.rb`\n\n```ruby\nLite::Archive.configure do |config|\n  config.all_records_archivable = false\n  config.sync_updated_at = true\nend\n```\n\n## Usage\n\nAn `archived_at` column must be added to tables where you that you want to archive.\nIf the table does not have this column, records will be destroyed instead.\n\n#### Table create\n```ruby\nclass AddArchivedAtColumn \u003c ActiveRecord::Migration\n  def change\n    create_table :table_name do |t|\n      t.timestamp                # Adds archived_at automatically if all_records_archivable\n      t.timestamp archive: true  # Adds archived_at timestamp\n      t.timestamp archive: false # Does NOT add archived_at timestamp\n    end\n  end\nend\n```\n\n#### Column migration\n```ruby\nclass AddArchivedAtColumn \u003c ActiveRecord::Migration\n  def change\n    add_column :table_name, :archived_at, :datetime # Manual column (null constraint must be false)\n    add_timestamp :table_name                       # Named column helper (equivalent to the above)\n  end\nend\n```\n\n## Methods\n\n#### Instance\n```ruby\nuser = User.first\nuser.archive     #=\u003e Archives the User record and its dependents\nuser.unarchive   #=\u003e Unarchives the User record and its dependents\nuser.to_archival #=\u003e Returns the User archival state locale string (ex: Archived)\n```\n\n#### Class\n```ruby\nUser.archive_all   #=\u003e Archives all User records and their dependents\nUser.unarchive_all #=\u003e Unarchives all User record and their dependents\n```\n\n## Scopes\n\n```ruby\nUser.archived.all   #=\u003e Returns only archived records\nUser.unarchived.all #=\u003e Returns only unarchived records\n```\n\n## Callbacks\n\n#### Before\n ```ruby\n class User \u003c ActiveRecord::Base\n   before_archive :do_something\n   before_unarchived :do_something\n end\n```\n\n#### After\n ```ruby\n class User \u003c ActiveRecord::Base\n   after_archive :do_something\n   after_unarchive :do_something\n end\n```\n\n## Development\n\nAfter 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.\n\nTo 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 tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/drexed/lite-archive. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n## Code of Conduct\n\nEveryone interacting in the Lite::Archive project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/drexed/lite-archive/blob/master/CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrexed%2Flite-archive","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdrexed%2Flite-archive","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrexed%2Flite-archive/lists"}