S1ngoooor
S1ngoooor

Reputation: 2607

Cannot switch Firestore from Datastore to native mode on GCP

Somehow the Firestore initialized with the Datastore mode and I can't switch it back to the Firestore native mode even the Datastore is empty.

There's no useful info I can get from the error message.

failed in switching firestore mode

Upvotes: 2

Views: 1878

Answers (4)

Supun Ayeshmantha
Supun Ayeshmantha

Reputation: 607

To disable the Datastore mode in firestore , follow the steps:

  1. You can also click here to go to the Google Cloud Platform Page.

  2. After that click on the Cloud Shell

  3. After that Paste the following Code in the terminal and press Enter

    gcloud alpha firestore databases update --type=firestore-native

  4. Authorize the request.

Now you can access the database in firebase

Upvotes: 1

Nayana Jangale
Nayana Jangale

Reputation: 11

Click on the defalut option on the right side of the datastore option. If you have not added any data to the database, the option to switch to Native Mode should show up in the GCP console. You can access the GCP console directly rather than through the Firebase console.

[img][1] [1]: https://i.sstatic.net/qr440.png

Upvotes: 0

democrenes
democrenes

Reputation: 69

The answer is here in the "Choosing between Native and Datastore" mode section

If your database is empty, you can change between Native mode and Datastore mode.

You can accomplish this using a patch request, assuming you've also obtained the valid credentials. For example:

curl --request PATCH \
--header "Authorization: Bearer "$(gcloud auth print-access-token) \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{"type":"DATASTORE_MODE"}' \
"https://firestore.googleapis.com/v1/projects/PROJECT_ID/databases/(default)?updateMask=type"

Upvotes: 0

DazWilkin
DazWilkin

Reputation: 40296

After the first write, you cannot change the mode once it has been created.

You cannot disable, re-enable and recreate a Firestore database in the same Project either. This is unfortunate and is likely an historical consequence of Datastore's original relationship with App Engine.

The only possibly way this could be change (after the first write) is with help from the magical elves in Google Support but, I'm confident that they're not able to do this either.

There are no magical elves that create these resources though, someone who has permissions on your Project created the Firestore database in Datastore mode.

Upvotes: 1

Related Questions