Updated

db/migrate / 20150701145202_migrate_government_responses.rb

A
33 lines of codes
2 methods
3.2 complexity/method
1 churn
6.3 complexity
0 duplications
class MigrateGovernmentResponses < ActiveRecord::Migration
  1. MigrateGovernmentResponses has no descriptive comment
def up execute <<-SQL INSERT INTO government_responses (petition_id, summary, details, created_at, updated_at) SELECT id, response_summary, response, government_response_at, government_response_at FROM petitions WHERE government_response_at IS NOT NULL SQL remove_column :petitions, :response remove_column :petitions, :response_summary end def down add_column :petitions, :response, :text add_column :petitions, :response_summary, :string, limit: 500 execute <<-SQL UPDATE petitions AS p SET response_summary = r.summary, response = r.details FROM government_responses AS r WHERE p.id = r.petition_id SQL end end