Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-4888

Rake task does not create indexes

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 7.1.0
    • Component/s: None
    • None
    • Environment:

      Model:

       

      class Loan
        include Mongoid::Document
        include Mongoid::Timestamps
        index({ loan_number: 1 }, { unique: true, name: "loan_number_index" })
      

       

       

      According to docs https://docs.mongodb.com/mongoid/current/tutorials/mongoid-indexes/

       

      rake db:mongoid:create_indexes 

       

      There is no output, except for Rails 6 warnings:

      .../action_dispatch/middleware/stack.rb:37: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
      .../actionpack-6.0.2.2/lib/action_dispatch/middleware/static.rb:110: warning: The called method `initialize' is defined here

       

      mongo shell shows only default index exists:

      > db.loan_details.getIndexes()> db.loan.getIndexes()[ { "v" : 2, "key" : { "_id" : 1 }, "name" : "_id_", "ns" : "cedar_customer_app_development.loans" }]

       

      However, Rails console shows a index has been created:

      irb(main):009:0> LoanDetail.index_specifications
      => [#<Mongoid::Indexable::Specification:0x00007fb6268ba748 @klass=Loan, @key={:loan_number=>1}, @fields=[:loan_number], @options={:unique=>true, :name=>"loan_number_index"}>

       

       

       

            Assignee:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Reporter:
            george@cedarcreditbuilder.com George Ulmer
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: