avniproject / avni-models

Avni data model to be used by front end clients
https://avniproject.org
GNU Affero General Public License v3.0
1 stars 4 forks source link

Fix app load after upgradation of avni-client from old versions to 10.0 #54

Closed himeshr closed 2 weeks ago

himeshr commented 2 weeks ago

Issue

We have introduces several new fields in openchs-models, which are used in new CustomDashboards and related entities, with assumption that they are optional or so and would have values setup correctly on first sync post update.

But, in-case the org has CustomDashboard set as Primary Dashboard and their app gets upgraded, then after that App load would break everytime, preventing user from completing first time sync and hence result in him being forced to perform fresh sync.

AC

Perform all new Realm Entities fields initialization appropriately, so that app load does not fail after app upgrade without performing any sync post update.

Tech details

Based o code diff of 9.3 branch with 10.0 in Models repo, we found following places where we need to handle initialization of new columns of Realm Entities as part of Schema Migration for new CustomDashboardReportCards (Version 197):

alter table standard_report_card_type add column type varchar(100) null; update standard_report_card_type set type = replace(initcap(description), ' ', '') where 1 = 1; alter table standard_report_card_type alter column type set not null;



- ~DashboardFilterConfig => SubjectType // Mystery~
- ~ReportCard =>~
    - ~standardReportCardInputSubjectTypes: {type: "list", objectType: "SubjectType"}, //EmptyArray~
    - ~standardReportCardInputPrograms: {type: "list", objectType: "Program"},//EmptyArray~
    - ~standardReportCardInputEncounterTypes: {type: "list", objectType: "EncounterType"}, //EmptyArray~
    - ~standardReportCardInputRecentDurationJSON: {type: "string", optional: true} // "{\"value\":\"1\",\"unit\":\"days\"}"~
himeshr commented 2 weeks ago

Was unable to find any issues with configuring

As seen in https://prerelease.avniproject.org/#/appDesigner/dashboard/603/show