Sha256: 8d293dfc7230f358b4be0284d2353d96278abd77ceedc36a85acf35d4a4977fb

Contents?: true

Size: 661 Bytes

Versions: 15

Compression:

Stored size: 661 Bytes

Contents

class MigratePeopleCommentsToEvents < ActiveRecord::Migration[5.0]
  class Event < ::Dorsale::ApplicationRecord
    self.table_name = :dorsale_customer_vault_events

    belongs_to :comment, class_name: Dorsale::Comment
  end

  def change
    add_column :dorsale_customer_vault_events, :title, :string
    add_column :dorsale_customer_vault_events, :date, :date

    Event.where(action: "comment").each do |event|
      event.title = event.comment.title
      event.text  = event.comment.text
      event.date  = event.comment.date
      event.save!
      event.comment.destroy!
    end

    remove_column :dorsale_customer_vault_events, :comment_id
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
dorsale-3.10.3 db/migrate/20171023080507_migrate_people_comments_to_events.rb
dorsale-3.10.2 db/migrate/20171023080507_migrate_people_comments_to_events.rb
dorsale-3.10.1 db/migrate/20171023080507_migrate_people_comments_to_events.rb
dorsale-3.10.0 db/migrate/20171023080507_migrate_people_comments_to_events.rb
dorsale-3.9.8 db/migrate/20171023080507_migrate_people_comments_to_events.rb
dorsale-3.9.7 db/migrate/20171023080507_migrate_people_comments_to_events.rb
dorsale-3.9.6 db/migrate/20171023080507_migrate_people_comments_to_events.rb
dorsale-3.9.5 db/migrate/20171023080507_migrate_people_comments_to_events.rb
dorsale-3.9.4 db/migrate/20171023080507_migrate_people_comments_to_events.rb
dorsale-3.9.3 db/migrate/20171023080507_migrate_people_comments_to_events.rb
dorsale-3.9.2 db/migrate/20171023080507_migrate_people_comments_to_events.rb
dorsale-3.9.1 db/migrate/20171023080507_migrate_people_comments_to_events.rb
dorsale-3.9.0 db/migrate/20171023080507_migrate_people_comments_to_events.rb
dorsale-3.8.1 db/migrate/20171023080507_migrate_people_comments_to_events.rb
dorsale-3.8.0 db/migrate/20171023080507_migrate_people_comments_to_events.rb