-
Type: Bug
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: 7.1.0
-
Component/s: None
-
None
-
Environment:OSX 10.15.4
mongo (2.11.4)
mongoid (7.1.0)
> mongod --version
db version v4.2.6
git version: 20364840b8f1af16917e4c23c1b5f5efd8b352f8
allocator: system
modules: none
build environment:
distarch: x86_64
target_arch: x86_64
> mongo --version
MongoDB shell version v4.2.6
git version: 20364840b8f1af16917e4c23c1b5f5efd8b352f8
allocator: system
modules: none
build environment:
distarch: x86_64
target_arch: x86_64
Observed same behavior with Mongo DB v3.6OSX 10.15.4 mongo (2.11.4) mongoid (7.1.0) > mongod --version db version v4.2.6 git version: 20364840b8f1af16917e4c23c1b5f5efd8b352f8 allocator: system modules: none build environment: distarch: x86_64 target_arch: x86_64 > mongo --version MongoDB shell version v4.2.6 git version: 20364840b8f1af16917e4c23c1b5f5efd8b352f8 allocator: system modules: none build environment: distarch: x86_64 target_arch: x86_64 Observed same behavior with Mongo DB v3.6
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"}>
- duplicates
-
MONGOID-4802 Test eagerly loading application classes in rake tasks that use Mongoid.models with Rails 6/zeitwerk / create_index rake task
- Closed