Updated

db/migrate / 20150617135014_create_email_sent_receipts.rb

B
32 lines of codes
1 methods
16.4 complexity/method
1 churn
16.4 complexity
46 duplications
class CreateEmailSentReceipts < ActiveRecord::Migration
  1. CreateEmailSentReceipts has no descriptive comment
def change
  1. Similar code found in 2 nodes Locations: 0 1
  2. CreateEmailSentReceipts#change has approx 11 statements
create_table :email_sent_receipts do |t|
  1. CreateEmailSentReceipts#change has the variable name 't'
t.references :signature, 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_sent_receipts SELECT nextval('email_sent_receipts_id_seq'), signatures.id, signatures.last_emailed_at, NULL, current_timestamp, current_timestamp FROM signatures WHERE signatures.last_emailed_at IS NOT NULL SQL end dir.down do execute <<-SQL.strip_heredoc UPDATE signatures SET last_emailed_at = email_sent_receipts.government_response FROM email_sent_receipts WHERE signatures.id = email_sent_receipts.signature_id SQL end end remove_column :signatures, :last_emailed_at, :datetime end end