Updated

db/migrate / 20150617114935_create_email_requested_receipts.rb

B
32 lines of codes
1 methods
16.4 complexity/method
1 churn
16.4 complexity
46 duplications
class CreateEmailRequestedReceipts < ActiveRecord::Migration
  1. CreateEmailRequestedReceipts has no descriptive comment
def change
  1. Similar code found in 2 nodes Locations: 0 1
  2. CreateEmailRequestedReceipts#change has approx 11 statements
create_table :email_requested_receipts do |t|
  1. CreateEmailRequestedReceipts#change has the variable name 't'
t.references :petition, index: true, foreign_key: true t.datetime :government_response t.datetime :debate_outcome t.timestamps null: false end reversible do |dir| dir.up do execute <<-SQL.strip_heredoc INSERT INTO email_requested_receipts SELECT nextval('email_requested_receipts_id_seq'), petitions.id, petitions.email_requested_at, NULL, current_timestamp, current_timestamp FROM petitions WHERE petitions.email_requested_at IS NOT NULL SQL end dir.down do execute <<-SQL.strip_heredoc UPDATE petitions SET email_requested_at = email_requested_receipts.government_response FROM email_requested_receipts WHERE petitions.id = email_requested_receipts.petition_id SQL end end remove_column :petitions, :email_requested_at, :datetime end end