edgedb / edgedb-js

The official TypeScript/JS client library and query builder for EdgeDB
https://edgedb.com
Apache License 2.0
509 stars 62 forks source link

Error on `generate queries` after migration squash #678

Closed jackfischer closed 11 months ago

jackfischer commented 1 year ago

Follow up from discord [1]

Code

edgedb migration create --squash
edgedb migrate
@edgedb/generate queries

fixups/m1zty3dzskd55b45qlrk372z4wr5waj3ufl7wdqugs2c6rsudxq4aa-m1slgwrv4ofe447s2gr6gcbh7zpypzrzkzqxunqhv7tlnzygy7voeq.edgeql:

m1zty3dzskd55b45qlrk372z4wr5waj3ufl7wdqugs2c6rsudxq4aa-m1slgwrv4ofe447s2gr6gcbh7zpypzrzkzqxunqhv7tlnzygy7voeq.edgeql
CREATE MIGRATION m14pxoxvao5l26j3vg6glbeq2y5p3ocfx6hiwf6v2qemg3im4vll3a
    ONTO m1zty3dzskd55b45qlrk372z4wr5waj3ufl7wdqugs2c6rsudxq4aa
{
};

New 00001.edgeql:

 head dbschema/migrations/00001.edgeql
CREATE MIGRATION m1slgwrv4ofe447s2gr6gcbh7zpypzrzkzqxunqhv7tlnzygy7voeq
    ONTO initial
{
  CREATE GLOBAL default::current_user -> std::uuid;
...

Error or desired behavior

Generating functions from .edgeql files...
Detected tsconfig.json, generating TypeScript files.
   To override this, use the --target flag.
   Run `npx @edgedb/generate --help` for full options.
Detected project root via edgedb.toml:
   /Users/jack/dev/credalai-app
Connecting to database...
Analyzing .edgeql files...
Generating files for following queries:
Error in file './dbschema/fixups/m1zty3dzskd55b45qlrk372z4wr5waj3ufl7wdqugs2c6rsudxq4aa-m1slgwrv4ofe447s2gr6gcbh7zpypzrzkzqxunqhv7tlnzygy7voeq.edgeql': SchemaDefinitionError: specified migration parent is not the most recent migration, expected 'm1slgwrv4ofe447s2gr6gcbh7zpypzrzkzqxunqhv7tlnzygy7voeq'
   |
 2 |     ONTO m1zty3dzskd55b45qlrk372z4wr5waj3ufl7wdqugs2c6rsudxq4aa
   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

   ./queries/example1.query.ts
   ./queries/example2.query.ts

Versions (please complete the following information):

jackfischer commented 1 year ago

Confirmed this doesn't actually block query file generation, which suggests it's seeing the fixup file and incorrectly trying to generate a query file for it, failing and moving on.

scotttrinh commented 1 year ago

Ahhh, nice catch @jackfischer! We should definitely filter out /fixups/**/* from our queries generator. Will fix!