Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Stuck in Datastore (Can't change to Native/ Can't Delete)

I accidentally started a database in datastore instead of native mode, so I cannot access it using firebase api anymore. 

It does not contain any data.

I have tried converting it to native mode:

 

gcloud alpha firestore databases update --database="(default)" --type=firestore-native
ERROR: (gcloud.alpha.firestore.databases.update) FAILED_PRECONDITION: Precondition check failed.

 

I have tried deleting it like this: 

 

gcloud alpha firestore databases delete --database "(de
fault)"
The database 'projects/hostai-booking-prod-clone/databases/(default)' will be deleted.

Do you want to continue (Y/n)?  y

ERROR: (gcloud.alpha.firestore.databases.delete) FAILED_PRECONDITION: Precondition check failed.

 

delete protection is also turned off

 

gcloud alpha firestore databases update --database="(default)" --no-delete-protection

 

So I am now stuck with a database I cannot change to native mode and cannot delete...The error message tells me precondition failed but provides no information on what precondition has failed...

0 6 1,656
6 REPLIES 6

There are a few possible reasons why you might be getting the FAILED_PRECONDITION error when trying to update or delete your Firestore database. It could be related to the database's current state, permissions, or other factors.

Here are some steps you can take to troubleshoot and resolve the FAILED_PRECONDITION error:

1. Check Permissions

Make sure your account has the necessary permissions to modify or delete the Firestore database. You should have roles like Owner, Editor, or a custom role with sufficient permissions. Verify your permissions in the IAM section of the Google Cloud Console.

2. Use the Web Interface

Attempt to perform the same operations from the Google Cloud Console. The web interface may provide more detailed error messages or additional options to resolve the issue.

Additional Checks

  • Review the settings of your Firestore database in the Google Cloud Console to ensure there are no configurations preventing the deletion or conversion of the database.
  • Sometimes, the issue might be temporary. Wait for some time and try the operations again.

Alternative Solution

If the database does not contain any data and you are unable to delete or convert it, consider creating a new Google Cloud project and setting up Firestore in native mode in the new project. This should be considered as a last resort as it might involve additional configuration and setup.

Note:

  • Ensure to replace any sensitive information before sharing error messages or logs publicly or with support.
  • If you are still unable to update or delete the database after trying the above steps, creating a new database and migrating any necessary data should be your last resort.

It is not a permissions issue, the account I am using is the Owner account.

The web interface has the delete option disabled and on hover the tooltip tell me I am limited to using the api.

It's unbelievable to me that the best/only solution here is to create a whole new project!! not something one would expect from an established Google product... 

Try opening the database in the Google Cloud console. Select the database from the list of available databases. When a Datastore database is empty, you should see a button to "Switch to Native mode."

Here is what I get when I try that:

hijazhostai_0-1695853914480.png

 

Even in Native mode, it's not possible to delete the database after creation it seems. I've just created this database to test (nothing has been configured, it's not storing any data):

gcloud alpha firestore databases delete --database="(default)"
The database 'projects/xxxxx/databases/(default)' will be deleted.

Do you want to continue (Y/n)? Y

ERROR: (gcloud.alpha.firestore.databases.delete) FAILED_PRECONDITION: Precondition check failed.

The option in the console is not available

mattk11_0-1696236223100.png

 

This appears to have been a temporary issue and should now be resolved. Please try this again either through the console or gcloud.

If you try it in the console, you might see a 400 error when you switch from Datastore mode to Native mode. Refresh the page and it should work.