Skip to content

firebase deploy firebase:indexes fails when any index was already created #1483

Description

@marcin-ptaszynski

[REQUIRED] Environment info

firebase-tools: 7.0.2

Platform: Ubuntu

[REQUIRED] Test case

v1: indexes.json

{
  "indexes": [
    {
      "collectionGroup": "authors",
      "queryScope": "COLLECTION",
      "fields": [
        {
          "fieldPath": "name",
          "order": "ASCENDING"
        },
        {
          "fieldPath": "born",
          "order": "ASCENDING"
        }
      ]
    }
  ]
}

v2: indexes.json: added new index

{
  "indexes": [
    {
      "collectionGroup": "authors",
      "queryScope": "COLLECTION",
      "fields": [
        {
          "fieldPath": "name",
          "order": "ASCENDING"
        },
        {
          "fieldPath": "born",
          "order": "ASCENDING"
        }
      ]
    },
    {
      "collectionGroup": "authors",
      "queryScope": "COLLECTION",
      "fields": [
        {
          "fieldPath": "name",
          "order": "ASCENDING"
        },
        {
          "fieldPath": "born",
          "order": "DESCENDING"
        }
      ]
    }
  ]
}

[REQUIRED] Steps to reproduce

  1. run firebase deploy --only firestore:indexes with first version of indexes.json
  2. update file with additional index and re-run

[REQUIRED] Expected behavior

Both commands are successful and target firestore database contains both indices

[REQUIRED] Actual behavior

First run succeeds, but latter fails with error: Error: HTTP Error: 409, index already exists. Only first index is present.

Workaround

  1. Delete all indexes before deploy
  2. Place in indexes.json only indexes not present in database.

It would seems this has been caused by: #1120

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions