Changeset 1278

Show
Ignore:
Timestamp:
10/26/06 21:29:44 (2 years ago)
Author:
pdcawley
Message:

A slightly more sane migration 56. It probably breaks on everything
but MySQL, but at least it documents the intent...

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • experimental/restful/db/migrate/056_create_notifications.rb

    r1275 r1278  
    11class CreateNotifications < ActiveRecord::Migration 
     2  class OldNotification < ActiveRecord::Base 
     3  end 
     4 
     5  class Notification < ActiveRecord::Base 
     6  end 
     7 
    28  def self.up 
     9    rename_table :notifications, :old_notifications 
     10 
    311    create_table :notifications do |t| 
    4       # t.column :name, :string 
     12      t.column :content_id, :integer 
    513      t.column :user_id, :integer 
    6       t.column :content_id, :integer 
     14      t.column :created_at, :datetime 
     15      t.column :updated_at, :datetime 
    716    end 
     17 
     18    OldNotification.reset_column_information 
     19    Notification.reset_column_information 
     20    if $schema_generator 
     21      OldNotification.find(:all).each do |on| 
     22        Notification.create!(on.attributes) 
     23      end 
     24    end 
     25    drop_table :old_notifications 
    826  end 
    927 
    1028  def self.down 
    11     drop_table :notifications 
     29    remove_column :notifications, :id 
     30    rename_column :notifications, :user_id, :notify_user_id 
     31    rename_column :notifications, :content_id, :notify_content_id 
    1232  end 
    1333end