Skip to content

Commit ab8f672

Browse files
sadiqkhojaktuite
andauthored
Added indices for entities related tables (getodk#726)
Co-authored-by: Kathleen Tuite <[email protected]>
1 parent 8f80675 commit ab8f672

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Copyright 2023 ODK Central Developers
2+
// See the NOTICE file at the top-level directory of this distribution and at
3+
// https://github.com/getodk/central-backend/blob/master/NOTICE.
4+
// This file is part of ODK Central. It is subject to the license terms in
5+
// the LICENSE file found in the top-level directory of this distribution and at
6+
// https://www.apache.org/licenses/LICENSE-2.0. No part of ODK Central,
7+
// including this file, may be copied, modified, propagated, or distributed
8+
// except according to the terms contained in the LICENSE file.
9+
10+
const up = async (db) => {
11+
await db.schema.table('entities', (en) => {
12+
en.index([ 'datasetId', 'createdAt', 'id' ]);
13+
});
14+
15+
await db.schema.table('entity_defs', (ed) => {
16+
ed.index(['entityId', 'current']);
17+
ed.index('submissionDefId');
18+
});
19+
};
20+
21+
22+
const down = async (db) => {
23+
await db.schema.table('entities', (en) => {
24+
en.dropIndex([ 'datasetId', 'createdAt', 'id' ]);
25+
});
26+
27+
await db.schema.table('entity_defs', (ed) => {
28+
ed.dropIndex(['entityId', 'current']);
29+
ed.dropIndex('submissionDefId');
30+
});
31+
};
32+
33+
module.exports = { up, down };
34+

0 commit comments

Comments
 (0)