selmertsxの素振り日記

ひたすら日々の素振り内容を書き続けるだけの日記

【GCP】Datastoreを作ってしまったGCPプロジェクトではFirestoreを使えない

表題の通り。それだけなんだけれども、同じ悲劇を経験する人がいないようにブログに書きました。

2019年1月、Firestoreが東京リージョンでも使えるようになった。 https://firebase.google.com/docs/firestore/locations?hl=en#location-r

せっかくなので、今作っているcloud functionsのデータベースをDatastoreではなくてFirestoreで構築しようと考えた。( FirestoreはDatastoreの上位互換であり、Datastoreで使える機能はFirestoreでも利用可能 )

ということでドキュメントを見ながらコードを書いて、動作確認をしようとしたら下記のエラー。

{ Error: 9 FAILED_PRECONDITION: This project contains a Cloud Datastore database and does not support Cloud Firestore API calls.
    at Object.exports.createStatusError (/Users/shuhei.morioka/project/speee/datadog_slack_report/node_modules/grpc/src/common.js:91:15)
    at Object.onReceiveStatus (/Users/shuhei.morioka/project/speee/datadog_slack_report/node_modules/grpc/src/client_interceptors.js:1204:28)
    at InterceptingListener._callNext (/Users/shuhei.morioka/project/speee/datadog_slack_report/node_modules/grpc/src/client_interceptors.js:568:42)
    at InterceptingListener.onReceiveStatus (/Users/shuhei.morioka/project/speee/datadog_slack_report/node_modules/grpc/src/client_interceptors.js:618:8)
    at callback (/Users/shuhei.morioka/project/speee/datadog_slack_report/node_modules/grpc/src/client_interceptors.js:845:24)
  code: 9,
  metadata: Metadata { _internal_repr: {} },
  details: 'This project contains a Cloud Datastore database and does not support Cloud Firestore API calls.' }

ここで1~2時間くらい原因を調査したが分からず、issue trackerを見てみたらこんな文言が。

If you absolutely want to use Firestore proper, you need to open a new project and deploy your app to the new project, where you choose Firestore from the start.

https://issuetracker.google.com/issues/113075718

ということで、Datastoreをすでに使っているプロジェクトではFirestoreは使うことが出来ません。これから触る人は、誤って使わないように気をつけましょう〜

ちなみに

Cloud Firestore への自動アップグレード  |  Cloud Datastore ドキュメント  |  Google Cloud

Cloud Firestore の一般公開後、ある程度の時間を置いてから既存の Cloud Datastore データベースの所有者に連絡し、Cloud Firestore の Datastore モードへの自動アップグレードのタイミングを相談させていただく予定です。

ということです!