Skip to content

Commit 5079e2b

Browse files
committed
WIP improve legislation RAG system
1 parent c5b0b6a commit 5079e2b

File tree

7 files changed

+6403
-227
lines changed

7 files changed

+6403
-227
lines changed

lib/db/legislation/schema.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ export const crossReferences = legislationSchema.table(
630630
sourceSectionLabel: varchar("source_section_label", { length: 50 }),
631631
// Target (what is being referenced) - raw from XML
632632
targetType: varchar("target_type", { length: 20 }).notNull(), // "act" or "regulation"
633-
targetRef: varchar("target_ref", { length: 100 }).notNull(), // Raw link text (e.g., "A-2", "SOR-86-946")
633+
targetRef: varchar("target_ref", { length: 100 }).notNull(), // Raw link (e.g., "C-46", "SOR-2000-1")
634634
targetSectionRef: varchar("target_section_ref", { length: 50 }),
635635
// Display text for the reference
636636
referenceText: text("reference_text"),
@@ -642,6 +642,7 @@ export const crossReferences = legislationSchema.table(
642642
index("cross_references_source_regulation_id_idx").on(
643643
table.sourceRegulationId
644644
),
645+
index("cross_references_target_type_idx").on(table.targetType),
645646
index("cross_references_target_ref_idx").on(table.targetRef),
646647
]
647648
);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ALTER TABLE "rag"."leg_resources" DROP CONSTRAINT "leg_resources_source_type_check";--> statement-breakpoint
2+
CREATE INDEX "cross_references_target_type_idx" ON "legislation"."cross_references" USING btree ("target_type");--> statement-breakpoint
3+
ALTER TABLE "rag"."leg_resources" ADD CONSTRAINT "leg_resources_source_type_check" CHECK ("rag"."leg_resources"."source_type" IN ('act', 'act_section', 'regulation', 'regulation_section', 'defined_term', 'preamble', 'treaty', 'cross_reference', 'table_of_provisions', 'signature_block', 'related_provisions', 'footnote', 'schedule', 'marginal_note'));

0 commit comments

Comments
 (0)