module ActiveRecordArchive
Public Instance Methods
archive(conditions, options = {})
click to toggle source
Archive database records
Caveats: where foreign keys are involved, child records must be archived first
Examples:
>> Model.archive('created_at < DATE_SUB(NOW(), INTERVAL 6 MONTH)') >> Model.archive('created_at < DATE_SUB(NOW(), INTERVAL 6 MONTH)', prefix: 'arch_')
Arguments:
conditions: (String) options: prefix: (String) - default "ar_archive_"
# File lib/activerecord_archive.rb, line 95 def archive(conditions, options = {}) do_archive(conditions, options) end
restore(conditions, options = {})
click to toggle source
Restore database records
Caveats: if you used a custom prefix to archive, make sure you use the same prefix to restore
Examples:
>> Model.archive('created_at < DATE_SUB(NOW(), INTERVAL 6 MONTH)') >> Model.archive('created_at < DATE_SUB(NOW(), INTERVAL 6 MONTH)', prefix: 'arch_')
Arguments:
conditions: (String) options: prefix: (String) - default "ar_archive_"
# File lib/activerecord_archive.rb, line 111 def restore(conditions, options = {}) do_restore(conditions, options) end