Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 0 additions & 16 deletions drizzle/0008_audit_logs.sql

This file was deleted.

83 changes: 0 additions & 83 deletions drizzle/0013_silky_gateway.sql

This file was deleted.

29 changes: 29 additions & 0 deletions drizzle/0017_wild_klaw.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
CREATE TABLE "audit_logs" (
"id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "audit_logs_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),
"actorEmail" varchar(255) NOT NULL,
"targetEmail" varchar(255),
"action" varchar(100) NOT NULL,
"resourceType" varchar(50) NOT NULL,
"resourceId" varchar(255),
"metadata" text,
"createdAt" timestamp DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE TABLE "video_jobs" (
"id" varchar(64) PRIMARY KEY NOT NULL,
"user_email" varchar(255) NOT NULL,
"status" varchar(20) DEFAULT 'queued' NOT NULL,
"progress" integer DEFAULT 0 NOT NULL,
"step" varchar(255),
"video_type" varchar(20),
"video_url" text,
"error" text,
"created_at" timestamp DEFAULT now() NOT NULL,
"updated_at" timestamp DEFAULT now() NOT NULL
);
--> statement-breakpoint
ALTER TABLE "video_jobs" ADD CONSTRAINT "video_jobs_user_email_users_email_fk" FOREIGN KEY ("user_email") REFERENCES "public"."users"("email") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
CREATE INDEX "audit_actor_idx" ON "audit_logs" USING btree ("actorEmail");--> statement-breakpoint
CREATE INDEX "audit_action_idx" ON "audit_logs" USING btree ("action");--> statement-breakpoint
CREATE INDEX "video_jobs_user_email_idx" ON "video_jobs" USING btree ("user_email");--> statement-breakpoint
CREATE INDEX "video_jobs_status_created_at_idx" ON "video_jobs" USING btree ("status","created_at");
Comment on lines +1 to +29

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🔴 Critical | 🏗️ Heavy lift

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check whether any migration file creates the organizations/organization_memberships tables
# or adds organization_id to classrooms.
fd -e sql . drizzle | xargs grep -ln "organizations\|organization_memberships\|organization_id"

Repository: knoxiboy/DoubtDesk

Length of output: 160


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== Migrations mentioning organization-related schema =="
fd -e sql . drizzle -x sh -c 'echo "--- $1"; rg -n "organizations|organization_memberships|organization_id|organizationId|classroomsTable" "$1"' sh {}

echo
echo "== Schema definitions =="
rg -n "organizationsTable|organizationMembershipsTable|organizationId|classroomsTable" src/configs/schema.ts src/app/api/organizations/route.ts src/app/api/rooms/route.ts

echo
echo "== Migration inventory =="
fd -e sql . drizzle | sort

Repository: knoxiboy/DoubtDesk

Length of output: 918


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== schema.ts references =="
rg -n "organizationsTable|organizationMembershipsTable|organizationId|classroomsTable" src/configs/schema.ts

echo
echo "== route references =="
rg -n "organizations|organizationMemberships|organizationId" src/app/api/organizations/route.ts src/app/api/rooms/route.ts

echo
echo "== drizzle migration files =="
fd -e sql . drizzle | sort

echo
echo "== organization-related strings in all migrations =="
for f in $(fd -e sql . drizzle | sort); do
  if rg -n "organizations|organization_memberships|organization_id|organizationId" "$f" >/dev/null; then
    echo "--- $f"
    rg -n "organizations|organization_memberships|organization_id|organizationId" "$f"
  fi
done

Repository: knoxiboy/DoubtDesk

Length of output: 4601


Add the missing organization schema migration
drizzle/0017_wild_klaw.sql only adds audit_logs and video_jobs; none of the drizzle/*.sql migrations create organizations, organization_memberships, or classrooms.organization_id. src/app/api/organizations/route.ts and src/app/api/rooms/route.ts already depend on them, so a fresh deployment will hit missing-relation errors until this schema lands in a migration.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@drizzle/0017_wild_klaw.sql` around lines 1 - 29, The migration is missing the
organization-related schema needed by the API routes, so add the tables and
relationship changes for organizations, organization_memberships, and the
classrooms.organization_id foreign key in this migration. Update the SQL in this
file to create the missing relations and constraints so the code paths in
src/app/api/organizations/route.ts and src/app/api/rooms/route.ts can run on a
fresh database without missing-relation errors.

Loading
Loading