diff options
| author | Seb Bacon <seb.bacon@gmail.com> | 2011-07-22 15:55:48 +0100 |
|---|---|---|
| committer | Seb Bacon <seb.bacon@gmail.com> | 2011-07-22 15:55:48 +0100 |
| commit | 11a73eef1d83cfa3bc3c145de483fa81c25d6216 (patch) | |
| tree | f8d6da387cdf48e1283bfac20c316358ff571708 /db | |
| parent | 51f9ab2ac1b779e31aa54ebf9485a1a72eb7cee0 (diff) | |
Store raw_emails in the filesystem, not in the database. They don't need to be in the database (we never write to them, for example), and they bloat it unecessarily, making backups etc difficult.
NOTE: this migration could take a *very* long time.
Diffstat (limited to 'db')
| -rw-r--r-- | db/migrate/099_move_raw_email_to_filesystem.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/db/migrate/099_move_raw_email_to_filesystem.rb b/db/migrate/099_move_raw_email_to_filesystem.rb new file mode 100644 index 000000000..991ef55d7 --- /dev/null +++ b/db/migrate/099_move_raw_email_to_filesystem.rb @@ -0,0 +1,23 @@ +class MoveRawEmailToFilesystem < ActiveRecord::Migration + def self.up + batch_size = 10 + 0.step(RawEmail.count, batch_size) do |i| + RawEmail.find(:all, :limit => batch_size, :offset => i, :order => :id).each do |raw_email| + if !File.exists?(raw_email.filepath) + STDERR.puts "converting raw_email " + raw_email.id.to_s + raw_email.data = raw_email.dbdata + raw_email.dbdata = nil + raw_email.save! + end + end + end + end + + def self.down + #raise "safer not to have reverse migration scripts, and we never use them" + end +end + + + + |
