Manage databases  |  Firestore  |  Firebase

Manage databases

Stay organized with collections. Save and categorize content based on your preferences.

Required roles and permissions

To create and manage databases, you'll need the following Identity and Access Management role:

That role grants the following permissions that you need to create and manage databases:

Create a database

To create a database, use one of the following methods:

ConsolegcloudFirebase CLITerraform

Firebase console

  1. In the Firebase console, go to Databases & Storage > Firestore.
    Go to Firestore
  2. Click Add database.
  3. Select Standard edition. Click Next.
  4. Enter a Database ID.
  5. Select a location for your database. Click Next.
  6. Select a starting mode for your Cloud Firestore Security Rules:
    • Test mode: Good for getting started with the mobile and web client libraries, but allows anyone to read and overwrite your data. After testing, make sure to review the Secure your data section.
    • Production mode: Denies all reads and writes from mobile and web clients. Your authenticated application servers (Node.js, Python, Java) can still access your database.
  7. Click Create.

Using gcloud command

Use the gcloud firestore databases create command.

gcloud firestore databases create \
  --database=DATABASE_ID \
  --location=LOCATION \
  --edition=standard \
  --type=DATABASE_TYPE

Replace the following:

--delete-protection is an optional flag to enable deletion protection.

Tags

To add tags to the database, use the --tags flag:

--tags=123/environment=production,123/costCenter=marketing

Update database configuration

To update the configurations settings of a database, use the gcloud firestore databases update command.

Delete a database

To delete a database, use the console or command-line tool.

  1. In the Firebase console, go to Databases & Storage > Firestore.
  2. In the Data tab, above the data table view for the database, click more_vert, then select Delete database.
  3. Follow the instructions to delete the database.

Use the gcloud firestore databases delete command.

gcloud firestore databases delete --database=DATABASE_ID

Replace DATABASE_ID with the ID of the database to delete. To delete the default database use the ID '(default)'.

Clone a database

You can clone an existing database at a selected timestamp into a new database:

Use the gcloud firestore databases clone command to clone a database:

gcloud firestore databases clone \
--source-database='SOURCE_DATABASE' \
--snapshot-time='PITR_TIMESTAMP' \
--destination-database='DESTINATION_DATABASE_ID'

Replace the following:

IAM Conditions

You can use Identity and Access Management Conditions to configure access permissions on a per-database level. The following examples use the Google Cloud CLI to assign conditional access.

Cloud Monitoring

Cloud Firestore metrics are reported under two monitored resources:

Limitations

Next Steps