2012-01-12 14:33:07 -05:00
|
|
|
require "cases/helper"
|
|
|
|
|
|
|
|
module ActiveRecord
|
|
|
|
class Migration
|
2012-01-16 14:21:20 -05:00
|
|
|
class << self
|
|
|
|
attr_accessor :message_count
|
|
|
|
end
|
|
|
|
|
|
|
|
def puts(text="")
|
|
|
|
ActiveRecord::Migration.message_count ||= 0
|
|
|
|
ActiveRecord::Migration.message_count += 1
|
|
|
|
end
|
|
|
|
|
2012-01-12 14:33:07 -05:00
|
|
|
module TestHelper
|
|
|
|
attr_reader :connection, :table_name
|
|
|
|
|
|
|
|
class TestModel < ActiveRecord::Base
|
|
|
|
self.table_name = 'test_models'
|
|
|
|
end
|
|
|
|
|
|
|
|
def setup
|
|
|
|
super
|
|
|
|
@connection = ActiveRecord::Base.connection
|
|
|
|
connection.create_table :test_models do |t|
|
|
|
|
t.timestamps
|
|
|
|
end
|
|
|
|
|
|
|
|
TestModel.reset_column_information
|
|
|
|
end
|
|
|
|
|
|
|
|
def teardown
|
|
|
|
super
|
2012-01-12 17:16:47 -05:00
|
|
|
TestModel.reset_table_name
|
|
|
|
TestModel.reset_sequence_name
|
2012-01-12 14:33:07 -05:00
|
|
|
connection.drop_table :test_models rescue nil
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
def add_column(*args)
|
|
|
|
connection.add_column(*args)
|
|
|
|
end
|
|
|
|
|
|
|
|
def remove_column(*args)
|
|
|
|
connection.remove_column(*args)
|
|
|
|
end
|
|
|
|
|
|
|
|
def rename_column(*args)
|
|
|
|
connection.rename_column(*args)
|
|
|
|
end
|
2012-01-12 16:14:58 -05:00
|
|
|
|
|
|
|
def add_index(*args)
|
|
|
|
connection.add_index(*args)
|
|
|
|
end
|
|
|
|
|
|
|
|
def change_column(*args)
|
|
|
|
connection.change_column(*args)
|
|
|
|
end
|
2012-01-12 17:16:47 -05:00
|
|
|
|
|
|
|
def rename_table(*args)
|
|
|
|
connection.rename_table(*args)
|
|
|
|
end
|
2012-01-12 14:33:07 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|