这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@paf31
Copy link
Contributor

@paf31 paf31 commented Jan 23, 2020

Description

Adds the graphql-engine downgrade command to revert the schema to a previous version.

As the help text indicates, the usage is as follows:

Usage: graphql-engine downgrade --to <VERSION> [--dryRun]
  Downgrade the GraphQL Engine schema to the specified version

--dryRun will simply show the SQL which would be run, without actually running it.

Affected components

  • Other (new command)

Related Issues

#1156

Solution and Design

I copied the downgrade scripts from the docs.hasura.io website into the migrations folder, and then removed the ones which don't seem to work against the latest schema any more. I can downgrade as far as schema version 12 but no further.

The code picks out the correct range of scripts to be run, and runs them in order.

Steps to test and verify

Tested by migrating back to various older versions, and then trying to upgrade back by restarting the latest server. As noted above, this works for all versions back to version 12.

Limitations, known bugs & workarounds

Server checklist

Catalog upgrade

Does this PR change Hasura Catalog version?

  • No

Metadata

Does this PR add a new Metadata feature?

  • No

GraphQL

  • No new GraphQL schema is generated

Breaking changes

  • No Breaking changes

@paf31 paf31 requested a review from lexi-lambda January 23, 2020 05:36
@netlify
Copy link

netlify bot commented Jan 23, 2020

Deploy preview for hasura-docs ready!

Built with commit 8beca02

https://deploy-preview-3760--hasura-docs.netlify.com

@hasura-bot
Copy link
Contributor

Review app for commit 9a8339c deployed to Heroku: https://hge-ci-pull-3760.herokuapp.com
Docker image for server: hasura/graphql-engine:pull3760-9a8339c8

@hasura-bot
Copy link
Contributor

Review app for commit a52611c deployed to Heroku: https://hge-ci-pull-3760.herokuapp.com
Docker image for server: hasura/graphql-engine:pull3760-a52611c3

@hasura-bot
Copy link
Contributor

Review app for commit 34ccb24 deployed to Heroku: https://hge-ci-pull-3760.herokuapp.com
Docker image for server: hasura/graphql-engine:pull3760-34ccb24a

where
-- This implements the mapping between application versions
-- and catalog schema versions.
readVersion "v1.0.0-alpha0" = Just "1"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually think having the mapping here is strictly worse than keeping it in documentation, because it's easier to forget to update it, and the user won't have any way to downgrade in that case. At least using catalog versions, we can tell them the exact command to use. I'm happy to hear alternatives if anyone has ideas.

Copy link
Contributor

@lexi-lambda lexi-lambda Jan 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you think it’s easier to forget to update this mapping than one in the documentation? I don’t see why one would be more obvious than the other.

In any case, I think being able to treat catalog versions as an implementation detail our users don’t have to worry about is a big enough win that I lean toward this approach, anyway. However, it does make me want two other features:

  1. I’d like to be able to print the list of versions graphql-engine knows about somehow. Otherwise, if I enter something like 1.1.0-beta.1 (leaving off the v) I just get a cryptic “cannot parse value” error, which is very unhelpful.

    I think the error message for supplying an invalid version should be improved to either list the known versions or tell people how to list them, and there should be something in the --help output that says how to list them. (We probably don’t want to list them all in the --help text all the time, since it would be a lot of output. But maybe we could show an example instead, and then we could probably get away with only printing out all the known versions if someone supplies an invalid version. Nevermind, I realized you’ve already done that. So I think it’s fine to just list known versions on invalid input.)

  2. I’d like to be able to specify a catalog version by specifying a --catalog-version flag or something like that. This is useful both for developers working on the server and users trying out PR builds. In the former case, we know the catalog versions, and in the latter, we’re already interacting with users directly, so we can just tell them what to run. Since this would be so easy to add, it seems worthwhile!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lexi-lambda How's this?

@paf31 paf31 marked this pull request as ready for review January 27, 2020 11:39
@hasura-bot
Copy link
Contributor

Review app for commit d85fc84 deployed to Heroku: https://hge-ci-pull-3760.herokuapp.com
Docker image for server: hasura/graphql-engine:pull3760-d85fc845

@hasura-bot
Copy link
Contributor

Review app for commit a6e648c deployed to Heroku: https://hge-ci-pull-3760.herokuapp.com
Docker image for server: hasura/graphql-engine:pull3760-a6e648cc

@0x777
Copy link
Member

0x777 commented Jan 31, 2020

This looks good @paf31, couple of things:

  1. I would second having the --catalog-version option, it'll be particularly useful in a git bisect style debugging workflow to figure out the commit that introduced a bug.

  2. because it's easier to forget to update it, and the user won't have any way to downgrade in that case

    We can have a test which gets the list of available options for the downgrade command and checks them with the tags in the git repo (ignoring the ones that we know will not exist)

@paf31
Copy link
Contributor Author

paf31 commented Feb 4, 2020

--to-catalog-version is implemented already, and I'll work on adding the test today.

@hasura-bot
Copy link
Contributor

Review app for commit 40647c0 deployed to Heroku: https://hge-ci-pull-3760.herokuapp.com
Docker image for server: hasura/graphql-engine:pull3760-40647c06

@hasura-bot
Copy link
Contributor

Review app for commit 81b40a4 deployed to Heroku: https://hge-ci-pull-3760.herokuapp.com
Docker image for server: hasura/graphql-engine:pull3760-81b40a47

@paf31 paf31 requested a review from 0x777 February 5, 2020 18:27
You can downgrade the catalogue from a particular version to a previous version by executing the ``graphql-engine`` executable on the command line,
with the ``downgrade`` command, specifying the desired catalog version using one of the ``--to-`` flags.

.. note::
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a rather long note. How about just having the third point as a note (as it's the unexpected case) and have the rest part of the normal tutorial?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, thanks.

@0x777 0x777 added the c/server Related to server label Feb 6, 2020
@hasura-bot
Copy link
Contributor

Review app for commit a5ab503 deployed to Heroku: https://hge-ci-pull-3760.herokuapp.com
Docker image for server: hasura/graphql-engine:pull3760-a5ab5034

@hasura-bot
Copy link
Contributor

Review app for commit 049ed13 deployed to Heroku: https://hge-ci-pull-3760.herokuapp.com
Docker image for server: hasura/graphql-engine:pull3760-049ed132

@hasura-bot
Copy link
Contributor

Review app for commit 8beca02 deployed to Heroku: https://hge-ci-pull-3760.herokuapp.com
Docker image for server: hasura/graphql-engine:pull3760-8beca021

@0x777 0x777 merged commit 94102c0 into hasura:master Feb 7, 2020
@hasura-bot
Copy link
Contributor

Review app https://hge-ci-pull-3760.herokuapp.com is deleted

@paf31 paf31 deleted the downgrade branch February 7, 2020 18:26
polRk pushed a commit to polRk/graphql-engine that referenced this pull request Feb 12, 2020
* Add downgrade command

* Add docs per @lexi-lambda's suggestions

* make tests pass

* Update hdb_version once, from Haskell

* more work based on feedback

* Improve the usage message

* Small docs changes

* Test downgrades exist for each tag

* Update downgrading.rst

* Use git-log to find tags which are ancestors of the current commit

Co-authored-by: Vamshi Surabhi <0x777@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c/server Related to server

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants