Updated

db/migrate / 20150701165425_migrate_notes.rb

A
29 lines of codes
2 methods
2.0 complexity/method
1 churn
4.0 complexity
0 duplications
class MigrateNotes < ActiveRecord::Migration
  1. MigrateNotes has no descriptive comment
def up execute <<-SQL INSERT INTO notes (petition_id, details, created_at, updated_at) SELECT id, admin_notes, updated_at, updated_at FROM petitions WHERE admin_notes IS NOT NULL SQL remove_column :petitions, :admin_notes end def down add_column :petitions, :admin_notes, :text execute <<-SQL UPDATE petitions AS p SET admin_notes = n.details FROM notes AS n WHERE p.id = n.petition_id SQL end end