Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pulling in gem this is forked from for latest changes #5

Open
wants to merge 122 commits into
base: core
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
122 commits
Select commit Hold shift + click to select a range
1753594
Use gem version of jdbcsqlite3-adapter
jhawthorn Nov 1, 2017
bb55ee9
Avoid raise_in_transactional_callbacks warning
jhawthorn Nov 1, 2017
7ccd9d4
Use rails 5.1 in Gemfile by default
jhawthorn Nov 2, 2017
c98ad45
Use define_model_callbacks
jhawthorn Nov 1, 2017
f6448c4
Add paranoia_{delete,destroy} aliases
jhawthorn Nov 1, 2017
87f8a0c
Use paranoia_ aliases internally
jhawthorn Nov 2, 2017
0f25822
Add paranoia_destroy!
jhawthorn Nov 2, 2017
97623f1
Fixes `really_destroy!` behavior with `sentinel_value`
steverice Jul 13, 2017
3092f36
Merge pull request #425 from jhawthorn/steverice-326-really-destroy-w…
jhawthorn Nov 2, 2017
c332f2a
Merge branch 'core' into versions_updates
jhawthorn Nov 2, 2017
acd43c1
Merge pull request #424 from jhawthorn/versions_updates
jhawthorn Nov 2, 2017
c63e0ab
Merge branch 'core' into paranoia_aliases
jhawthorn Nov 2, 2017
7c0d4ac
Merge pull request #423 from jhawthorn/paranoia_aliases
jhawthorn Nov 3, 2017
8e0abf5
Version 2.4.0
jhawthorn Nov 3, 2017
9250578
Merge pull request #427 from jhawthorn/version_2_4_0
jhawthorn Nov 3, 2017
76567a9
Test with Rails 5.2
mrhead Nov 29, 2017
021551f
Merge pull request #431 from mrhead/add-support-for-rails-5-2
jhawthorn Jan 5, 2018
d721f52
Add a very soft deprecation notice
jhawthorn Jan 5, 2018
d446da4
Merge pull request #433 from jhawthorn/notice
jhawthorn Jan 5, 2018
1d7d367
Test on new Ruby versions
nicolasleger Jan 9, 2018
64462b0
Fix Travis build on Ruby update
nicolasleger Jan 9, 2018
a328640
Merge pull request #434 from nicolasleger/test_new_ruby_versions
BenMorganIO Jan 9, 2018
65649aa
Monkeypatch activerecord relations to work with rails >=5.2.0rc2
bbonislawski Mar 21, 2018
82ba504
Merge pull request #435 from spark-solutions/fix-for-rails-5-2-rc2
BenMorganIO Mar 28, 2018
3c23c7e
Bump activerecord dependency
jhawthorn Mar 28, 2018
1e097eb
Rename active_record_patches to active_record_5_2
jhawthorn Mar 29, 2018
42cb1df
Only require monkey patches on active_record 5.2
jhawthorn Mar 29, 2018
c33f3a6
Use paranoia_destroyed? instead of deleted?
jhawthorn Mar 29, 2018
9a26d81
Merge pull request #436 from jhawthorn/rails_5_2_patches
jhawthorn Apr 4, 2018
23ec63e
Specify Rails 5.2.0 proper
jhawthorn Apr 9, 2018
35e6716
Version 2.4.1
jhawthorn Apr 10, 2018
a535372
Merge pull request #439 from jhawthorn/version_2_4_1
jhawthorn Apr 10, 2018
e9e2b5f
Fix typo (`6.2.0` -> `5.2.0`)
siman-man Apr 11, 2018
1434cc6
Merge pull request #440 from siman-man/fix-typo
jhawthorn Apr 11, 2018
531a229
Add Ruby 2.6 to Travis CI.
junaruga Feb 15, 2019
ccf85e5
Merge pull request #465 from junaruga/feature/ci
sevenseacat Mar 7, 2019
b9583d2
Remove upper dependency for activerecord
iggant Oct 17, 2018
7ed561c
Remove back upper limit
iggant Feb 13, 2019
e098680
Update .travis.yml
iggant Feb 13, 2019
b443fd9
Allow specifying sqlite version
jarednorman Apr 22, 2019
64f6c2d
Specify compatible sqlite versions for older rails
jarednorman Apr 22, 2019
37c7aa8
Correct excluded Ruby versions
jarednorman Apr 22, 2019
26383fc
fixup! Specify compatible sqlite versions for older rails
jarednorman Apr 22, 2019
c9b1c8a
Run tests against latest Ruby 2.6
jarednorman Apr 22, 2019
91355e8
Merge pull request #470 from jarednorman/activerecord-6-support
jhawthorn Apr 22, 2019
0600183
Version 2.4.2
jhawthorn Apr 26, 2019
a4da86d
Fix after commit for rails 6
hashwin Nov 28, 2019
5b6be56
trigger_transactional_callbacks if paranoia destroyed
hashwin Nov 28, 2019
555ce03
Update JRuby version to 9.2.8.0 + avoid gem update
donv Dec 2, 2019
d493469
Reinstate gem update and remove EOL Ruby 2.2
donv Dec 2, 2019
594ec41
Removed extra whitespace
donv Dec 2, 2019
41f52c3
Avoid bundler 2 while testing Rails 4.2
donv Dec 2, 2019
d52c66e
Only update bundler if necessary
donv Dec 2, 2019
fd82642
Revert check for bundler >=2
donv Dec 3, 2019
c370a18
Uninstall global bundler
donv Dec 3, 2019
950a83f
Accept uninstall of executables
donv Dec 3, 2019
ed86d01
Merge pull request #482 from hashwin/hashwin/after_commit
sevenseacat Jun 29, 2020
e03846f
Merge branch 'core' into patch-1
sevenseacat Jun 29, 2020
00a7057
Merge pull request #483 from donv/patch-1
sevenseacat Jun 29, 2020
30f82f1
Bump activerecord dependency
joergschiller Dec 11, 2020
f504fc9
Avoid deprecated method to add error
joergschiller Dec 11, 2020
15a09a8
Merge pull request #503 from zinsbaustein/rails6.1
sevenseacat Dec 14, 2020
03d0779
Update version number
sevenseacat Dec 16, 2020
7c78f1f
Add changelog for v2.4.3
tricknotes Dec 17, 2020
07a64b5
Update supported Rails version in paranoia.gemspec
tricknotes Dec 17, 2020
858096b
Merge pull request #505 from tricknotes/add-changelog-for-2.4.3
sevenseacat Dec 17, 2020
552bc7d
Merge branch 'core' into update-description-in-gemspec
sevenseacat Dec 17, 2020
032a2ad
Merge pull request #506 from tricknotes/update-description-in-gemspec
sevenseacat Dec 17, 2020
5bb1365
allow rails 7.0
mathieujobin Oct 18, 2021
16aa715
ruby 2.5 is minimum, switch to github actions
mathieujobin Nov 4, 2021
dde2b26
env matrix does not set env vars
mathieujobin Nov 4, 2021
75f167f
limit rails/rubies combinaison
mathieujobin Nov 4, 2021
c6591f6
adapt latest version of jruby available on 20.04
mathieujobin Nov 4, 2021
063d7be
clear_association_cache is gone from rails 7
mathieujobin Nov 4, 2021
d06e01b
rails 4.2 and 5.0 is legacy
mathieujobin Nov 4, 2021
01d973d
Check AR version
mathieujobin Nov 4, 2021
161b459
no jruby
mathieujobin Nov 4, 2021
77dfd52
Add rubygems badge
mathieujobin Nov 10, 2021
3589589
7.0.0 released
mathieujobin Dec 18, 2021
346bb16
Add Rails ~> 6.0.0 to build.yml
radar Dec 18, 2021
6cf3b01
Merge pull request #519 from rubysherpas/rails7
radar Dec 18, 2021
bde51dd
Merge branch 'core' into patch-1
radar Dec 18, 2021
d9b81c6
Merge pull request #517 from mathieujobin/patch-1
radar Dec 18, 2021
a61c512
Bump to 2.5.0
radar Dec 18, 2021
06af260
Add 2.5.0 updates to CHANGELOG (#521)
magni- Jan 12, 2022
47997ee
Show CI status badge (#524)
mishina2228 Jan 12, 2022
3b5a1a0
CI against Ruby 3.0 and 3.1 (#523)
mishina2228 Jan 12, 2022
b6b5167
gets deletion time from paranoia_column (#481)
sas1ni69 Jan 19, 2022
c0758a8
Warn if acts_as_paranoid is called more than once on the same model (…
ignatiusreza Feb 2, 2022
3572129
Do not include tests files in packaged gem (#526)
jasonfb Feb 2, 2022
742951c
release v2.5.2 - bump version, update changelog
mathieujobin Feb 2, 2022
fb494c8
Define rspec matcher only when rspec is defined (#529)
swelther Feb 28, 2022
e7c5a34
added a test case to cover the bug (#531)
sherif-nedap Mar 23, 2022
e1dd15d
separates deletion_time from paranoia_column_value (#532)
sas1ni69 Mar 23, 2022
57a978d
release v2.5.3 - bump version, update changelog
mathieujobin Mar 23, 2022
cd60ab2
Fix create callback called on destroy (#513)
bkDJ Mar 23, 2022
2af6700
Add failing tests for association with abort on destroy (#522)
tricknotes Mar 23, 2022
f8cffd8
rollback transaction if destroy aborted (#485)
Able1991 Mar 23, 2022
ef1225e
Fix syntax to restore a record (#476)
sachinjain007 Mar 23, 2022
cc19cef
[Mysql] small updated to quote table names. Mysql 8 has keywords that…
Mar 23, 2022
c0d1d9a
release v2.6.0 - bump version, update changelog
mathieujobin Mar 23, 2022
09e3a9f
skip updating paranoia_destroy_attributes for records while really_de…
kortirso Nov 15, 2022
cb04a4d
Use correct time class for earlier Rails versions (#541)
emilong Jun 5, 2023
894269f
Recursive restore with has_many/one through assocs (#441)
emilong Jun 5, 2023
33e433a
Release 2.6.2 + Redo Github Actions matrix using includes (#537)
mathieujobin Jun 5, 2023
c038be3
fix Minitest case
mathieujobin Aug 24, 2023
3bdb553
Update supported Rails version in paranoia.gemspec (#547)
ken3ypa Sep 1, 2023
4db17c2
Use paranoia_destroyed\? instead of deleted\? (#545)
mlarraz Sep 1, 2023
1db8402
Minor optimization, removing unneeded variables (#546)
ken3ypa Sep 1, 2023
72a03f1
Rails 7.1 Release 🚀 (#548)
indyarocks Oct 11, 2023
a0b7632
Bump actions/checkout from v2 to v4 (#550)
mishina2228 Oct 17, 2023
de74493
Support prebuilt counter cache association list (#554)
JoeDupuis Mar 12, 2024
f68cb23
fix: restore has_one with scope (#551)
zygzagZ Mar 12, 2024
0f8a3bd
📝 Add Yard documentation for Paranoia::Query (#555)
cprodhomme Mar 21, 2024
c3b432e
Release v2.6.4: bump version and update Changelog
mathieujobin Jul 20, 2024
9790ee1
Add support for Rails 7.2 (#563)
andrewhampton Aug 13, 2024
4d7b87d
See what happens on Rails edge (#564)
radar Aug 13, 2024
3faf7d3
Document support for Rails edge + 7.2
radar Aug 13, 2024
f441c37
Bump to 3.0.0
radar Aug 13, 2024
ba6dde7
Handle #delete_all (#566)
mohammednasser-32 Oct 2, 2024
7b96793
feat: Trigger an after_commit callback when restoring a record (#559)
yoheimuta Oct 2, 2024
d15a01e
fix typo in newly added readme (#567)
mohammednasser-32 Dec 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby

name: build

on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
rails: ["~> 7.2.0", "~> 7.1.0", "~> 7.0.0", "~> 6.1.0"]
ruby: ["3.3","3.2", "3.1", "3.0", "2.7"]
exclude:
- rails: "~> 7.2.0"
ruby: "3.0"
- rails: "~> 7.2.0"
ruby: "2.7"
- rails: "edge"
ruby: "3.0"
- rails: "edge"
ruby: "2.7"



env:
RAILS: ${{ matrix.rails }}
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- run: bundle exec rake
23 changes: 0 additions & 23 deletions .travis.yml

This file was deleted.

113 changes: 113 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,118 @@
# paranoia Changelog

## 3.0.0 - August 13, 2024

_Tagged as 3.0 as Ruby + Rails version constraints have been modernised._

- [#564](https://github.com/rubysherpas/paranoia/pull/564) Support Rails edge
- [#563](https://github.com/rubysherpas/paranoia/pull/563) Support Rails 7.2

## 2.6.4 - July 20, 2024

* [#554](https://github.com/rubysherpas/paranoia/pull/554) Support prebuilt counter cache association list (#554)
[Joé Dupuis](https://github.com/JoeDupuis)
* [#551](https://github.com/rubysherpas/paranoia/pull/551) Fix: restore has_one with scope (#551)
[Paweł Charyło](https://github.com/zygzagZ)
* [#555](https://github.com/rubysherpas/paranoia/pull/555) 📝 Add Yard documentation for Paranoia::Query (#555)
[Clément Prod'homme](https://github.com/cprodhomme)

## 2.6.3 - Oct 12, 2023

* [#548](https://github.com/rubysherpas/paranoia/pull/548) Add support for [Rails 7.1](https://github.com/rails/rails/releases/tag/v7.1.0) (#548)
[Indyarocks](https://github.com/indyarocks)

## 2.6.2 - Jun 6, 2023

* [#441](https://github.com/rubysherpas/paranoia/pull/441) Recursive restore with has_many/one through assocs (#441)
[Emil Ong](https://github.com/emilong)

## 2.6.1 - Nov 16, 2022

* [#535](https://github.com/rubysherpas/paranoia/pull/535) Allow to skip updating paranoia_destroy_attributes for records while really_destroy!
[Anton Bogdanov](https://github.com/kortirso)

## 2.6.0 - Mar 23, 2022

* [#512](https://github.com/rubysherpas/paranoia/pull/512) Quote table names; Mysql 8 has keywords that might match table names which cause an exception.
* [#476](https://github.com/rubysherpas/paranoia/pull/476) Fix syntax error in documentation.
* [#485](https://github.com/rubysherpas/paranoia/pull/485) Rollback transaction if destroy aborted.
* [#522](https://github.com/rubysherpas/paranoia/pull/522) Add failing tests for association with abort on destroy.
* [#513](https://github.com/rubysherpas/paranoia/pull/513) Fix create callback called on destroy.

## 2.5.3

* [#532](https://github.com/rubysherpas/paranoia/pull/532) Fix: correct bug when sentinel_value is not a timestamp
[Hassanin Ahmed](https://github.com/sas1ni69)
* [#531](https://github.com/rubysherpas/paranoia/pull/531) Added test case to reproduce bug introduce in v2.5.1
[Sherif Elkassaby](https://github.com/sherif-nedap)
* [#529](https://github.com/rubysherpas/paranoia/pull/529) Fix: Do not define a RSpec matcher when RSpec isn't present
[Sebastian Welther](https://github.com/swelther)

## 2.5.2

* [#526](https://github.com/rubysherpas/paranoia/pull/526) Do not include tests files in packaged gem

[Jason Fleetwood-Boldt](https://github.com/jasonfb)
* [#492](https://github.com/rubysherpas/paranoia/pull/492) Warn if acts_as_paranoid is called more than once on the same model

[Ignatius Reza](https://github.com/ignatiusreza)

## 2.5.1

* [#481](https://github.com/rubysherpas/paranoia/pull/481) Replaces hard coded `deleted_at` with `paranoia_column`.

[Hassanin Ahmed](https://github.com/sas1ni69)

## 2.5.0

* [#516](https://github.com/rubysherpas/paranoia/pull/516) Add support for ActiveRecord 7.0, drop support for EOL Ruby < 2.5 and Rails < 5.1
adding support for Rails 7

[Mathieu Jobin](https://github.com/mathieujobin)
* [#515](https://github.com/rubysherpas/paranoia/pull/515) Switch from Travis CI to GitHub Actions

[Shinichi Maeshima](https://github.com/willnet)

## 2.4.3

* [#503](https://github.com/rubysherpas/paranoia/pull/503) Bump activerecord dependency for Rails 6.1

[Jörg Schiller](https://github.com/joergschiller)

* [#483](https://github.com/rubysherpas/paranoia/pull/483) Update JRuby version to 9.2.8.0 + remove EOL Ruby 2.2

[Uwe Kubosch](https://github.com/donv)

* [#482](https://github.com/rubysherpas/paranoia/pull/482) Fix after_commit for Rails 6

[Ashwin Hegde](https://github.com/hashwin)

## 2.4.2

* [#470](https://github.com/rubysherpas/paranoia/pull/470) Add support for ActiveRecord 6.0

[Anton Kolodii](https://github.com/iggant), [Jared Norman](https://github.com/jarednorman)

## 2.4.1

* [#435](https://github.com/rubysherpas/paranoia/pull/435) Monkeypatch activerecord relations to work with rails 5.2.0

[Bartosz Bonisławski (@bbonislawski)](https://github.com/bbonislawski)

## 2.4.0

* [#423](https://github.com/rubysherpas/paranoia/pull/423) Add `paranoia_destroy` and `paranoia_delete` aliases

[John Hawthorn (@jhawthorn)](https://github.com/jhawthorn)

* [#408](https://github.com/rubysherpas/paranoia/pull/408) Fix instance variable `@_disable_counter_cache` not initialized warning.

[Akira Matsuda (@amatsuda)](https://github.com/amatsuda)

* [#412](https://github.com/rubysherpas/paranoia/pull/412) Fix `really_destroy!` behavior with `sentinel_value`

[Steve Rice (@steverice)](https://github.com/steverice)

## 2.3.1

* [#397](https://github.com/rubysherpas/paranoia/pull/397) Bump active record max version to support 5.1 final
Expand Down
28 changes: 20 additions & 8 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,32 @@
source 'https://rubygems.org'

gem 'sqlite3', platforms: [:ruby]
sqlite = ENV['SQLITE_VERSION']

if sqlite
gem 'sqlite3', sqlite, platforms: [:ruby]
else
gem 'sqlite3', '~> 1.4', platforms: [:ruby]
end

platforms :jruby do
gem 'activerecord-jdbcsqlite3-adapter', github: 'jruby/activerecord-jdbc-adapter', branch: 'rails-5'
gem 'activerecord-jdbcsqlite3-adapter'
end

platforms :rbx do
gem 'rubysl', '~> 2.0'
gem 'rubysl-test-unit'
gem 'rubinius-developer_tools'
if RUBY_ENGINE == 'rbx'
platforms :rbx do
gem 'rubinius-developer_tools'
gem 'rubysl', '~> 2.0'
gem 'rubysl-test-unit'
end
end

rails = ENV['RAILS'] || '~> 4.2.0'
rails = ENV['RAILS'] || '~> 6.0.4'

gem 'rails', rails
if rails == 'edge'
gem 'rails', github: 'rails/rails'
else
gem 'rails', rails
end

# Specify your gem's dependencies in paranoia.gemspec
gemspec
47 changes: 46 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
[![Gem Version](https://badge.fury.io/rb/paranoia.svg)](https://badge.fury.io/rb/paranoia)
[![build](https://github.com/rubysherpas/paranoia/actions/workflows/build.yml/badge.svg)](https://github.com/rubysherpas/paranoia/actions/workflows/build.yml)

**Notice:**

`paranoia` has some surprising behaviour (like overriding ActiveRecord's `delete` and `destroy`) and is not recommended for new projects. See [`discard`'s README](https://github.com/jhawthorn/discard#why-not-paranoia-or-acts_as_paranoid) for more details.

Paranoia will continue to accept bug fixes and support new versions of Rails but isn't accepting new features.

# Paranoia

Paranoia is a re-implementation of [acts\_as\_paranoid](http://github.com/ActsAsParanoid/acts_as_paranoid) for Rails 3/4/5, using much, much, much less code.
Expand Down Expand Up @@ -94,6 +103,14 @@ If you really want it gone *gone*, call `really_destroy!`:
# => client
```

If you need skip updating timestamps for deleting records, call `really_destroy!(update_destroy_attributes: false)`.
When we call `really_destroy!(update_destroy_attributes: false)` on the parent `client`, then each child `email` will also have `really_destroy!(update_destroy_attributes: false)` called.

``` ruby
>> client.really_destroy!(update_destroy_attributes: false)
# => client
```

If you want to use a column other than `deleted_at`, you can pass it as an option:

``` ruby
Expand Down Expand Up @@ -184,11 +201,24 @@ client.restore(:recursive => true)
If you want to restore a record and only those dependently destroyed associated records that were deleted within 2 minutes of the object upon which they depend:

``` ruby
Client.restore(id, :recursive => true. :recovery_window => 2.minutes)
Client.restore(id, :recursive => true, :recovery_window => 2.minutes)
# or
client.restore(:recursive => true, :recovery_window => 2.minutes)
```

If you want to trigger an after_commit callback when restoring a record:

``` ruby
class Client < ActiveRecord::Base
acts_as_paranoid after_restore_commit: true

after_commit :commit_called, on: :restore
# or
after_restore_commit :commit_called
...
end
```

Note that by default paranoia will not prevent that a soft destroyed object can't be associated with another object of a different model.
A Rails validator is provided should you require this functionality:
``` ruby
Expand Down Expand Up @@ -331,6 +361,21 @@ end
# => NoMethodError: undefined method `with_deleted' for #<Class:0x0123456>
```

#### delete_all:

The gem supports `delete_all` method, however it is disabled by default, to enable it add this in your `environment` file

``` ruby
Paranoia.delete_all_enabled = true
```
alternatively, you can enable/disable it for specific models as follow:

``` ruby
class User < ActiveRecord::Base
acts_as_paranoid(delete_all_enabled: true)
end
```

## Acts As Paranoid Migration

You can replace the older `acts_as_paranoid` methods as follows:
Expand Down
Loading