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

rake db:mongoid:create_indexes does create indexes correctly

    • Type: Icon: Task Task
    • Resolution: Done
    • 3.0.0
    • Affects Version/s: None
    • Component/s: None

      Hi,

      rake db:mongoid:create_indexes does not create the defined indexes correctly in 3.0.0.rc.

      In my model I use:

      index(

      { project_id: 1, email: 1 }

      , unique: true)
      index(

      { project_id: 1, tag_ids: 1, active: 1, next_mailing: -1 }

      )
      index(

      { project_id: 1, created_at: -1 }

      )

      rake db:mongoid:create_indexes shows the following output in the console, which is wrong:

      Creating indexes on: Subscriber for: {:project_id=>1, :email=>1}, {:created_at=>-1}, {:active=>1, :next_mailing=>-1}.

      And in MongoDB the following indexes are created:

      db.subscribers.getIndexes()
      [
      {
      "v" : 1,
      "key" :

      { "_id" : 1 }

      ,
      "ns" : "test.subscribers",
      "name" : "id"
      },
      {
      "v" : 1,
      "key" :

      { "project_id" : 1, "email" : 1 }

      ,
      "unique" : true,
      "ns" : "test.subscribers",
      "name" : "project_id_1_email_1"
      },
      {
      "v" : 1,
      "key" :

      { "created_at" : -1 }

      ,
      "ns" : "test.subscribers",
      "name" : "created_at_-1"
      },
      {
      "v" : 1,
      "key" :

      { "active" : 1, "next_mailing" : -1 }

      ,
      "ns" : "test.subscribers",
      "name" : "active_1_next_mailing_-1"
      }
      ]

      Am I defining indexes in my models the wrong way?

      Thanks and cheers

            Assignee:
            durran Durran Jordan
            Reporter:
            marcboeker marcboeker
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: