edgedb-js
edgedb-js copied to clipboard
Improve running the generator and migrations in CI environment
Per a recent team call, I'm putting down some thoughts relating our plans to provide a better DX for users looking to generate the query builder and apply migrations in CI.
Per #361 all instances of
npx edgeql-js
will likely be replaced bynpx @edgedb/generate
.
1. Offline generation
Add a --offline
flag to npx edgeql-js
that would do a temp install of the CLI and spin up an ephemeral instance from which to generate the query builder. This would ignore the migration files and generate a fresh instance from the given SDL.
2 DDL-only mode for migrate
We should implement a way to execute migrations s.t. all DML statements are ignored, to prevent possible errors when executing a migration against an empty database.
3 SDL/migration integrity checking
The npx edgeql-js
command should check that the SDL is in sync with the latest migrations. This can be achieved by attempting to create a migration and checking if the list of proposed statements is empty.
This may be inadvisable for performance reasons. Currently the QB takes under a second to generate usually; this may increase that unacceptably.
4 Run migrations with npx
There should be a way to apply migrations with npx
. Installing the CLI binary in build environments like Vercel doesn't feel idiomatic in the JS ecosystem. The edgedb-js
package should expose another command (alongside edgeql-js
) for executing migrations. This would install the CLI using the logic from setup-edgedb
and use to to apply the migrations. Per #361:
$ npx @edgedb/migrate
$ npx edgedb-migrate
call it edgedb-ci-migrate?
I already dislike npx edgedb-migrate
and I like edgedb-ci-migrate
even less. Hyphenated commands like this just aren't very elegant and feel too technical/hackery. I propose an alternative command naming scheme here: https://github.com/edgedb/edgedb-js/issues/361