]> git.openstreetmap.org Git - rails.git/blob - db/migrate/20120318201948_create_redactions.rb
Fixing review comments
[rails.git] / db / migrate / 20120318201948_create_redactions.rb
1 require 'migrate'
2
3 class CreateRedactions < ActiveRecord::Migration
4   def up
5     create_table :redactions do |t|
6       t.string :title
7       t.text :description
8
9       t.timestamps
10     end
11
12     [:nodes, :ways, :relations].each do |tbl|
13       add_column tbl, :redaction_id, :integer, :null => true
14       add_foreign_key tbl, [:redaction_id], :redactions, [:id]
15     end
16   end
17
18   def down
19     [:nodes, :ways, :relations].each do |tbl|
20       remove_foreign_key tbl, [:redaction_id], :redactions, [:id]
21       remove_column tbl, :redaction_id
22     end
23     
24     drop_table :redactions
25   end
26 end