Skip to content
Closed
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
40fc569
Add technical planning for VIBE-316: Refactor artefact search extract…
github-actions[bot] Jan 13, 2026
0b4022e
feat(VIBE-316): Refactor artefact search extraction and subscription …
KianKwa Jan 19, 2026
fea592d
Merge remote-tracking branch 'origin/master' into feature/VIBE-316-re…
KianKwa Jan 20, 2026
e705dc2
Removed script
KianKwa Jan 20, 2026
6b509fc
fix(VIBE-316): Fix TypeScript errors from schema changes
KianKwa Jan 20, 2026
43a17dd
Add list search config migration
KianKwa Jan 20, 2026
c30929d
feat(VIBE-316): Remove locationId column from subscription table
KianKwa Jan 20, 2026
8e7ba8b
feat(VIBE-316): Register list-search-config module in web app
KianKwa Jan 20, 2026
50b7a93
fix(VIBE-316): Fix list-search-config route parameter syntax
KianKwa Jan 20, 2026
0e7d218
fix: Rename Nunjucks template to avoid bracket syntax issues
KianKwa Jan 20, 2026
09eaa5a
fix: Add list-search-config moduleRoot to Nunjucks template paths
KianKwa Jan 20, 2026
f010f71
fix: Correct Nunjucks template layout and block names
KianKwa Jan 20, 2026
b708199
fix: Change redirect to go back to same page after save
KianKwa Jan 20, 2026
9b17abe
fix: Add explicit action attribute to form
KianKwa Jan 20, 2026
c88a263
fix: Add explicit type='submit' to button
KianKwa Jan 20, 2026
d258885
fix: Replace govukButton macro with plain HTML button
KianKwa Jan 20, 2026
3f12884
Add list type configuration pages
KianKwa Jan 20, 2026
93e3763
Move list search config pages
KianKwa Jan 20, 2026
ce02681
Update unit tests
KianKwa Jan 20, 2026
aa595ec
Restructure code
KianKwa Jan 20, 2026
6e50afa
Update logic
KianKwa Jan 20, 2026
db4d6db
Removed test file
KianKwa Jan 20, 2026
9b471f0
Fixed failing unit and e2e tests
KianKwa Jan 20, 2026
4b291b5
Add e2e tests for manage list types
KianKwa Jan 20, 2026
cf2fc1b
Code restructuring
KianKwa Jan 21, 2026
72ba7da
Fix security vuln
KianKwa Jan 21, 2026
dfd7c8d
Add subscription by case name and case number
KianKwa Jan 26, 2026
1211b85
Update tests and fix security vuln
KianKwa Jan 26, 2026
b19aed5
Fix issue with duplicate case name in pending subscriptions
KianKwa Jan 26, 2026
575425c
Fixed failing e2e tests
KianKwa Jan 26, 2026
9c14f67
Verified pages code tidy up
KianKwa Jan 26, 2026
d203b02
Code refactoring
KianKwa Jan 26, 2026
6a3944e
Fixed failing unit test
KianKwa Jan 26, 2026
234b0a6
FIx issue with duplicated case subscriptions
KianKwa Jan 26, 2026
f6ba7c5
Removed redundant logs
KianKwa Jan 26, 2026
d48b005
Update Welsh translations
KianKwa Jan 26, 2026
3fecac1
Lint fix
KianKwa Jan 26, 2026
570dbe7
Update id to use uuid
KianKwa Jan 27, 2026
08bd06a
Merge branch 'feature/VIBE-316-refactor-artefact-search-extraction-su…
KianKwa Jan 27, 2026
db463d8
Update id to use uuid
KianKwa Jan 27, 2026
00bffba
Merge branch 'feature/VIBE-316-refactor-artefact-search-extraction-su…
KianKwa Jan 27, 2026
59f315b
Merge branch 'master' into feature/VIBE-316-refactor-artefact-search-…
KianKwa Feb 17, 2026
cd1a23a
Fix merge issue
KianKwa Feb 17, 2026
74f3056
Merge remote-tracking branch 'origin/master' into feature/VIBE-316-re…
KianKwa Feb 17, 2026
b9d9278
Merge branch 'feature/VIBE-316-refactor-artefact-search-extraction-su…
KianKwa Feb 17, 2026
f450188
Fix merge issue
KianKwa Feb 17, 2026
76627a0
Merge branch 'feature/VIBE-316-refactor-artefact-search-extraction-su…
KianKwa Feb 17, 2026
c1f1db8
Fix unit test issue
KianKwa Feb 17, 2026
6ea83b2
Fix unit test issue
KianKwa Feb 17, 2026
10904ff
Add validation to list-search-config page
KianKwa Feb 18, 2026
16d3d4f
Fixed security vuln
KianKwa Feb 18, 2026
630d3ef
Merge branch 'feature/VIBE-316-refactor-artefact-search-extraction-su…
KianKwa Feb 18, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
-- CreateTable
CREATE TABLE "list_search_config" (
"id" TEXT NOT NULL,
"list_type_id" INTEGER NOT NULL,
"case_number_field_name" VARCHAR(100) NOT NULL,
"case_name_field_name" VARCHAR(100) NOT NULL,
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(3) NOT NULL,

CONSTRAINT "list_search_config_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE UNIQUE INDEX "list_search_config_list_type_id_key" ON "list_search_config"("list_type_id");
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
-- DropForeignKey
ALTER TABLE "subscription" DROP CONSTRAINT IF EXISTS "subscription_location_id_fkey";

-- DropIndex
DROP INDEX IF EXISTS "idx_subscription_location";

-- DropIndex
DROP INDEX IF EXISTS "unique_user_location";

-- AlterTable
ALTER TABLE "subscription"
ADD COLUMN "search_type" VARCHAR(50) NOT NULL,
ADD COLUMN "search_value" TEXT NOT NULL,
DROP COLUMN IF EXISTS "location_id";

-- CreateTable
CREATE TABLE "artefact_search" (
"id" TEXT NOT NULL,
"artefact_id" UUID NOT NULL,
"case_number" TEXT,
"case_name" TEXT,
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,

CONSTRAINT "artefact_search_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE INDEX "artefact_search_artefact_id_idx" ON "artefact_search"("artefact_id");

-- CreateIndex
CREATE INDEX "idx_subscription_search" ON "subscription"("search_type", "search_value");

-- CreateIndex
CREATE UNIQUE INDEX "subscription_user_id_search_type_search_value_key" ON "subscription"("user_id", "search_type", "search_value");

-- AddForeignKey
ALTER TABLE "artefact_search" ADD CONSTRAINT "artefact_search_artefact_id_fkey" FOREIGN KEY ("artefact_id") REFERENCES "artefact"("artefact_id") ON DELETE CASCADE ON UPDATE CASCADE;
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-- AlterTable
ALTER TABLE "subscription" ADD COLUMN "case_name" TEXT,
ADD COLUMN "case_number" TEXT;

-- CreateIndex
CREATE INDEX "idx_subscription_case_number" ON "subscription"("case_number");
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- DropForeignKey
ALTER TABLE "notification_audit_log" DROP CONSTRAINT "notification_audit_log_subscription_id_fkey";

-- AddForeignKey
ALTER TABLE "notification_audit_log" ADD CONSTRAINT "notification_audit_log_subscription_id_fkey" FOREIGN KEY ("subscription_id") REFERENCES "subscription"("subscription_id") ON DELETE CASCADE ON UPDATE CASCADE;
34 changes: 24 additions & 10 deletions apps/postgres/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,38 @@ datasource db {
}

model Artefact {
artefactId String @id @default(uuid()) @map("artefact_id") @db.Uuid
locationId String @map("location_id")
listTypeId Int @map("list_type_id")
contentDate DateTime @map("content_date") @db.Date
artefactId String @id @default(uuid()) @map("artefact_id") @db.Uuid
locationId String @map("location_id")
listTypeId Int @map("list_type_id")
contentDate DateTime @map("content_date") @db.Date
sensitivity String
language String
displayFrom DateTime @map("display_from")
displayTo DateTime @map("display_to")
lastReceivedDate DateTime @default(now()) @map("last_received_date")
isFlatFile Boolean @map("is_flat_file")
displayFrom DateTime @map("display_from")
displayTo DateTime @map("display_to")
lastReceivedDate DateTime @default(now()) @map("last_received_date")
isFlatFile Boolean @map("is_flat_file")
provenance String
supersededCount Int @default(0) @map("superseded_count")
noMatch Boolean @default(false) @map("no_match")
supersededCount Int @default(0) @map("superseded_count")
noMatch Boolean @default(false) @map("no_match")
ingestionLogs IngestionLog[]
artefactSearches ArtefactSearch[]

@@map("artefact")
}

model ArtefactSearch {
id String @id @default(cuid())
artefactId String @map("artefact_id") @db.Uuid
caseNumber String? @map("case_number")
caseName String? @map("case_name")
createdAt DateTime @default(now()) @map("created_at")

artefact Artefact @relation(fields: [artefactId], references: [artefactId], onDelete: Cascade)

@@index([artefactId])
@@map("artefact_search")
}

model User {
userId String @id @default(uuid()) @map("user_id") @db.Uuid
email String @db.VarChar(255)
Expand Down
57 changes: 57 additions & 0 deletions apps/postgres/scripts/migrate-subscriptions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { prisma } from "@hmcts/postgres";

async function migrateSubscriptions() {
console.log("Starting subscription data migration...");

const subscriptions = await prisma.subscription.findMany({
where: {
searchType: null
}
});

console.log(`Found ${subscriptions.length} subscriptions to migrate`);

let migratedCount = 0;
let errorCount = 0;

for (const subscription of subscriptions) {
try {
if (subscription.locationId) {
await prisma.subscription.update({
where: {
subscriptionId: subscription.subscriptionId
},
data: {
searchType: "LOCATION_ID",
searchValue: subscription.locationId.toString()
}
});
migratedCount++;
}
} catch (error) {
console.error(`Failed to migrate subscription ${subscription.subscriptionId}:`, error);
errorCount++;
}
}

console.log(`Migration completed:`);
console.log(` - Successfully migrated: ${migratedCount}`);
console.log(` - Errors: ${errorCount}`);

const verifyCount = await prisma.subscription.count({
where: {
searchType: "LOCATION_ID"
}
});

console.log(`Verification: ${verifyCount} subscriptions now have searchType='LOCATION_ID'`);
}

migrateSubscriptions()
.catch((error) => {
console.error("Migration failed:", error);
process.exit(1);
})
.finally(async () => {
await prisma.$disconnect();
});
5 changes: 3 additions & 2 deletions apps/postgres/src/schema-discovery.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@
expect(Array.isArray(result)).toBe(true);
});

it("should return array with subscriptions, location, and notifications schemas", () => {
it("should return array with subscriptions, location, notifications, and list-search-config schemas", () => {
const result = getPrismaSchemas();
expect(result.length).toBe(3);
expect(result.length).toBe(4);
expect(result.some((path) => path.includes("subscriptions"))).toBe(true);

Check failure on line 18 in apps/postgres/src/schema-discovery.test.ts

View workflow job for this annotation

GitHub Actions / Test Changed Packages

src/schema-discovery.test.ts > Schema Discovery > getPrismaSchemas > should return array with subscriptions, location, notifications, and list-search-config schemas

AssertionError: expected false to be true // Object.is equality - Expected + Received - true + false ❯ src/schema-discovery.test.ts:18:69
expect(result.some((path) => path.includes("location"))).toBe(true);
expect(result.some((path) => path.includes("notifications"))).toBe(true);
expect(result.some((path) => path.includes("list-search-config"))).toBe(true);
});
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

it("should return a new array on each call", () => {
Expand Down
5 changes: 3 additions & 2 deletions apps/postgres/src/schema-discovery.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// Schema discovery functionality for module integration
import { prismaSchemas as listSearchConfigSchemas } from "@hmcts/list-search-config/config";
import { prismaSchemas as locationSchemas } from "@hmcts/location/config";
import { prismaSchemas as notificationsSchemas } from "@hmcts/notifications/config";
import { prismaSchemas as subscriptionsSchemas } from "@hmcts/subscriptions/config";
import { prismaSchemas as subscriptionSchemas } from "@hmcts/subscription/config";

export function getPrismaSchemas(): string[] {
return [subscriptionsSchemas, locationSchemas, notificationsSchemas];
return [subscriptionSchemas, locationSchemas, notificationsSchemas, listSearchConfigSchemas];
}
Loading
Loading