2010-02-18 21:57:01 +00:00
|
|
|
|
|
|
|
# Adds 'created_at' and 'updated_at' columns to every primary table.
|
|
|
|
#
|
|
|
|
class AddTimestamps < ActiveRecord::Migration
|
|
|
|
|
2010-04-29 21:49:18 +00:00
|
|
|
@@TABLES_NEEDING_RENAME = [:clients, :hosts, :notes, :refs, :services, :vulns, :wmap_requests]
|
|
|
|
@@TABLES_NEEDING_CREATED_AT = [:wmap_targets]
|
|
|
|
@@TABLES_NEEDING_UPDATED_AT = [:clients, :events, :hosts, :notes, :refs, :services, :vulns, :wmap_requests, :wmap_targets]
|
2010-02-18 21:57:01 +00:00
|
|
|
|
|
|
|
def self.up
|
2010-04-29 21:49:18 +00:00
|
|
|
@@TABLES_NEEDING_RENAME.each { |t| rename_column t, :created, :created_at }
|
2010-02-18 21:57:01 +00:00
|
|
|
|
2010-04-29 21:49:18 +00:00
|
|
|
@@TABLES_NEEDING_CREATED_AT.each { |t| add_column t, :created_at, :datetime }
|
2010-02-18 21:57:01 +00:00
|
|
|
|
2010-04-29 21:49:18 +00:00
|
|
|
@@TABLES_NEEDING_UPDATED_AT.each { |t| add_column t, :updated_at, :datetime }
|
2010-02-18 21:57:01 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def self.down
|
2010-04-29 21:49:18 +00:00
|
|
|
@@TABLES_NEEDING_RENAME.each { |t| rename_column t, :created_at, :created }
|
2010-02-18 21:57:01 +00:00
|
|
|
|
2010-04-29 21:49:18 +00:00
|
|
|
@@TABLES_NEEDING_CREATED_AT.each { |t| remove_column t, :created_at }
|
2010-02-18 21:57:01 +00:00
|
|
|
|
2010-04-29 21:49:18 +00:00
|
|
|
@@TABLES_NEEDING_UPDATED_AT.each { |t| remove_column t, :updated_at }
|
2010-02-18 21:57:01 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|