firebase / firebase/firebase-tools

firebase cli: wait for Firestore indexes deployment

Open
#7,959 4 comments 2 reactions 1 assignee Claimed by @jamesdaniels View on GitHub
api: firestore type: feature request
Dominant language
TypeScript
Stars
4.5k
Forks
1.3k
Avg merge
1d 12h
Merged PRs (30d)
84

Description

## Description

Enabling indexes in databases is a common practice. Many projects dedicate a separate CI step to DB schema/index changes before deploying new application code.

## Firebase problem

Firebase provides the following functionality to deploy indexes:
```
firebase deploy --only=firestore:indexes [--force]
```

The command does not wait for the end of index deployment in the database. This may result in the following failure:
1. Run `firebase deploy --only=firestore:indexes --force`, which is asynchronous operation.
2. Deploy frontend or backend applications with queries requiring new Firstore indexes.

⚠️ Step 2 is completed, while indexes deployment is still in progress. _At runtime, users will see Firestore query errors that require enabling new indexes._

## Current workarounds

It is possible to run `gcloud firestore operations list` command in a loop and check for the related command status completion.

The CI code is challenging for beginners and error-prone for experienced programmers. Adding new database indexes is a common practice, and it will benefit many Firestore users.

## Proposal

Introduce
```
firebase deploy --only=firestore:indexes --wait-all
```
where `--wait-all` will force the command to wait for all operations to complete, in this case, indexes deployment.

It is hard to choose the right argument name. For example, `firebase deploy --only functions` is a synchronous operation that waits for the end of function deployments.

---

I found several requests for that feature in Stackoverflow and Google community but did not find it in Github. I'm sorry if I missed it. The feature request is also submitted via [support page](https://firebase.google.com/support/troubleshooter/report/features/).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.