Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Figure out type / field renaming #40

Open
manishrjain opened this issue Apr 5, 2022 · 2 comments
Open

Figure out type / field renaming #40

manishrjain opened this issue Apr 5, 2022 · 2 comments
Labels
enhancement New feature or request
Milestone

Comments

@manishrjain
Copy link
Contributor

manishrjain commented Apr 5, 2022

We need a solution for renaming a field or a type, without having to rewrite the entire data.

P.S. Have a look at how EdgeDB does this: https://www.edgedb.com/showcase/migrations

@manishrjain manishrjain added the enhancement New feature or request label Apr 5, 2022
@manishrjain manishrjain added this to the post-v1 milestone Apr 5, 2022
@benwoodward
Copy link

Fauna have a good tool for this.

https://github.com/fauna-labs/fauna-schema-migrate

Ideally every schema change would be accomplished via a generated migration script that is saved in a commit.

This is how it works in Rails (https://guides.rubyonrails.org/active_record_migrations.html) - you run a CLI command to generate a new migration, it creates a timestamped script, you edit the script and add commands for modifying the schema as well as any logic you might need for manipulating data. Then you run the migrate command and it will sequentially run the migrations up until the latest.

The benefit to this is that team members can easily be on the same schema regardless of what commit they are on.

@jdgamble555
Copy link

I imagine you're going to have a graphql endpoint and an admin endpoint.

Why not just do something like this on the admin endpoint:

mutation {
  renameType('Post', 'Tweet')
}

to rename a Type, and

mutation {
  Post {
    renameField('updated_at', 'updatedAt')
  }
}

to rename a field.

Under the hood it uses the dql mutation

J

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants