# File lib/rubyrep/replication_initializer.rb, line 279
    def prepare_replication
      exclude_rubyrep_tables

      puts "Verifying RubyRep tables"
      ensure_infrastructure

      call_after_infrastructure_setup_handler

      puts "Checking for and removing rubyrep triggers from unconfigured tables"
      restore_unconfigured_tables

      puts "Verifying rubyrep triggers of configured tables"
      unsynced_table_pairs = []
      table_pairs = session.sort_table_pairs(session.configured_table_pairs)
      table_pairs.each do |table_pair|
        table_options = options(table_pair[:left])
        ensure_sequence_setup table_pair,
          table_options[:sequence_increment],
          table_options[:left_sequence_offset],
          table_options[:right_sequence_offset]

        unsynced = false
        [:left, :right].each do |database|
          unless trigger_exists? database, table_pair[database]
            create_trigger database, table_pair[database]
            unsynced = true
          end
        end
        if unsynced and table_options[:initial_sync]
          unsynced_table_pairs << table_pair
        end
      end
      unsynced_table_specs = unsynced_table_pairs.map do |table_pair|
        "#{table_pair[:left]}, #{table_pair[:right]}"
      end

      unless unsynced_table_specs.empty?
        puts "Executing initial table syncs"
        runner = SyncRunner.new
        runner.session = session
        runner.options = {:table_specs => unsynced_table_specs}
        runner.execute
      end

      puts "Starting replication"
    end