add index for user_id column on highlight table

This commit is contained in:
Hongbo Wu
2024-06-06 17:33:42 +08:00
parent 70bc136d15
commit e9f9f5dded
3 changed files with 22 additions and 5 deletions

View File

@ -459,16 +459,19 @@ describe('Highlights API', () => {
const label1 = await createLabel(labelName1, '#ff0001', user.id) const label1 = await createLabel(labelName1, '#ff0001', user.id)
// save labels in highlights // save labels in highlights
await saveLabelsInHighlight([label], existingHighlights[0].id, user.id) await saveLabelsInHighlight(
await saveLabelsInHighlight([label1], existingHighlights[1].id, user.id) [label, label1],
existingHighlights[0].id,
user.id
)
const res = await graphqlRequest(query, authToken, { const res = await graphqlRequest(query, authToken, {
query: `label:"${labelName}" label:"${labelName1}"`, query: `label:"${labelName}" label:"${labelName1}"`,
}).expect(200) }).expect(200)
const highlights = res.body.data.highlights.edges as Array<HighlightEdge> const highlights = res.body.data.highlights.edges as Array<HighlightEdge>
expect(highlights).to.have.lengthOf(2) expect(highlights).to.have.lengthOf(1)
expect(highlights[1].node.labels?.[0].name).to.eq(labelName) expect(highlights[0].node.labels?.[0].name).to.eq(labelName)
expect(highlights[0].node.labels?.[0].name).to.eq(labelName1) expect(highlights[0].node.labels?.[1].name).to.eq(labelName1)
await deleteLabels([label.id, label1.id], user.id) await deleteLabels([label.id, label1.id], user.id)
}) })

View File

@ -0,0 +1,5 @@
-- Type: DO
-- Name: add_index_on_highlight_user_id
-- Description: Add index on user_id column to the highlight table
CREATE INDEX CONCURRENTLY IF NOT EXISTS highlight_user_id_idx ON omnivore.highlight (user_id);

View File

@ -0,0 +1,9 @@
-- Type: UNDO
-- Name: add_index_on_highlight_user_id
-- Description: Add index on user_id column to the highlight table
BEGIN;
DROP INDEX IF EXISTS highlight_user_id_idx;
COMMIT;