edgedb-js icon indicating copy to clipboard operation
edgedb-js copied to clipboard

Improve running the generator and migrations in CI environment

Open colinhacks opened this issue 2 years ago • 2 comments

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 by npx @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

colinhacks avatar May 04 '22 06:05 colinhacks

$ npx edgedb-migrate

call it edgedb-ci-migrate?

1st1 avatar May 04 '22 06:05 1st1

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

colinhacks avatar May 10 '22 19:05 colinhacks