module Stagehand
  module Schema
    module Statements
      # Ensure that developers are aware they need to make a determination of whether stagehand should track this table or not
      def create_table(table_name, options = {})
        super

        return if options.symbolize_keys[:stagehand] == false
        return if UNTRACKED_TABLES.include?(table_name)
        return if Database.connected_to_production?

        Schema.add_stagehand! :only => table_name
      end
    end
  end
end

ActiveRecord::Base.connection.class.include Stagehand::Schema::Statements

module Stagehand
  module Schema
    module Statements
      # Ensure that developers are aware they need to make a determination of whether stagehand should track this table or not
      def create_table(table_name, options = {})
        super

        return if options.symbolize_keys[:stagehand] == false
        return if UNTRACKED_TABLES.include?(table_name)
        return if Database.connected_to_production? && !Stagehand::Configuration.single_connection?

        Schema.add_stagehand! :only => table_name
      end
    end
  end
end

ActiveRecord::Base.connection.class.include Stagehand::Schema::Statements

Fix rake not creating triggers
Fix rake not creating triggers

If the test environment used only a single connection, and the rake task was run in that environment, the extended version of create_table would not create triggers because it found that it was migrating the production database (which was also the staging database). Now if there is a single connection, we ignore the fact that we're in the production database and still create triggers.
