Module: ActsAsArchivable::Schema

Defined in:
lib/acts_as_archivable/schema.rb

Instance Method Summary collapse

Instance Method Details

#archived_table_schemaObject



11
12
13
14
15
# File 'lib/acts_as_archivable/schema.rb', line 11

def archived_table_schema
  table_schema
    .gsub(/#{table_name}/, archived_table_name)
    .gsub(/(create_table|add_index)/, 'ActiveRecord::Migration.\1')
end

#table_schemaObject



3
4
5
6
7
8
9
# File 'lib/acts_as_archivable/schema.rb', line 3

def table_schema
  schema = ActiveRecord::SchemaDumper
           .send(:new, ActiveRecord::Base.connection)
           .send(:table, table_name, Tempfile.new('temporary_schema'))
  schema.rewind
  schema.read
end