Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 133 lines (85 sloc) 3.136 kB
00400aa @winton README
authored
1 ActsAsArchive
2 =============
cc6c0c1 @winton First commit: partially working, partially tested
authored
3
9778feb @winton Update README.md
authored
4 **This project is no longer maintained. If you would like to become the new owner, please email [Winton Welsh](mailto:mail@wintoni.us).**
5
00400aa @winton README
authored
6 Don't delete your records, move them to a different table.
90ffbf5 @winton README
authored
7
aab6c6b @winton Wrote specs for create_archive_indexes and migrate_from_acts_as_paran…
authored
8 Like <code>acts\_as\_paranoid</code>, but doesn't mess with your SQL queries.
cc6c0c1 @winton First commit: partially working, partially tested
authored
9
00400aa @winton README
authored
10 Install
11 -------
12
cc6c0c1 @winton First commit: partially working, partially tested
authored
13 <pre>
f16b286 @winton README, puts -> $stdout.puts
authored
14 gem install acts_as_archive
cc6c0c1 @winton First commit: partially working, partially tested
authored
15 </pre>
16
f16b286 @winton README, puts -> $stdout.puts
authored
17 ### Rails 2
18
19 #### config/environment.rb
9dc96bb @winton Fixing acts_as_archive binary (0.1.6)
authored
20
21 <pre>
22 config.gem 'acts_as_archive'
23 </pre>
24
f16b286 @winton README, puts -> $stdout.puts
authored
25 ### Rails 3
00400aa @winton README
authored
26
f16b286 @winton README, puts -> $stdout.puts
authored
27 #### Gemfile
cc6c0c1 @winton First commit: partially working, partially tested
authored
28
29 <pre>
f16b286 @winton README, puts -> $stdout.puts
authored
30 gem 'acts_as_archive'
cc6c0c1 @winton First commit: partially working, partially tested
authored
31 </pre>
32
f16b286 @winton README, puts -> $stdout.puts
authored
33 ### Sinatra
aab6c6b @winton Wrote specs for create_archive_indexes and migrate_from_acts_as_paran…
authored
34
f16b286 @winton README, puts -> $stdout.puts
authored
35 <pre>
36 require 'acts_as_archive'
7424077 @winton Version 0.1.2: New rakefile, using bin/acts_as_archive to generate ar…
authored
37
dd7b490 @winton Moving ActsAsArchive configuration to YAML file (config/acts_as_archi…
authored
38 class Application &lt; Sinatra::Base
39 include ActsAsArchive::Adapters::Sinatra
40 end
41 </pre>
f16b286 @winton README, puts -> $stdout.puts
authored
42
dd7b490 @winton Moving ActsAsArchive configuration to YAML file (config/acts_as_archi…
authored
43 config/acts\_as\_archive.yml
44 ----------------------------
81563fa @winton Adding migration instructions to README
authored
45
0ee8655 @winton README
authored
46 Create <code>config/acts\_as\_archive.yml</code> to define the archive class and archive table for each of your models:
47
7424077 @winton Version 0.1.2: New rakefile, using bin/acts_as_archive to generate ar…
authored
48 <pre>
dd7b490 @winton Moving ActsAsArchive configuration to YAML file (config/acts_as_archi…
authored
49 Article:
50 - class: Article::Archive
51 table: archived_articles
7424077 @winton Version 0.1.2: New rakefile, using bin/acts_as_archive to generate ar…
authored
52 </pre>
53
0ee8655 @winton README
authored
54 It is expected that neither the archive class or archive table exist yet. <code>ActsAsArchive</code> will create these automatically.
dd7b490 @winton Moving ActsAsArchive configuration to YAML file (config/acts_as_archi…
authored
55
f16b286 @winton README, puts -> $stdout.puts
authored
56 Migrate
57 -------
7424077 @winton Version 0.1.2: New rakefile, using bin/acts_as_archive to generate ar…
authored
58
dd7b490 @winton Moving ActsAsArchive configuration to YAML file (config/acts_as_archi…
authored
59 Run <code>rake db:migrate</code>. Your archive table is created automatically.
81563fa @winton Adding migration instructions to README
authored
60
00400aa @winton README
authored
61 That's it!
62 ----------
63
f16b286 @winton README, puts -> $stdout.puts
authored
64 Use <code>destroy</code>, <code>destroy\_all</code>, <code>delete</code>, and <code>delete_all</code> like you normally would.
aab6c6b @winton Wrote specs for create_archive_indexes and migrate_from_acts_as_paran…
authored
65
430f63e @winton README
authored
66 Records move into the archive table instead of being destroyed.
00400aa @winton README
authored
67
70908bd @winton README
authored
68 Automatically archive relationships
69 -----------------------------------
70
dd7b490 @winton Moving ActsAsArchive configuration to YAML file (config/acts_as_archi…
authored
71 If your model's relationship has the <code>:dependent</code> option, and the relationship also uses <code>acts\_as\_archive</code>, that relationship will archive automatically.
b0a72ff @winton README
authored
72
87591b7 @winton Version 0.1.1
authored
73 What if my schema changes?
74 --------------------------
00400aa @winton README
authored
75
59022de @winton README
authored
76 New migrations are automatically applied to the archive table.
87591b7 @winton Version 0.1.1
authored
77
81563fa @winton Adding migration instructions to README
authored
78 No action is necessary on your part.
79
87591b7 @winton Version 0.1.1
authored
80 Query the archive
81 -----------------
82
0ee8655 @winton README
authored
83 Use the archive class you specified in the configuration:
00400aa @winton README
authored
84
85 <pre>
f16b286 @winton README, puts -> $stdout.puts
authored
86 Article::Archive.first
00400aa @winton README
authored
87 </pre>
88
f16b286 @winton README, puts -> $stdout.puts
authored
89 Delete records without archiving
90 --------------------------------
00400aa @winton README
authored
91
f16b286 @winton README, puts -> $stdout.puts
authored
92 Use any of the destroy methods, but add a bang (!):
00400aa @winton README
authored
93
87591b7 @winton Version 0.1.1
authored
94 <pre>
728dae9 @winton README
authored
95 Article::Archive.first.destroy!
f29a2e9 @winton README
authored
96 Article.delete_all!([ "id in (?)", [ 1, 2, 3 ] ])
87591b7 @winton Version 0.1.1
authored
97 </pre>
00400aa @winton README
authored
98
f16b286 @winton README, puts -> $stdout.puts
authored
99 Restore from the archive
100 ------------------------
c2ab564 @winton README
authored
101
f16b286 @winton README, puts -> $stdout.puts
authored
102 Use any of the destroy/delete methods on the archived record to move it back to its original table:
430f63e @winton README
authored
103
104 <pre>
f16b286 @winton README, puts -> $stdout.puts
authored
105 Article::Archive.first.destroy
106 Article::Archive.delete_all([ "id in (?)", [ 1, 2, 3 ] ])
430f63e @winton README
authored
107 </pre>
108
077f09f @winton README
authored
109 Any relationships that were automatically archived will be restored as well.
110
f16b286 @winton README, puts -> $stdout.puts
authored
111 Magic columns
112 -------------
508fc5a @look add some docs for destroy! and delete_all!
look authored
113
f16b286 @winton README, puts -> $stdout.puts
authored
114 You will find an extra <code>deleted_at</code> datetime column on the archive table.
508fc5a @look add some docs for destroy! and delete_all!
look authored
115
f16b286 @winton README, puts -> $stdout.puts
authored
116 You may manually add a <code>restored_at</code> datetime column to the origin table if you wish to store restoration time as well.
508fc5a @look add some docs for destroy! and delete_all!
look authored
117
f16b286 @winton README, puts -> $stdout.puts
authored
118 Migrate from acts\_as\_paranoid
119 -------------------------------
508fc5a @look add some docs for destroy! and delete_all!
look authored
120
f16b286 @winton README, puts -> $stdout.puts
authored
121 Add this line to a migration, or run it via <code>script/console</code>:
508fc5a @look add some docs for destroy! and delete_all!
look authored
122
123 <pre>
f16b286 @winton README, puts -> $stdout.puts
authored
124 Article.migrate_from_acts_as_paranoid
125 </pre>
126
b0a72ff @winton README
authored
127 This copies all records with non-null <code>deleted_at</code> values to the archive.
128
129 Running specs
130 -------------
131
9778feb @winton Update README.md
authored
132 There is a [wiki entry](https://github.com/winton/acts_as_archive/wiki/Running-Specs) that describes the development setup in-depth.
Something went wrong with that request. Please try again.