subql icon indicating copy to clipboard operation
subql copied to clipboard

Refactor StoreService, StoreCacheService and ProjectService to have a single source of truth

Open stwiname opened this issue 1 year ago • 0 comments

Description

With migrations now supported there are multiple places where we keep references to the current models. They are updated at different times and in different places. This has led to entangling of some dependencies on other services.

This should be refactored to simplify the code and reduce chances of bugs.

There are currently 3 places where the current models/schema are needed:

  • StoreCacheService to provide CachedModels in the store
  • StoreService sequelize hooks to use the right block height when querying/updating data
  • StoreService _modelIndexedFields and _modelsRelations for POI and store methods

Solution

When a migration is run it should return all the required information (sequelize models, gql schema) to update the necessary places. This should remove the need for the SchemaMigraionService and Migration to depend on the StoreService.

There should be a new method on the StoreService that is called after a migration that updates everything correctly and this should be the only way to set fields that depend on the current models/schema

stwiname avatar Feb 25 '24 22:02 stwiname