Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ CREATE EXTENSION IF NOT EXISTS "uuid-ossp" WITH SCHEMA skills;
CREATE INDEX IF NOT EXISTS "challenge_status_type_track_created_at_idx"
ON "Challenge" ("status", "typeId", "trackId", "createdAt" DESC);

DROP INDEX IF EXISTS "challenge_name_idx";

CREATE INDEX IF NOT EXISTS "challenge_name_trgm_idx"
ON "Challenge" USING gin ("name" pg_catalog.gin_trgm_ops);

DO
$$
DECLARE
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
-- Remove deprecated ChallengePhase ordering index and allow AI reviewer flag to be nullable.

DO
$$
DECLARE
idx_schema TEXT;
BEGIN
SELECT n.nspname
INTO idx_schema
FROM pg_class c
JOIN pg_namespace n ON n.oid = c.relnamespace
WHERE c.relname = 'challenge_phase_order_idx'
AND c.relkind = 'i'
LIMIT 1;

IF idx_schema IS NOT NULL THEN
EXECUTE format('DROP INDEX %I.%I', idx_schema, 'challenge_phase_order_idx');

Choose a reason for hiding this comment

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

[⚠️ correctness]
Consider using CASCADE with DROP INDEX if there are any dependent objects that might be affected by the index removal. This ensures that the operation does not fail due to dependencies.

END IF;
END
$$ LANGUAGE plpgsql;

DO
$$
DECLARE
tbl_schema TEXT;
BEGIN
SELECT n.nspname
INTO tbl_schema
FROM pg_class c
JOIN pg_namespace n ON n.oid = c.relnamespace
WHERE c.relname = 'DefaultChallengeReviewer'
AND c.relkind = 'r'
LIMIT 1;

IF tbl_schema IS NULL THEN
RETURN;
END IF;

EXECUTE format(
'ALTER TABLE %I.%I ALTER COLUMN %I DROP NOT NULL',

Choose a reason for hiding this comment

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

[⚠️ correctness]
Ensure that altering the column to allow nulls does not introduce unintended behavior in the application logic that relies on this column being non-nullable. Consider reviewing the application code for any assumptions about this column's nullability.

tbl_schema,
'DefaultChallengeReviewer',
'isAIReviewer'
);
END
$$ LANGUAGE plpgsql;
8 changes: 3 additions & 5 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ datasource db {

generator client {
provider = "prisma-client-js"
previewFeatures = ["fullTextSearchPostgres", "postgresqlExtensions"]
previewFeatures = ["fullTextSearchPostgres", "postgresqlExtensions", "views"]

Choose a reason for hiding this comment

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

[⚠️ maintainability]
Adding views to previewFeatures can introduce instability as preview features are not fully stable. Ensure that this feature is thoroughly tested in your environment before relying on it in production.

}

// Enum for allowed challenge track values (matches app-constants)
Expand Down Expand Up @@ -157,7 +157,6 @@ model Challenge {
@@index([status, startDate])
@@index([trackId, typeId, status])
@@index([status, typeId, trackId, createdAt(sort: Desc)], map: "challenge_status_type_track_created_at_idx")
@@index([name(ops: raw("pg_catalog.gin_trgm_ops"))], type: Gin, map: "challenge_name_trgm_idx")
@@index([legacyId])
@@index([projectId, status])
}
Expand All @@ -166,13 +165,12 @@ model Challenge {
// MemberChallengeAccess view – member/challenge pairs from resources schema
//////////////////////////////////////////

model MemberChallengeAccess {
view MemberChallengeAccess {

Choose a reason for hiding this comment

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

[❗❗ correctness]
Changing MemberChallengeAccess from a model to a view can impact how data is queried and manipulated. Ensure that all existing operations on this model are compatible with the view semantics, especially if there are any write operations.

challengeId String
memberId String

challenge Challenge @relation(fields: [challengeId], references: [id])

@@id([challengeId, memberId])
@@map("MemberChallengeAccess")
}

Expand Down Expand Up @@ -660,7 +658,7 @@ model DefaultChallengeReviewer {
baseCoefficient Float?
incrementalCoefficient Float?
opportunityType ReviewOpportunityTypeEnum?
isAIReviewer Boolean
isAIReviewer Boolean?

Choose a reason for hiding this comment

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

[❗❗ correctness]
Changing isAIReviewer from Boolean to Boolean? allows for null values, which could lead to unexpected behavior if not handled properly. Ensure that the application logic accounts for potential null values.

shouldOpenOpportunity Boolean @default(true)

// Relations
Expand Down