24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/archivist/base/db.rb', line 24
def create_archive_table
if table_exists? && !archive_table_exists?
cols = self.columns.reject { |column| column.name == primary_key }
connection.create_table("archived_#{table_name}")
cols.each do |c|
connection.add_column("archived_#{table_name}",c.name,c.type)
end
connection.add_column("archived_#{table_name}",:deleted_at,:datetime)
if archive_options[:associate_with_original]
connection.add_column("archived_#{table_name}","#{self.new.class.to_s.underscore}_id",:integer)
end
end
end
|