Open manishrjain opened 2 years ago
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.
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
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