Comments (10)
This is semantically true, but will it actually be true in the database? When we add editable submissions, will the instanceId of the edit be different, or will we have some sort of version increment? If the former, how do we relate those records together?
Or will we edit in place? (I am queasy about that.)
from central-backend.
Your notes sound like they intersect with stories 5.07a (update a submission via web interface) and 5.23 (record submission action audit log). I'm not totally sure how we'll store that log or whether we'd store each submission update as a separate version of the submission. (For example, one way we could end up going is to store the latest version of the submission in the submissions
table, then the log of changes elsewhere. I think this is how the paper_trail
Ruby gem implements it.) With that in mind, since submission edits are down the road (they aren't a "must"), I think we need a solution for now so that duplicate submissions aren't saved to the database. One option might be to add a simple database constraint for now, then rethink it once we get to those two stories.
from central-backend.
Database constraints are extraordinarily hard to walk back. We can't punt this solution.
from central-backend.
What makes a database constraint hard to walk back? I'd definitely also be happy with a solution other than a database constraint. Would you recommend checking for duplicates in the JavaScript instead? Or is there a better third solution?
from central-backend.
No, constraints should always be enforced by the database. But you should set them up correctly from the beginning, or else you're going to have a zoo of different conflicting user databases which may or may not conform with the new constraint you wish to inject.
from central-backend.
It sounds to me like three different implementations of 5.07a/5.23 are currently on the table, and at least so far, all of them seem consistent with adding a constraint on formId, instanceId
for now:
- The first option is that submission updates are stored as new rows of the
submissions
table with a new instance ID and maybe a link to the previous version of the submission.formId, instanceId
would uniquely identify rows in this case. - The second option is that submission updates are stored as new rows of the
submissions
table with the same instance ID but with an incremental version (say this is stored on aversion
column).formId, instanceId, version
would uniquely identify rows. This would be consistent with adding a constraint onformId, instanceId
now, because when we'd add submission versions for the first time, all existing rows would haveversion = 1
. - The third option is that submission updates update existing rows of the
submissions
table in place, but a log of the changes are stored elsewhere (this is what thepaper_trail
Ruby gem does).formId, instanceId
would uniquely identify rows.
I'm thinking that if we add a constraint on formId, instanceId
now, it would protect against duplicates, and it seems like it's consistent with the implementations we're currently considering for 5.07a/5.23.
Do you think there's a better solution for v1 to prevent duplicate submissions? Or do you think we should move up the timeline for 5.07a/5.23, make those two "musts," and decide how to implement them now?
from central-backend.
@clint-tseng I agree it's really hard/impossible/a bad idea to ADD constraints but I think it's harmless to remove them?
This is not necessarily related to the DB structure but just so you know, ODK XForms has a mechanism for updating instances and it is most similar to @matthew-white's 2 above. Search for deprecatedID
here.
from central-backend.
from central-backend.
I would lean toward punting on 5.07a/5.23 and for now adding a constraint on formId, submissionId
, if folks are comfortable with that.
from central-backend.
I will note that is possible and often necessary to consider future tasks without upgrading their priority or working on them immediately. I am queasy about ignoring this and applying the constraint but cannot identify the exact problem, so I'll just apply the constraint.
from central-backend.
Related Issues (20)
- Different port numbers for pyxform-http HOT 1
- Update dependencies for v2023.5 HOT 3
- Refactor worker/entity tests HOT 1
- Get rid of `submissionCreate` from GET entities/:uuid/audits HOT 2
- GET entities/:uuid returns 304 after resolve HOT 6
- Update API docs for 2023.5
- "Not found" Problem after request to submissions.csv.zip
- Update dependencies for v2024.1
- Frames used in migrations HOT 6
- Add system property like __id back to entity CSV attachment? HOT 1
- Benchmark bulk entity create API HOT 7
- Update API docs for v2024.1
- entities."deletedAt" has different type from other timestamp columns
- API documentation inconsistencies HOT 2
- Get off of slonik fork HOT 1
- OIDC login fails due to Authentik sending state QS and node-openid-client failing a check
- Streamline Form creation/update/publish paths to better fit with Entities
- cli.js output is inconsistently not JSON HOT 1
- Reap singleUse actors HOT 1
- Questions about actors with formview assignments
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from central-backend.