Sha256: 739b2c498a8de22db6b8377e15732b1ead93f4e088ac6d9665ec18bd6d413a3d

Contents?: true

Size: 865 Bytes

Versions: 1

Compression:

Stored size: 865 Bytes

Contents

class CreateNotifications < ActiveRecord::Migration
  class OldNotification < ActiveRecord::Base
  end

  class Notification < ActiveRecord::Base
  end

  def self.up
    rename_table :notifications, :old_notifications
    create_table :notifications do |t|
      t.column :content_id, :integer
      t.column :user_id, :integer
      t.column :created_at, :datetime
      t.column :updated_at, :datetime
    end

    OldNotification.reset_column_information
    Notification.reset_column_information
    if $schema_generator
      OldNotification.find(:all).each do |on|
        Notification.create!(on.attributes)
      end
    end
    drop_table :old_notifications
  end

  def self.down
    remove_column :notifications, :id
    rename_column :notifications, :user_id, :notify_user_id
    rename_column :notifications, :content_id, :notify_content_id
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
typo-4.1.1 db/migrate/056_create_notifications.rb