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...
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
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:
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:
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
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.