fauna-labs / fauna-schema-migrate

The Fauna Schema Migrate tool helps you set up Fauna resources as code and perform schema migrations.
MIT No Attribution
88 stars 11 forks source link

`fauna-schema-migrate generate` fails with TypeError #121

Closed accuser closed 2 years ago

accuser commented 2 years ago

I've tried to use FSM with a simple schema definition, having only one collection ("people") and one index ("people_by_email"). I used init to initialise FSM, but when it fails when I try to generate migrations:

> env-cmd fauna-schema-migrate generate

generate: Generate migration from your resources Executed...
🧬  Planning Migrations
TypeError: Cannot read properties of undefined (reading 'object')

These are the installed packages:

@fauna-labs/fauna-schema-migrate 2.2.1 env-cmd 10.1.0 faunadb 4.6.0

These are the schema files:

/* ./fauna/resources/collections/people.js */
import { query } from "faunadb";
const { CreateCollection } = query;

export default CreateCollection("people");
/* ./fauna/resources/indexes/people-by-email.js */
import { query } from "faunadb";
const { Collection, CreateIndex } = query;

export default CreateIndex({
  name: "people_by_email",
  unique: true,
  serialized: true,
  source: Collection("people"),
  terms: [
    {
      field: ["data", "email"],
      transform: "casefold",
    },
  ],
  values: [
    {
      field: "ref",
    },
    {
      field: ["data", "displayName"],
    },
    {
      field: ["data", "email"],
    },
  ],
});

I have created a .env file with FAUNA_ADMIN_KEY and FAUNADB_DOMAIN variables.

accuser commented 2 years ago

Mea culpa. I missed the params object for CreateCollection.