Skip to content

Commit

Permalink
chore: add rag table migrations (#385)
Browse files Browse the repository at this point in the history
  • Loading branch information
mantagen authored Nov 26, 2024
1 parent 69b2371 commit 6af7fad
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 10 deletions.
2 changes: 2 additions & 0 deletions packages/db/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
"db-migrate": "pnpm with-env prisma migrate dev",
"db-migrate:dev": "pnpm with-env prisma migrate dev",
"db-migrate:status": "pnpm with-env prisma migrate status",
"db-migrate:status:stg": "DB_ENV=stg doppler run --config stg -- prisma migrate status",
"db-migrate:status:prd": "DB_ENV=prd doppler run --config prd -- prisma migrate status",
"db-migrate-resolve-applied:prd": "doppler run --config prd -- prisma migrate resolve --applied",
"db-migrate-resolve-applied:stg": "doppler run --config stg -- prisma migrate resolve --applied",
"db-migrate-resolve-rolled-back:prd": "doppler run --config prd -- prisma migrate resolve --rolled-back",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
Warnings:
- Added the required column `oak_lesson_slug` to the `rag_lesson_plans` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE "ingest"."ingest" ALTER COLUMN "config" DROP DEFAULT;

-- AlterTable
ALTER TABLE "rag"."rag_lesson_plans" ADD COLUMN "is_published" BOOLEAN NOT NULL DEFAULT false,
ADD COLUMN "oak_lesson_slug" TEXT NOT NULL,
ALTER COLUMN "oak_lesson_id" DROP NOT NULL;

-- CreateIndex
CREATE INDEX "idx_rag_lesson_plans_published_key_stage_subject" ON "rag"."rag_lesson_plans"("is_published", "key_stage_slug", "subject_slug");
25 changes: 15 additions & 10 deletions packages/db/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -1117,16 +1117,21 @@ model IngestError {
}

model RagLessonPlan {
id String @id @default(cuid())
oakLessonId Int @map("oak_lesson_id")
ingestLessonId String? @map("ingest_lesson_id")
lessonPlan Json @map("lesson_plan") @db.JsonB
subjectSlug String @map("subject_slug")
keyStageSlug String @map("key_stage_slug")
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
ragLessonPlanPart RagLessonPlanPart[]
id String @id @default(cuid())
oakLessonId Int? @map("oak_lesson_id")
oakLessonSlug String @map("oak_lesson_slug")
ingestLessonId String? @map("ingest_lesson_id")
lessonPlan Json @map("lesson_plan") @db.JsonB
subjectSlug String @map("subject_slug")
keyStageSlug String @map("key_stage_slug")
isPublished Boolean @default(false) @map("is_published")
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
ragLessonPlanParts RagLessonPlanPart[]
// The following index is not supported by prisma so is applied manually in ./additions/rag_lesson_plans_unique_slug_index.sql
// @@index([oakLessonSlug], name: "unique_published_oak_lesson_slug", dbIndex: false) @db.PartialIndex("is_published = TRUE")
@@index([isPublished, keyStageSlug, subjectSlug], name: "idx_rag_lesson_plans_published_key_stage_subject")
@@map("rag_lesson_plans")
@@schema("rag")
}
Expand Down

0 comments on commit 6af7fad

Please sign in to comment.