-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle offline entities with baseVersion, trunkVersion, and branchId (#…
…1154) * Parse trunkVersion and branchId from entity submissions * Adding submission backlog, check for held submission following this one * Improving out of order processing for complex branches * Problem case in a test * Improve logic to process following submission * Make branchId, branchBaseVersion, trunkVersion readable thru api * small changes to backlog schema based on feedback * Fixing more edge cases * unit tests about parsing branch and trunk values from submissions * More tests * Refactor offline entity tests to use more api * Factor out baseVersion computation * Updates from final code review
- Loading branch information
Showing
9 changed files
with
937 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
lib/model/migrations/20240607-01-add-offline-entity-branch-trunk-info.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright 2024 ODK Central Developers | ||
// See the NOTICE file at the top-level directory of this distribution and at | ||
// https://github.com/getodk/central-backend/blob/master/NOTICE. | ||
// This file is part of ODK Central. It is subject to the license terms in | ||
// the LICENSE file found in the top-level directory of this distribution and at | ||
// https://www.apache.org/licenses/LICENSE-2.0. No part of ODK Central, | ||
// including this file, may be copied, modified, propagated, or distributed | ||
// except according to the terms contained in the LICENSE file. | ||
|
||
const up = async (db) => { | ||
await db.raw(`ALTER TABLE entity_defs | ||
ADD COLUMN "branchId" UUID, | ||
ADD COLUMN "trunkVersion" INT4, | ||
ADD COLUMN "branchBaseVersion" INT4`); | ||
}; | ||
|
||
const down = (db) => db.raw(`ALTER TABLE entity_defs | ||
DROP COLUMN "branchId", | ||
DROP COLUMN "trunkVersion", | ||
DROP COLUMN "branchBaseVersion" | ||
`); | ||
|
||
module.exports = { up, down }; |
31 changes: 31 additions & 0 deletions
31
lib/model/migrations/20240607-02-add-submission-backlog.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright 2024 ODK Central Developers | ||
// See the NOTICE file at the top-level directory of this distribution and at | ||
// https://github.com/getodk/central-backend/blob/master/NOTICE. | ||
// This file is part of ODK Central. It is subject to the license terms in | ||
// the LICENSE file found in the top-level directory of this distribution and at | ||
// https://www.apache.org/licenses/LICENSE-2.0. No part of ODK Central, | ||
// including this file, may be copied, modified, propagated, or distributed | ||
// except according to the terms contained in the LICENSE file. | ||
|
||
const up = async (db) => { | ||
await db.raw(`CREATE TABLE entity_submission_backlog ( | ||
"submissionId" INT4 NOT NULL, | ||
"submissionDefId" INT4 NOT NULL, | ||
"branchId" UUID NOT NULL, | ||
"branchBaseVersion" INT4 NOT NULL, | ||
"loggedAt" TIMESTAMPTZ(3) NOT NULL, | ||
CONSTRAINT fk_submission_defs | ||
FOREIGN KEY("submissionDefId") | ||
REFERENCES submission_defs(id) | ||
ON DELETE CASCADE, | ||
CONSTRAINT fk_submissions | ||
FOREIGN KEY("submissionId") | ||
REFERENCES submissions(id) | ||
ON DELETE CASCADE, | ||
UNIQUE ("branchId", "branchBaseVersion") | ||
)`); | ||
}; | ||
|
||
const down = (db) => db.raw('DROP TABLE entity_submission_backlog'); | ||
|
||
module.exports = { up, down }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.