2017-07-09 17:41:28 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2012-01-12 19:33:07 +00:00
|
|
|
require "cases/helper"
|
|
|
|
|
|
|
|
module ActiveRecord
|
|
|
|
class Migration
|
2012-11-19 14:52:09 +00:00
|
|
|
class << self; attr_accessor :message_count; end
|
|
|
|
self.message_count = 0
|
2012-01-16 19:21:20 +00:00
|
|
|
|
2012-01-12 19:33:07 +00:00
|
|
|
module TestHelper
|
|
|
|
attr_reader :connection, :table_name
|
|
|
|
|
2012-07-02 19:41:49 +00:00
|
|
|
CONNECTION_METHODS = %w[add_column remove_column rename_column add_index change_column rename_table column_exists? index_exists? add_reference add_belongs_to remove_reference remove_references remove_belongs_to]
|
2012-06-30 13:09:35 +00:00
|
|
|
|
2012-01-12 19:33:07 +00:00
|
|
|
class TestModel < ActiveRecord::Base
|
2012-06-30 13:09:35 +00:00
|
|
|
self.table_name = :test_models
|
2012-01-12 19:33:07 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def setup
|
|
|
|
super
|
|
|
|
@connection = ActiveRecord::Base.connection
|
|
|
|
connection.create_table :test_models do |t|
|
2014-08-12 20:23:14 +00:00
|
|
|
t.timestamps null: true
|
2012-01-12 19:33:07 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
TestModel.reset_column_information
|
|
|
|
end
|
|
|
|
|
|
|
|
def teardown
|
|
|
|
super
|
2012-01-12 22:16:47 +00:00
|
|
|
TestModel.reset_table_name
|
|
|
|
TestModel.reset_sequence_name
|
2015-09-22 15:28:38 +00:00
|
|
|
connection.drop_table :test_models, if_exists: true
|
2012-01-12 19:33:07 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
2016-08-06 17:55:02 +00:00
|
|
|
delegate(*CONNECTION_METHODS, to: :connection)
|
2012-01-12 19:33:07 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|