kevlened / fireway

A schema migration tool for firestore
MIT License
277 stars 41 forks source link

fireway requiring projectId while running against firebase emulator #57

Closed eokoneyo closed 2 years ago

eokoneyo commented 2 years ago

Hi there,

I'm currently running into an issue attempting to run migrations whilst specifying the environment variable FIREBASE_EMULATOR_HOST, my script is something along the lines of;

    "emulators": "firebase emulators:start",
    "firebase-migration": "yarn cross-env FIRESTORE_EMULATOR_HOST=localhost:8080 fireway --path=\"./scripts/migrations\" migrate --dryRun"

on starting the emulator, then running firebase-migration I get this error;

 FirebaseAppError: Failed to determine project ID: Error while making request: getaddrinfo ENOTFOUND metadata.google.internal. Error code: ENOTFOUND

which is quite strange considering the README file for the package explicitly states that once the FIRESTORE_EMULATOR_HOST env value is set, there should be no need to set a project ID, I also looked into how tests are ran in package, and I see it's very similar to the setup I shared above. I'd appreciate any insights you might have as why it's not working as one might expect.

My fireway version is 1.1.0

eokoneyo commented 2 years ago

I finally figured this out so I'll be closing this, turns out my issue was occurring because I was interacting with user auth within my migration script and not only firestore, after taking a look here I modified the migration script for dev like so;

   "firebase-migration": "yarn cross-env GCLOUD_PROJECT=project-id FIREBASE_AUTH_EMULATOR_HOST=localhost:9099 FIRESTORE_EMULATOR_HOST=localhost:8080 fireway --path=\"./scripts/migrations\" migrate --dryRun"

it's worth pointing out project-id must match the value of the project id that the emulator runs against.