-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate forms to use offline entities #692
Comments
Currently, I'm thinking that the only thing that the database migration should do is add events to the audit log like This strategy was used previously to backfill Enketo IDs for forms and form drafts.
I think this is another advantage of using a worker. If a worker tries to create a new version of a form, and it fails for some reason, then that'd be handled in the usual way and won't bring anything down. On the other hand, if a database migration fails, then the server won't be able to complete the upgrade to .2. |
Entity spec version history: Questions: 1. Maybe just upgrade 2023.1 (entity update) forms
I was first thinking about this when considering the 2. Published form only vs. draft only vs. both vs. other edge cases Looking back at the PR that upgraded forms with the For what we're doing now, I think we just want to do one action per Form. Here are the cases: a. Published form only: introduce new version that has xml with new entity spec and probably a version suffix, carry xlsx attachment over Does that seem right? |
That makes sense to me. 👍 I think the idea of updating as few forms as possible is nice. Targeting forms with an
That also makes sense to me. 👍
I wasn't so sure initially about updating in place, but now I think that it's the least confusing thing. I think we should carry forward the XLSForm of the draft that's being replaced. The other cases make sense to me too. So does the idea of one action per form rather than one action per form def. |
Rereading this issue, I'm not sure why I thought a non-offline entity update would result in an entity processing error. As far as I know, we're not planning to require that all entity updates via submission be offline updates. |
Right! It's totally fine for a client to still have old form versions and be submitting updates that are not offline-aware. In that case the client won't have an offline representation and everything will be consistent. |
Tested with Success! |
One issue around offline entities that we've discussed is what would happen if a Central project has a mix of forms such that some forms use offline entities, while others don't. That could end up being a very confusing experience to data collectors. For example, imagine a project that has four forms and two entity lists: form A updates entity list X, form B also updates X, form C updates entity list Y, and form D reads from both X and Y (but doesn't update them). There are a number of possibilities then with the potential for confusion:
The solution to this issue that we've discussed is to migrate all existing forms that modify
(or even use?)entities. The idea is to automatically convert forms to the latest entities spec (2024.1) so that they are all capable of making offline changes. If they are all converted at the same time, then clients shouldn't end up with a mix of forms, avoiding this issue.Once forms are migrated, we will need to check going forward that all form definitions that are uploaded (for new or existing forms) are capable of making offline changes. Specifically, we should reject form definitions that specify an entities spec before 2024.1. That shouldn't be an issue for users using XLSForms (things should work seamlessly), because pyxform will automatically specify 2024.1. (UPDATE: This will be done separately as part of issue #730.)
In the future, users may wish to opt out of offline entities. We're thinking that that's something that would be configured on the client (perhaps via a QR code setting) and not something that the XForm would determine. In other words, even if we migrate forms now, that doesn't close off the possibility of users opting out of offline entities in the future.
I think we should convert both the current form def (the most recently published def) and the form draft. That's what we do when we convert forms when enabling managed encryption. Central will autogenerate the form version string as part of the migration. If there is an XLSForm on the form def, Central should carry it forward to the migrated form def (related: #729).
This might not be needed, but I personally think that it'd be nice if Frontend were to show a message above the forms table when the forms table includes a form that has been recently migrated. The message would inform users that their form definitions have been changed and will need to be re-downloaded to clients. If the autogenerated form version string includes a particular prefix or suffix, then Frontend could check for that prefix/suffix and a timestamp in the last X days when determining whether to show the message.
One thing to note is that even if Central migrates all forms at once, there are rare cases where a client could end up with a mix of forms. That could happen if the form download process is interrupted partway through such that only some forms are updated. If a client does end up with a mix of forms, then it's possible that a submission would specify a non-offline entity update that would result in an entity processing error on the server. That should be a rare case, but once we implement #688, such errors would be surfaced in Frontend.
Another thing to think about is forms that used to be allowed in Central, but are not anymore. For example, it's no longer possible to upload a form definition without a
<meta>
field, but a server could have an old form definition without a<meta>
field. It's possible that such a form definition would cause the migration to fail, so we should check that case. Could we just skip forms like that or bypass requirements like the existence of a<meta>
field? How does that work currently when enabling managed encryption? Another example of a form that used to be allowed is a form definition that includes an<entity>
field without any action attribute (neithercreate
norupdate
). Such form definitions were never valid according to the entities spec and would be rejected on upload today, but at some point, it was possible to upload such a form.The text was updated successfully, but these errors were encountered: