subql
subql copied to clipboard
[$3,500 in kSQT] Schema Migrations
Description
Currently when users wish to change their project schema they need to reindex their project. This can be very slow. In order to improve this we should support schema migrations. These migrations are automated based on changes in project graphql schemas.
The reason for migrations being automated is driven by 2 main reasons:
- It limits security issues by having a narrow scope for migrations. Allowing raw SQL would be a large security issue.
- It limits really heavy migrations such as modifying large amounts of data.
Requirements
- Migrations should allow the following features:
- Add/remove colums
- Add/remove indexes and multi-column indexes
- Add/remove tables
- Changing a field type should drop the column and create a new one
- Migrations should only run on project upgrades
- Migrations should be reversed when rewinding and a project is downgraded
- A way to test migrations buy running through all the projects upgrades on an empty db