hoard records
before performing 1.2
and 1.3
the ActiverecordHoarder::Storage
needs to be configured with
storage: :aws_s3
- only storage currently implementedstorage_options: {...}
with s3 credentials, connection details and default permissions
access_key_id
required - amazon credentialacl
required - amazon canned ACL (private, public-read, ...)*bucket
required - amazon connection detailbucket_sub_dir
optional - amazon key prefixregion
required - amazon connection detailsecret_access_key
required - amazon credential
class ExampleModel < ActiveRecord::Base
acts_as_hoarder
end
from console:
ExampleModel.hoard(options)
will create S3 entries with keys: <bucket_sub_dir>/<table_name = example_models>/<year>/<month>/<year>-<month>-<day>.json
and json formatted content
To only archive a single batch of records do:
ExampleModel.hoard_single(options)
Options can be added to the options hash:
- start_at_date
- max_count
from console:
ExampleModel.restore_archive_records(Date.new(<Y>,<m>,<d>))
Make a clone. Make a branch. Install dependencies.
Create config file from template (cp config/dbspec.yml.template config/dbspec.yml
). Change database from postgresql
to sqlite3
and database name from activerecord_hoarder
to <as_desired>.sqlite3
.
Create config file from template (cp config/activerecord_hoarder.yml.template config/activerecord_hoarder.yml
). Add your S3 credentials access_key_id
and secret_access_key
for target bucket bucket
. Change region
if necessary. If you want, change acl
and add bucket_sub_dir
.
bundler exec bin/console
Convenience functionality
require_relative "example/schema"
for creating an example tableexamples
require_relative "example/example"
for an example archivable modelExample
require_relative "example/fixture"
for a factory methodcreate_examples(count, start: 0, deleted: true)
for creating examples
Create config file from template (cp config/dbspec_rspec.yml.template config/dbspec_rspec.yml
). Modify settings if you want.
bundler exec rspec spec