diff options
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/062_add_comments.rb | 32 | ||||
-rw-r--r-- | db/schema.rb | 1 |
2 files changed, 33 insertions, 0 deletions
diff --git a/db/migrate/062_add_comments.rb b/db/migrate/062_add_comments.rb new file mode 100644 index 000000000..d523dd808 --- /dev/null +++ b/db/migrate/062_add_comments.rb @@ -0,0 +1,32 @@ +class AddComments < ActiveRecord::Migration + def self.up + create_table :comments do |t| + t.column :user_id, :integer, :null => false + t.column :comment_type, :string, :null => false, :default => "internal_error" + + t.column :info_request_id, :integer + + t.column :body, :text, :null => false + t.column :visible, :boolean, :default => true, :null => false + + t.column :created_at, :datetime, :null => false + t.column :updated_at, :datetime, :null => false + end + + if ActiveRecord::Base.connection.adapter_name == "PostgreSQL" + execute "ALTER TABLE comments ADD CONSTRAINT fk_comments_user FOREIGN KEY (user_id) REFERENCES users(id)" + + execute "ALTER TABLE comments ADD CONSTRAINT fk_comments_info_request FOREIGN KEY (info_request_id) REFERENCES info_requests(id)" + end + + add_column :info_request_events, :comment_id, :integer + if ActiveRecord::Base.connection.adapter_name == "PostgreSQL" + execute "ALTER TABLE info_request_events ADD CONSTRAINT fk_info_request_events_comment_id FOREIGN KEY (comment_id) REFERENCES comments(id)" + end + end + + def self.down + drop_table :comments + remove_column :info_request_events, :comment_id + end +end diff --git a/db/schema.rb b/db/schema.rb index b53ac9e8e..3511724da 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -48,6 +48,7 @@ ActiveRecord::Schema.define(:version => 62) do t.datetime "last_described_at" t.integer "incoming_message_id" t.integer "outgoing_message_id" + t.integer "comment_id" end create_table "info_requests", :force => true do |t| |