diff --git a/drizzle/0020_flaky_lilith.sql b/drizzle/0020_flaky_lilith.sql new file mode 100644 index 0000000..079119d --- /dev/null +++ b/drizzle/0020_flaky_lilith.sql @@ -0,0 +1,3 @@ +ALTER TABLE "community_suggestions" DROP CONSTRAINT "community_suggestions_reviewed_by_user_id_fk"; +--> statement-breakpoint +ALTER TABLE "community_suggestions" ADD CONSTRAINT "community_suggestions_reviewed_by_user_id_fk" FOREIGN KEY ("reviewed_by") REFERENCES "public"."user"("id") ON DELETE set null ON UPDATE no action; \ No newline at end of file diff --git a/lib/db/schema/community-suggestions.ts b/lib/db/schema/community-suggestions.ts index 0893e50..7a969b0 100644 --- a/lib/db/schema/community-suggestions.ts +++ b/lib/db/schema/community-suggestions.ts @@ -31,7 +31,9 @@ export const communitySuggestions = pgTable( proposedValue: text("proposed_value").notNull(), // proposed new value reason: text("reason"), // optional explanation status: suggestionStatusEnum("status").default("pending").notNull(), - reviewedBy: text("reviewed_by").references(() => user.id), + reviewedBy: text("reviewed_by").references(() => user.id, { + onDelete: "set null", + }), reviewedAt: timestamp("reviewed_at"), reviewNote: text("review_note"), // reviewer's note createdAt: timestamp("created_at").defaultNow().notNull(),