From e87a3d73d78c581a8f49f80f51a098fd46ba7151 Mon Sep 17 00:00:00 2001 From: hoshinotsuyoshi Date: Thu, 17 Apr 2025 13:42:08 +0900 Subject: [PATCH 1/9] Migrate to snake_case table/column name in frontend/apps/app --- frontend/packages/db/schema/schema.sql | 598 ++++++++--------- .../packages/db/supabase/database.types.ts | 610 +++++++++--------- .../20250416105745_initial_squash.sql | 598 ++++++++--------- 3 files changed, 903 insertions(+), 903 deletions(-) diff --git a/frontend/packages/db/schema/schema.sql b/frontend/packages/db/schema/schema.sql index dccb07b69a..ac270e5ec8 100644 --- a/frontend/packages/db/schema/schema.sql +++ b/frontend/packages/db/schema/schema.sql @@ -65,7 +65,7 @@ CREATE EXTENSION IF NOT EXISTS "uuid-ossp" WITH SCHEMA "extensions"; -CREATE TYPE "public"."CategoryEnum" AS ENUM ( +CREATE TYPE "public"."category_enum" AS ENUM ( 'MIGRATION_SAFETY', 'DATA_INTEGRITY', 'PERFORMANCE_IMPACT', @@ -74,19 +74,19 @@ CREATE TYPE "public"."CategoryEnum" AS ENUM ( ); -ALTER TYPE "public"."CategoryEnum" OWNER TO "postgres"; +ALTER TYPE "public"."category_enum" OWNER TO "postgres"; -CREATE TYPE "public"."KnowledgeType" AS ENUM ( +CREATE TYPE "public"."knowledge_type" AS ENUM ( 'SCHEMA', 'DOCS' ); -ALTER TYPE "public"."KnowledgeType" OWNER TO "postgres"; +ALTER TYPE "public"."knowledge_type" OWNER TO "postgres"; -CREATE TYPE "public"."SchemaFormatEnum" AS ENUM ( +CREATE TYPE "public"."schema_format_enum" AS ENUM ( 'schemarb', 'postgres', 'prisma', @@ -94,10 +94,10 @@ CREATE TYPE "public"."SchemaFormatEnum" AS ENUM ( ); -ALTER TYPE "public"."SchemaFormatEnum" OWNER TO "postgres"; +ALTER TYPE "public"."schema_format_enum" OWNER TO "postgres"; -CREATE TYPE "public"."SeverityEnum" AS ENUM ( +CREATE TYPE "public"."severity_enum" AS ENUM ( 'CRITICAL', 'WARNING', 'POSITIVE', @@ -105,7 +105,7 @@ CREATE TYPE "public"."SeverityEnum" AS ENUM ( ); -ALTER TYPE "public"."SeverityEnum" OWNER TO "postgres"; +ALTER TYPE "public"."severity_enum" OWNER TO "postgres"; CREATE OR REPLACE FUNCTION "public"."handle_new_user"() RETURNS "trigger" @@ -113,7 +113,7 @@ CREATE OR REPLACE FUNCTION "public"."handle_new_user"() RETURNS "trigger" SET "search_path" TO '' AS $$ BEGIN - INSERT INTO public."User" (id, name, email) + INSERT INTO public."user" (id, name, email) VALUES ( NEW.id, COALESCE(NEW.raw_user_meta_data->>'name', NEW.email), @@ -131,13 +131,13 @@ CREATE OR REPLACE FUNCTION "public"."sync_existing_users"() RETURNS "void" LANGUAGE "plpgsql" SECURITY DEFINER AS $$ BEGIN - INSERT INTO public."User" (id, name, email) + INSERT INTO public."user" (id, name, email) SELECT au.id, COALESCE(au.raw_user_meta_data->>'name', au.email), au.email FROM auth.users au - LEFT JOIN public."User" pu ON au.id = pu.id + LEFT JOIN public."user" pu ON au.id = pu.id WHERE pu.id IS NULL; END; $$; @@ -150,585 +150,585 @@ SET default_tablespace = ''; SET default_table_access_method = "heap"; -CREATE TABLE IF NOT EXISTS "public"."GitHubDocFilePath" ( +CREATE TABLE IF NOT EXISTS "public"."github_doc_file_path" ( "id" "uuid" DEFAULT "gen_random_uuid"() NOT NULL, "path" "text" NOT NULL, - "isReviewEnabled" boolean DEFAULT true NOT NULL, - "projectId" "uuid" NOT NULL, - "createdAt" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "updatedAt" timestamp(3) without time zone NOT NULL + "is_review_enabled" boolean DEFAULT true NOT NULL, + "project_id" "uuid" NOT NULL, + "created_at" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "updated_at" timestamp(3) without time zone NOT NULL ); -ALTER TABLE "public"."GitHubDocFilePath" OWNER TO "postgres"; +ALTER TABLE "public"."github_doc_file_path" OWNER TO "postgres"; -CREATE TABLE IF NOT EXISTS "public"."GitHubSchemaFilePath" ( +CREATE TABLE IF NOT EXISTS "public"."github_schema_file_path" ( "id" "uuid" DEFAULT "gen_random_uuid"() NOT NULL, "path" "text" NOT NULL, - "projectId" "uuid" NOT NULL, - "createdAt" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "updatedAt" timestamp(3) without time zone NOT NULL, - "format" "public"."SchemaFormatEnum" NOT NULL + "project_id" "uuid" NOT NULL, + "created_at" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "updated_at" timestamp(3) without time zone NOT NULL, + "format" "public"."schema_format_enum" NOT NULL ); -ALTER TABLE "public"."GitHubSchemaFilePath" OWNER TO "postgres"; +ALTER TABLE "public"."github_schema_file_path" OWNER TO "postgres"; -CREATE TABLE IF NOT EXISTS "public"."KnowledgeSuggestion" ( +CREATE TABLE IF NOT EXISTS "public"."knowledge_suggestion" ( "id" "uuid" DEFAULT "gen_random_uuid"() NOT NULL, - "type" "public"."KnowledgeType" NOT NULL, + "type" "public"."knowledge_type" NOT NULL, "title" "text" NOT NULL, "path" "text" NOT NULL, "content" "text" NOT NULL, - "fileSha" "text", - "projectId" "uuid" NOT NULL, - "approvedAt" timestamp(3) without time zone, - "createdAt" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "updatedAt" timestamp(3) without time zone NOT NULL, - "branchName" "text" NOT NULL, - "traceId" "text", + "file_sha" "text", + "project_id" "uuid" NOT NULL, + "approved_at" timestamp(3) without time zone, + "created_at" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "updated_at" timestamp(3) without time zone NOT NULL, + "branch_name" "text" NOT NULL, + "trace_id" "text", "reasoning" "text" DEFAULT ''::"text" ); -ALTER TABLE "public"."KnowledgeSuggestion" OWNER TO "postgres"; +ALTER TABLE "public"."knowledge_suggestion" OWNER TO "postgres"; -CREATE TABLE IF NOT EXISTS "public"."KnowledgeSuggestionDocMapping" ( +CREATE TABLE IF NOT EXISTS "public"."knowledge_suggestion_doc_mapping" ( "id" "uuid" DEFAULT "gen_random_uuid"() NOT NULL, - "knowledgeSuggestionId" "uuid" NOT NULL, - "gitHubDocFilePathId" "uuid" NOT NULL, - "createdAt" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "updatedAt" timestamp(3) without time zone NOT NULL + "knowledge_suggestion_id" "uuid" NOT NULL, + "github_doc_file_path_id" "uuid" NOT NULL, + "created_at" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "updated_at" timestamp(3) without time zone NOT NULL ); -ALTER TABLE "public"."KnowledgeSuggestionDocMapping" OWNER TO "postgres"; +ALTER TABLE "public"."knowledge_suggestion_doc_mapping" OWNER TO "postgres"; -CREATE TABLE IF NOT EXISTS "public"."MembershipInvites" ( +CREATE TABLE IF NOT EXISTS "public"."membership_invites" ( "id" "uuid" DEFAULT "gen_random_uuid"() NOT NULL, "email" "text" NOT NULL, - "inviteByUserId" "uuid" NOT NULL, - "organizationId" "uuid" NOT NULL, - "invitedAt" timestamp with time zone DEFAULT CURRENT_TIMESTAMP + "invite_by_user_id" "uuid" NOT NULL, + "organization_id" "uuid" NOT NULL, + "invited_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP ); -ALTER TABLE "public"."MembershipInvites" OWNER TO "postgres"; +ALTER TABLE "public"."membership_invites" OWNER TO "postgres"; -CREATE TABLE IF NOT EXISTS "public"."Migration" ( +CREATE TABLE IF NOT EXISTS "public"."migration" ( "id" "uuid" DEFAULT "gen_random_uuid"() NOT NULL, "title" "text" NOT NULL, - "pullRequestId" "uuid" NOT NULL, - "createdAt" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "updatedAt" timestamp(3) without time zone NOT NULL + "pull_request_id" "uuid" NOT NULL, + "created_at" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "updated_at" timestamp(3) without time zone NOT NULL ); -ALTER TABLE "public"."Migration" OWNER TO "postgres"; +ALTER TABLE "public"."migration" OWNER TO "postgres"; -CREATE TABLE IF NOT EXISTS "public"."Organization" ( +CREATE TABLE IF NOT EXISTS "public"."organization" ( "id" "uuid" DEFAULT "gen_random_uuid"() NOT NULL, "name" "text" NOT NULL ); -ALTER TABLE "public"."Organization" OWNER TO "postgres"; +ALTER TABLE "public"."organization" OWNER TO "postgres"; -CREATE TABLE IF NOT EXISTS "public"."OrganizationMember" ( +CREATE TABLE IF NOT EXISTS "public"."organization_member" ( "id" "uuid" DEFAULT "gen_random_uuid"() NOT NULL, - "userId" "uuid" NOT NULL, - "organizationId" "uuid" NOT NULL, - "joinedAt" timestamp with time zone DEFAULT CURRENT_TIMESTAMP + "user_id" "uuid" NOT NULL, + "organization_id" "uuid" NOT NULL, + "joined_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP ); -ALTER TABLE "public"."OrganizationMember" OWNER TO "postgres"; +ALTER TABLE "public"."organization_member" OWNER TO "postgres"; -CREATE TABLE IF NOT EXISTS "public"."OverallReview" ( +CREATE TABLE IF NOT EXISTS "public"."overall_review" ( "id" "uuid" DEFAULT "gen_random_uuid"() NOT NULL, - "projectId" "uuid", - "pullRequestId" "uuid" NOT NULL, - "reviewComment" "text", - "reviewedAt" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "createdAt" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "updatedAt" timestamp(3) without time zone NOT NULL, - "branchName" "text" NOT NULL, - "traceId" "text" + "project_id" "uuid", + "pull_request_id" "uuid" NOT NULL, + "review_comment" "text", + "reviewed_at" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "created_at" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "updated_at" timestamp(3) without time zone NOT NULL, + "branch_name" "text" NOT NULL, + "trace_id" "text" ); -ALTER TABLE "public"."OverallReview" OWNER TO "postgres"; +ALTER TABLE "public"."overall_review" OWNER TO "postgres"; -CREATE TABLE IF NOT EXISTS "public"."OverallReviewKnowledgeSuggestionMapping" ( +CREATE TABLE IF NOT EXISTS "public"."overall_review_knowledge_suggestion_mapping" ( "id" "uuid" DEFAULT "gen_random_uuid"() NOT NULL, - "overallReviewId" "uuid" NOT NULL, - "knowledgeSuggestionId" "uuid" NOT NULL, - "createdAt" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "updatedAt" timestamp(3) without time zone NOT NULL + "overall_review_id" "uuid" NOT NULL, + "knowledge_suggestion_id" "uuid" NOT NULL, + "created_at" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "updated_at" timestamp(3) without time zone NOT NULL ); -ALTER TABLE "public"."OverallReviewKnowledgeSuggestionMapping" OWNER TO "postgres"; +ALTER TABLE "public"."overall_review_knowledge_suggestion_mapping" OWNER TO "postgres"; -CREATE TABLE IF NOT EXISTS "public"."Project" ( +CREATE TABLE IF NOT EXISTS "public"."project" ( "id" "uuid" DEFAULT "gen_random_uuid"() NOT NULL, "name" "text" NOT NULL, - "createdAt" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "updatedAt" timestamp(3) without time zone NOT NULL, - "organizationId" "uuid" + "created_at" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "updated_at" timestamp(3) without time zone NOT NULL, + "organization_id" "uuid" ); -ALTER TABLE "public"."Project" OWNER TO "postgres"; +ALTER TABLE "public"."project" OWNER TO "postgres"; -CREATE TABLE IF NOT EXISTS "public"."ProjectRepositoryMapping" ( +CREATE TABLE IF NOT EXISTS "public"."project_repository_mapping" ( "id" "uuid" DEFAULT "gen_random_uuid"() NOT NULL, - "projectId" "uuid" NOT NULL, - "repositoryId" "uuid" NOT NULL, - "createdAt" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "updatedAt" timestamp(3) without time zone NOT NULL + "project_id" "uuid" NOT NULL, + "repository_id" "uuid" NOT NULL, + "created_at" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "updated_at" timestamp(3) without time zone NOT NULL ); -ALTER TABLE "public"."ProjectRepositoryMapping" OWNER TO "postgres"; +ALTER TABLE "public"."project_repository_mapping" OWNER TO "postgres"; -CREATE TABLE IF NOT EXISTS "public"."PullRequest" ( +CREATE TABLE IF NOT EXISTS "public"."pull_request" ( "id" "uuid" DEFAULT "gen_random_uuid"() NOT NULL, - "pullNumber" bigint NOT NULL, - "commentId" bigint, - "createdAt" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "updatedAt" timestamp(3) without time zone NOT NULL, - "repositoryId" "uuid" NOT NULL + "pull_number" bigint NOT NULL, + "comment_id" bigint, + "created_at" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "updated_at" timestamp(3) without time zone NOT NULL, + "repository_id" "uuid" NOT NULL ); -ALTER TABLE "public"."PullRequest" OWNER TO "postgres"; +ALTER TABLE "public"."pull_request" OWNER TO "postgres"; -CREATE TABLE IF NOT EXISTS "public"."Repository" ( +CREATE TABLE IF NOT EXISTS "public"."repository" ( "id" "uuid" DEFAULT "gen_random_uuid"() NOT NULL, "name" "text" NOT NULL, "owner" "text" NOT NULL, - "installationId" integer NOT NULL, - "isActive" boolean DEFAULT true NOT NULL, - "createdAt" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "updatedAt" timestamp(3) without time zone NOT NULL + "installation_id" integer NOT NULL, + "is_active" boolean DEFAULT true NOT NULL, + "created_at" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "updated_at" timestamp(3) without time zone NOT NULL ); -ALTER TABLE "public"."Repository" OWNER TO "postgres"; +ALTER TABLE "public"."repository" OWNER TO "postgres"; -CREATE TABLE IF NOT EXISTS "public"."ReviewFeedback" ( +CREATE TABLE IF NOT EXISTS "public"."review_feedback" ( "id" "uuid" DEFAULT "gen_random_uuid"() NOT NULL, - "overallReviewId" "uuid" NOT NULL, - "category" "public"."CategoryEnum" NOT NULL, - "severity" "public"."SeverityEnum" NOT NULL, + "overall_review_id" "uuid" NOT NULL, + "category" "public"."category_enum" NOT NULL, + "severity" "public"."severity_enum" NOT NULL, "description" "text" NOT NULL, - "createdAt" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "updatedAt" timestamp(3) without time zone NOT NULL, + "created_at" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "updated_at" timestamp(3) without time zone NOT NULL, "suggestion" "text" NOT NULL, - "resolvedAt" timestamp(3) without time zone, - "resolutionComment" "text" + "resolved_at" timestamp(3) without time zone, + "resolution_comment" "text" ); -ALTER TABLE "public"."ReviewFeedback" OWNER TO "postgres"; +ALTER TABLE "public"."review_feedback" OWNER TO "postgres"; -CREATE TABLE IF NOT EXISTS "public"."ReviewFeedbackComment" ( +CREATE TABLE IF NOT EXISTS "public"."review_feedback_comment" ( "id" "uuid" DEFAULT "gen_random_uuid"() NOT NULL, - "reviewFeedbackId" "uuid" NOT NULL, - "userId" "uuid" NOT NULL, + "review_feedback_id" "uuid" NOT NULL, + "user_id" "uuid" NOT NULL, "content" "text" NOT NULL, - "createdAt" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "updatedAt" timestamp(3) without time zone NOT NULL + "created_at" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "updated_at" timestamp(3) without time zone NOT NULL ); -ALTER TABLE "public"."ReviewFeedbackComment" OWNER TO "postgres"; +ALTER TABLE "public"."review_feedback_comment" OWNER TO "postgres"; -CREATE TABLE IF NOT EXISTS "public"."ReviewSuggestionSnippet" ( +CREATE TABLE IF NOT EXISTS "public"."review_suggestion_snippet" ( "id" "uuid" DEFAULT "gen_random_uuid"() NOT NULL, - "reviewFeedbackId" "uuid" NOT NULL, + "review_feedback_id" "uuid" NOT NULL, "filename" "text" NOT NULL, "snippet" "text" NOT NULL, - "createdAt" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "updatedAt" timestamp(3) without time zone NOT NULL + "created_at" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "updated_at" timestamp(3) without time zone NOT NULL ); -ALTER TABLE "public"."ReviewSuggestionSnippet" OWNER TO "postgres"; +ALTER TABLE "public"."review_suggestion_snippet" OWNER TO "postgres"; -CREATE TABLE IF NOT EXISTS "public"."User" ( +CREATE TABLE IF NOT EXISTS "public"."user" ( "id" "uuid" NOT NULL, "name" "text" NOT NULL, "email" "text" NOT NULL ); -ALTER TABLE "public"."User" OWNER TO "postgres"; +ALTER TABLE "public"."user" OWNER TO "postgres"; -ALTER TABLE ONLY "public"."GitHubDocFilePath" - ADD CONSTRAINT "GitHubDocFilePath_pkey" PRIMARY KEY ("id"); +ALTER TABLE ONLY "public"."github_doc_file_path" + ADD CONSTRAINT "github_doc_file_path_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."GitHubSchemaFilePath" - ADD CONSTRAINT "GitHubSchemaFilePath_path_projectId_key" UNIQUE ("path", "projectId"); +ALTER TABLE ONLY "public"."github_schema_file_path" + ADD CONSTRAINT "github_schema_file_path_path_project_id_key" UNIQUE ("path", "project_id"); -ALTER TABLE ONLY "public"."GitHubSchemaFilePath" - ADD CONSTRAINT "GitHubSchemaFilePath_pkey" PRIMARY KEY ("id"); +ALTER TABLE ONLY "public"."github_schema_file_path" + ADD CONSTRAINT "github_schema_file_path_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."KnowledgeSuggestionDocMapping" - ADD CONSTRAINT "KnowledgeSuggestionDocMapping_pkey" PRIMARY KEY ("id"); +ALTER TABLE ONLY "public"."knowledge_suggestion_doc_mapping" + ADD CONSTRAINT "knowledge_suggestion_doc_mapping_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."KnowledgeSuggestion" - ADD CONSTRAINT "KnowledgeSuggestion_pkey" PRIMARY KEY ("id"); +ALTER TABLE ONLY "public"."knowledge_suggestion" + ADD CONSTRAINT "knowledge_suggestion_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."MembershipInvites" - ADD CONSTRAINT "MembershipInvites_pkey" PRIMARY KEY ("id"); +ALTER TABLE ONLY "public"."membership_invites" + ADD CONSTRAINT "membership_invites_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."Migration" - ADD CONSTRAINT "Migration_pkey" PRIMARY KEY ("id"); +ALTER TABLE ONLY "public"."migration" + ADD CONSTRAINT "migration_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."OrganizationMember" - ADD CONSTRAINT "OrganizationMember_pkey" PRIMARY KEY ("id"); +ALTER TABLE ONLY "public"."organization_member" + ADD CONSTRAINT "organization_member_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."OrganizationMember" - ADD CONSTRAINT "OrganizationMember_userId_organizationId_key" UNIQUE ("userId", "organizationId"); +ALTER TABLE ONLY "public"."organization_member" + ADD CONSTRAINT "organization_member_user_id_organization_id_key" UNIQUE ("user_id", "organization_id"); -ALTER TABLE ONLY "public"."Organization" - ADD CONSTRAINT "Organization_pkey" PRIMARY KEY ("id"); +ALTER TABLE ONLY "public"."organization" + ADD CONSTRAINT "organization_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."OverallReviewKnowledgeSuggestionMapping" - ADD CONSTRAINT "OverallReviewKnowledgeSuggestionMapping_pkey" PRIMARY KEY ("id"); +ALTER TABLE ONLY "public"."overall_review_knowledge_suggestion_mapping" + ADD CONSTRAINT "overall_review_knowledge_suggestion_mapping_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."OverallReview" - ADD CONSTRAINT "OverallReview_pkey" PRIMARY KEY ("id"); +ALTER TABLE ONLY "public"."overall_review" + ADD CONSTRAINT "overall_review_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."ProjectRepositoryMapping" - ADD CONSTRAINT "ProjectRepositoryMapping_pkey" PRIMARY KEY ("id"); +ALTER TABLE ONLY "public"."project" + ADD CONSTRAINT "project_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."Project" - ADD CONSTRAINT "Project_pkey" PRIMARY KEY ("id"); +ALTER TABLE ONLY "public"."project_repository_mapping" + ADD CONSTRAINT "project_repository_mapping_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."PullRequest" - ADD CONSTRAINT "PullRequest_pkey" PRIMARY KEY ("id"); +ALTER TABLE ONLY "public"."pull_request" + ADD CONSTRAINT "pull_request_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."Repository" - ADD CONSTRAINT "Repository_pkey" PRIMARY KEY ("id"); +ALTER TABLE ONLY "public"."repository" + ADD CONSTRAINT "repository_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."ReviewFeedbackComment" - ADD CONSTRAINT "ReviewFeedbackComment_pkey" PRIMARY KEY ("id"); +ALTER TABLE ONLY "public"."review_feedback_comment" + ADD CONSTRAINT "review_feedback_comment_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."ReviewFeedback" - ADD CONSTRAINT "ReviewFeedback_pkey" PRIMARY KEY ("id"); +ALTER TABLE ONLY "public"."review_feedback" + ADD CONSTRAINT "review_feedback_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."ReviewSuggestionSnippet" - ADD CONSTRAINT "ReviewSuggestionSnippet_pkey" PRIMARY KEY ("id"); +ALTER TABLE ONLY "public"."review_suggestion_snippet" + ADD CONSTRAINT "review_suggestion_snippet_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."User" - ADD CONSTRAINT "User_email_key" UNIQUE ("email"); +ALTER TABLE ONLY "public"."user" + ADD CONSTRAINT "user_email_key" UNIQUE ("email"); -ALTER TABLE ONLY "public"."User" - ADD CONSTRAINT "User_pkey" PRIMARY KEY ("id"); +ALTER TABLE ONLY "public"."user" + ADD CONSTRAINT "user_pkey" PRIMARY KEY ("id"); -CREATE UNIQUE INDEX "GitHubDocFilePath_path_projectId_key" ON "public"."GitHubDocFilePath" USING "btree" ("path", "projectId"); +CREATE UNIQUE INDEX "github_doc_file_path_path_project_id_key" ON "public"."github_doc_file_path" USING "btree" ("path", "project_id"); -CREATE UNIQUE INDEX "GitHubSchemaFilePath_projectId_key" ON "public"."GitHubSchemaFilePath" USING "btree" ("projectId"); +CREATE UNIQUE INDEX "github_schema_file_path_project_id_key" ON "public"."github_schema_file_path" USING "btree" ("project_id"); -CREATE UNIQUE INDEX "KnowledgeSuggestionDocMapping_unique_mapping" ON "public"."KnowledgeSuggestionDocMapping" USING "btree" ("knowledgeSuggestionId", "gitHubDocFilePathId"); +CREATE INDEX "idx_project_organization_id" ON "public"."project" USING "btree" ("organization_id"); -CREATE UNIQUE INDEX "Migration_pullRequestId_key" ON "public"."Migration" USING "btree" ("pullRequestId"); +CREATE INDEX "idx_review_feedback_comment_review_feedback_id" ON "public"."review_feedback_comment" USING "btree" ("review_feedback_id"); -CREATE UNIQUE INDEX "OverallReviewKnowledgeSuggestionMapping_unique_mapping" ON "public"."OverallReviewKnowledgeSuggestionMapping" USING "btree" ("overallReviewId", "knowledgeSuggestionId"); +CREATE UNIQUE INDEX "knowledge_suggestion_doc_mapping_unique_mapping" ON "public"."knowledge_suggestion_doc_mapping" USING "btree" ("knowledge_suggestion_id", "github_doc_file_path_id"); -CREATE UNIQUE INDEX "ProjectRepositoryMapping_projectId_repositoryId_key" ON "public"."ProjectRepositoryMapping" USING "btree" ("projectId", "repositoryId"); +CREATE INDEX "membership_invites_email_idx" ON "public"."membership_invites" USING "btree" ("email"); -CREATE UNIQUE INDEX "PullRequest_repositoryId_pullNumber_key" ON "public"."PullRequest" USING "btree" ("repositoryId", "pullNumber"); +CREATE INDEX "membership_invites_org_id_idx" ON "public"."membership_invites" USING "btree" ("organization_id"); -CREATE UNIQUE INDEX "Repository_owner_name_key" ON "public"."Repository" USING "btree" ("owner", "name"); +CREATE UNIQUE INDEX "migration_pull_request_id_key" ON "public"."migration" USING "btree" ("pull_request_id"); -CREATE INDEX "idx_project_organizationId" ON "public"."Project" USING "btree" ("organizationId"); +CREATE INDEX "organization_member_organization_id_idx" ON "public"."organization_member" USING "btree" ("organization_id"); -CREATE INDEX "idx_review_feedback_comment_review_feedback_id" ON "public"."ReviewFeedbackComment" USING "btree" ("reviewFeedbackId"); +CREATE INDEX "organization_member_user_id_idx" ON "public"."organization_member" USING "btree" ("user_id"); -CREATE INDEX "membership_invites_email_idx" ON "public"."MembershipInvites" USING "btree" ("email"); +CREATE UNIQUE INDEX "overall_review_knowledge_suggestion_mapping_unique_mapping" ON "public"."overall_review_knowledge_suggestion_mapping" USING "btree" ("overall_review_id", "knowledge_suggestion_id"); -CREATE INDEX "membership_invites_orgId_idx" ON "public"."MembershipInvites" USING "btree" ("organizationId"); +CREATE UNIQUE INDEX "project_repository_mapping_project_id_repository_id_key" ON "public"."project_repository_mapping" USING "btree" ("project_id", "repository_id"); -CREATE INDEX "organization_member_organizationId_idx" ON "public"."OrganizationMember" USING "btree" ("organizationId"); +CREATE UNIQUE INDEX "pull_request_repository_id_pull_number_key" ON "public"."pull_request" USING "btree" ("repository_id", "pull_number"); -CREATE INDEX "organization_member_userId_idx" ON "public"."OrganizationMember" USING "btree" ("userId"); +CREATE UNIQUE INDEX "repository_owner_name_key" ON "public"."repository" USING "btree" ("owner", "name"); -ALTER TABLE ONLY "public"."GitHubDocFilePath" - ADD CONSTRAINT "GitHubDocFilePath_projectId_fkey" FOREIGN KEY ("projectId") REFERENCES "public"."Project"("id") ON UPDATE CASCADE ON DELETE RESTRICT; +ALTER TABLE ONLY "public"."github_doc_file_path" + ADD CONSTRAINT "github_doc_file_path_project_id_fkey" FOREIGN KEY ("project_id") REFERENCES "public"."project"("id") ON UPDATE CASCADE ON DELETE RESTRICT; -ALTER TABLE ONLY "public"."GitHubSchemaFilePath" - ADD CONSTRAINT "GitHubSchemaFilePath_projectId_fkey" FOREIGN KEY ("projectId") REFERENCES "public"."Project"("id") ON UPDATE CASCADE ON DELETE RESTRICT; +ALTER TABLE ONLY "public"."github_schema_file_path" + ADD CONSTRAINT "github_schema_file_path_project_id_fkey" FOREIGN KEY ("project_id") REFERENCES "public"."project"("id") ON UPDATE CASCADE ON DELETE RESTRICT; -ALTER TABLE ONLY "public"."KnowledgeSuggestionDocMapping" - ADD CONSTRAINT "KnowledgeSuggestionDocMapping_gitHubDocFilePathId_fkey" FOREIGN KEY ("gitHubDocFilePathId") REFERENCES "public"."GitHubDocFilePath"("id") ON UPDATE CASCADE ON DELETE CASCADE; +ALTER TABLE ONLY "public"."knowledge_suggestion_doc_mapping" + ADD CONSTRAINT "knowledge_suggestion_doc_mapping_github_doc_file_path_id_fkey" FOREIGN KEY ("github_doc_file_path_id") REFERENCES "public"."github_doc_file_path"("id") ON UPDATE CASCADE ON DELETE CASCADE; -ALTER TABLE ONLY "public"."KnowledgeSuggestionDocMapping" - ADD CONSTRAINT "KnowledgeSuggestionDocMapping_knowledgeSuggestionId_fkey" FOREIGN KEY ("knowledgeSuggestionId") REFERENCES "public"."KnowledgeSuggestion"("id") ON UPDATE CASCADE ON DELETE CASCADE; +ALTER TABLE ONLY "public"."knowledge_suggestion_doc_mapping" + ADD CONSTRAINT "knowledge_suggestion_doc_mapping_knowledge_suggestion_id_fkey" FOREIGN KEY ("knowledge_suggestion_id") REFERENCES "public"."knowledge_suggestion"("id") ON UPDATE CASCADE ON DELETE CASCADE; -ALTER TABLE ONLY "public"."KnowledgeSuggestion" - ADD CONSTRAINT "KnowledgeSuggestion_projectId_fkey" FOREIGN KEY ("projectId") REFERENCES "public"."Project"("id") ON UPDATE CASCADE ON DELETE RESTRICT; +ALTER TABLE ONLY "public"."knowledge_suggestion" + ADD CONSTRAINT "knowledge_suggestion_project_id_fkey" FOREIGN KEY ("project_id") REFERENCES "public"."project"("id") ON UPDATE CASCADE ON DELETE RESTRICT; -ALTER TABLE ONLY "public"."MembershipInvites" - ADD CONSTRAINT "MembershipInvites_inviteByUserId_fkey" FOREIGN KEY ("inviteByUserId") REFERENCES "public"."User"("id") ON DELETE CASCADE; +ALTER TABLE ONLY "public"."membership_invites" + ADD CONSTRAINT "membership_invites_invite_by_user_id_fkey" FOREIGN KEY ("invite_by_user_id") REFERENCES "public"."user"("id") ON DELETE CASCADE; -ALTER TABLE ONLY "public"."MembershipInvites" - ADD CONSTRAINT "MembershipInvites_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "public"."Organization"("id") ON DELETE CASCADE; +ALTER TABLE ONLY "public"."membership_invites" + ADD CONSTRAINT "membership_invites_organization_id_fkey" FOREIGN KEY ("organization_id") REFERENCES "public"."organization"("id") ON DELETE CASCADE; -ALTER TABLE ONLY "public"."Migration" - ADD CONSTRAINT "Migration_pullRequestId_fkey" FOREIGN KEY ("pullRequestId") REFERENCES "public"."PullRequest"("id") ON UPDATE CASCADE ON DELETE RESTRICT; +ALTER TABLE ONLY "public"."migration" + ADD CONSTRAINT "migration_pull_request_id_fkey" FOREIGN KEY ("pull_request_id") REFERENCES "public"."pull_request"("id") ON UPDATE CASCADE ON DELETE RESTRICT; -ALTER TABLE ONLY "public"."OrganizationMember" - ADD CONSTRAINT "OrganizationMember_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "public"."Organization"("id") ON DELETE CASCADE; +ALTER TABLE ONLY "public"."organization_member" + ADD CONSTRAINT "organization_member_organization_id_fkey" FOREIGN KEY ("organization_id") REFERENCES "public"."organization"("id") ON DELETE CASCADE; -ALTER TABLE ONLY "public"."OrganizationMember" - ADD CONSTRAINT "OrganizationMember_userId_fkey" FOREIGN KEY ("userId") REFERENCES "public"."User"("id") ON DELETE CASCADE; +ALTER TABLE ONLY "public"."organization_member" + ADD CONSTRAINT "organization_member_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE CASCADE; -ALTER TABLE ONLY "public"."OverallReviewKnowledgeSuggestionMapping" - ADD CONSTRAINT "OverallReviewKnowledgeSuggestionMapping_knowledgeSuggestionId_f" FOREIGN KEY ("knowledgeSuggestionId") REFERENCES "public"."KnowledgeSuggestion"("id") ON UPDATE CASCADE ON DELETE CASCADE; +ALTER TABLE ONLY "public"."overall_review_knowledge_suggestion_mapping" + ADD CONSTRAINT "overall_review_knowledge_suggestion_mapping_knowledge_suggestio" FOREIGN KEY ("knowledge_suggestion_id") REFERENCES "public"."knowledge_suggestion"("id") ON UPDATE CASCADE ON DELETE CASCADE; -ALTER TABLE ONLY "public"."OverallReviewKnowledgeSuggestionMapping" - ADD CONSTRAINT "OverallReviewKnowledgeSuggestionMapping_overallReviewId_fkey" FOREIGN KEY ("overallReviewId") REFERENCES "public"."OverallReview"("id") ON UPDATE CASCADE ON DELETE CASCADE; +ALTER TABLE ONLY "public"."overall_review_knowledge_suggestion_mapping" + ADD CONSTRAINT "overall_review_knowledge_suggestion_mapping_overall_review_id_f" FOREIGN KEY ("overall_review_id") REFERENCES "public"."overall_review"("id") ON UPDATE CASCADE ON DELETE CASCADE; -ALTER TABLE ONLY "public"."OverallReview" - ADD CONSTRAINT "OverallReview_projectId_fkey" FOREIGN KEY ("projectId") REFERENCES "public"."Project"("id") ON UPDATE CASCADE ON DELETE SET NULL; +ALTER TABLE ONLY "public"."overall_review" + ADD CONSTRAINT "overall_review_project_id_fkey" FOREIGN KEY ("project_id") REFERENCES "public"."project"("id") ON UPDATE CASCADE ON DELETE SET NULL; -ALTER TABLE ONLY "public"."OverallReview" - ADD CONSTRAINT "OverallReview_pullRequestId_fkey" FOREIGN KEY ("pullRequestId") REFERENCES "public"."PullRequest"("id") ON UPDATE CASCADE ON DELETE RESTRICT; +ALTER TABLE ONLY "public"."overall_review" + ADD CONSTRAINT "overall_review_pull_request_id_fkey" FOREIGN KEY ("pull_request_id") REFERENCES "public"."pull_request"("id") ON UPDATE CASCADE ON DELETE RESTRICT; -ALTER TABLE ONLY "public"."ProjectRepositoryMapping" - ADD CONSTRAINT "ProjectRepositoryMapping_projectId_fkey" FOREIGN KEY ("projectId") REFERENCES "public"."Project"("id") ON UPDATE CASCADE ON DELETE RESTRICT; +ALTER TABLE ONLY "public"."project" + ADD CONSTRAINT "project_organization_id_fkey" FOREIGN KEY ("organization_id") REFERENCES "public"."organization"("id") ON UPDATE CASCADE ON DELETE CASCADE; -ALTER TABLE ONLY "public"."ProjectRepositoryMapping" - ADD CONSTRAINT "ProjectRepositoryMapping_repositoryId_fkey" FOREIGN KEY ("repositoryId") REFERENCES "public"."Repository"("id") ON UPDATE CASCADE ON DELETE RESTRICT; +ALTER TABLE ONLY "public"."project_repository_mapping" + ADD CONSTRAINT "project_repository_mapping_project_id_fkey" FOREIGN KEY ("project_id") REFERENCES "public"."project"("id") ON UPDATE CASCADE ON DELETE RESTRICT; -ALTER TABLE ONLY "public"."Project" - ADD CONSTRAINT "Project_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "public"."Organization"("id") ON UPDATE CASCADE ON DELETE CASCADE; +ALTER TABLE ONLY "public"."project_repository_mapping" + ADD CONSTRAINT "project_repository_mapping_repository_id_fkey" FOREIGN KEY ("repository_id") REFERENCES "public"."repository"("id") ON UPDATE CASCADE ON DELETE RESTRICT; -ALTER TABLE ONLY "public"."PullRequest" - ADD CONSTRAINT "PullRequest_repositoryId_fkey" FOREIGN KEY ("repositoryId") REFERENCES "public"."Repository"("id") ON UPDATE CASCADE ON DELETE RESTRICT; +ALTER TABLE ONLY "public"."pull_request" + ADD CONSTRAINT "pull_request_repository_id_fkey" FOREIGN KEY ("repository_id") REFERENCES "public"."repository"("id") ON UPDATE CASCADE ON DELETE RESTRICT; -ALTER TABLE ONLY "public"."ReviewFeedbackComment" - ADD CONSTRAINT "ReviewFeedbackComment_reviewFeedbackId_fkey" FOREIGN KEY ("reviewFeedbackId") REFERENCES "public"."ReviewFeedback"("id") ON UPDATE CASCADE ON DELETE CASCADE; +ALTER TABLE ONLY "public"."review_feedback_comment" + ADD CONSTRAINT "review_feedback_comment_review_feedback_id_fkey" FOREIGN KEY ("review_feedback_id") REFERENCES "public"."review_feedback"("id") ON UPDATE CASCADE ON DELETE CASCADE; -ALTER TABLE ONLY "public"."ReviewFeedbackComment" - ADD CONSTRAINT "ReviewFeedbackComment_userId_fkey" FOREIGN KEY ("userId") REFERENCES "public"."User"("id") ON UPDATE CASCADE ON DELETE CASCADE; +ALTER TABLE ONLY "public"."review_feedback_comment" + ADD CONSTRAINT "review_feedback_comment_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON UPDATE CASCADE ON DELETE CASCADE; -ALTER TABLE ONLY "public"."ReviewFeedback" - ADD CONSTRAINT "ReviewFeedback_overallReviewId_fkey" FOREIGN KEY ("overallReviewId") REFERENCES "public"."OverallReview"("id") ON UPDATE CASCADE ON DELETE RESTRICT; +ALTER TABLE ONLY "public"."review_feedback" + ADD CONSTRAINT "review_feedback_overall_review_id_fkey" FOREIGN KEY ("overall_review_id") REFERENCES "public"."overall_review"("id") ON UPDATE CASCADE ON DELETE RESTRICT; -ALTER TABLE ONLY "public"."ReviewSuggestionSnippet" - ADD CONSTRAINT "ReviewSuggestionSnippet_reviewFeedbackId_fkey" FOREIGN KEY ("reviewFeedbackId") REFERENCES "public"."ReviewFeedback"("id") ON UPDATE CASCADE ON DELETE CASCADE; +ALTER TABLE ONLY "public"."review_suggestion_snippet" + ADD CONSTRAINT "review_suggestion_snippet_review_feedback_id_fkey" FOREIGN KEY ("review_feedback_id") REFERENCES "public"."review_feedback"("id") ON UPDATE CASCADE ON DELETE CASCADE; -ALTER TABLE "public"."Project" ENABLE ROW LEVEL SECURITY; +CREATE POLICY "authenticated_users_can_delete_org_projects" ON "public"."project" FOR DELETE TO "authenticated" USING (("organization_id" IN ( SELECT "organization_member"."organization_id" + FROM "public"."organization_member" + WHERE ("organization_member"."user_id" = "auth"."uid"())))); -CREATE POLICY "authenticated_users_can_delete_org_projects" ON "public"."Project" FOR DELETE TO "authenticated" USING (("organizationId" IN ( SELECT "OrganizationMember"."organizationId" - FROM "public"."OrganizationMember" - WHERE ("OrganizationMember"."userId" = "auth"."uid"())))); +COMMENT ON POLICY "authenticated_users_can_delete_org_projects" ON "public"."project" IS 'Authenticated users can only delete projects in organizations they are members of'; -COMMENT ON POLICY "authenticated_users_can_delete_org_projects" ON "public"."Project" IS 'Authenticated users can only delete projects in organizations they are members of'; +CREATE POLICY "authenticated_users_can_insert_projects" ON "public"."project" FOR INSERT TO "authenticated" WITH CHECK (("organization_id" IN ( SELECT "organization_member"."organization_id" + FROM "public"."organization_member" + WHERE ("organization_member"."user_id" = "auth"."uid"())))); -CREATE POLICY "authenticated_users_can_insert_projects" ON "public"."Project" FOR INSERT TO "authenticated" WITH CHECK (("organizationId" IN ( SELECT "OrganizationMember"."organizationId" - FROM "public"."OrganizationMember" - WHERE ("OrganizationMember"."userId" = "auth"."uid"())))); +COMMENT ON POLICY "authenticated_users_can_insert_projects" ON "public"."project" IS 'Authenticated users can create any project'; -COMMENT ON POLICY "authenticated_users_can_insert_projects" ON "public"."Project" IS 'Authenticated users can create any project'; +CREATE POLICY "authenticated_users_can_select_org_projects" ON "public"."project" FOR SELECT TO "authenticated" USING (("organization_id" IN ( SELECT "organization_member"."organization_id" + FROM "public"."organization_member" + WHERE ("organization_member"."user_id" = "auth"."uid"())))); -CREATE POLICY "authenticated_users_can_select_org_projects" ON "public"."Project" FOR SELECT TO "authenticated" USING (("organizationId" IN ( SELECT "OrganizationMember"."organizationId" - FROM "public"."OrganizationMember" - WHERE ("OrganizationMember"."userId" = "auth"."uid"())))); +COMMENT ON POLICY "authenticated_users_can_select_org_projects" ON "public"."project" IS 'Authenticated users can only view projects belonging to organizations they are members of'; -COMMENT ON POLICY "authenticated_users_can_select_org_projects" ON "public"."Project" IS 'Authenticated users can only view projects belonging to organizations they are members of'; +CREATE POLICY "authenticated_users_can_update_org_projects" ON "public"."project" FOR UPDATE TO "authenticated" USING (("organization_id" IN ( SELECT "organization_member"."organization_id" + FROM "public"."organization_member" + WHERE ("organization_member"."user_id" = "auth"."uid"())))) WITH CHECK (("organization_id" IN ( SELECT "organization_member"."organization_id" + FROM "public"."organization_member" + WHERE ("organization_member"."user_id" = "auth"."uid"())))); -CREATE POLICY "authenticated_users_can_update_org_projects" ON "public"."Project" FOR UPDATE TO "authenticated" USING (("organizationId" IN ( SELECT "OrganizationMember"."organizationId" - FROM "public"."OrganizationMember" - WHERE ("OrganizationMember"."userId" = "auth"."uid"())))) WITH CHECK (("organizationId" IN ( SELECT "OrganizationMember"."organizationId" - FROM "public"."OrganizationMember" - WHERE ("OrganizationMember"."userId" = "auth"."uid"())))); +COMMENT ON POLICY "authenticated_users_can_update_org_projects" ON "public"."project" IS 'Authenticated users can only update projects in organizations they are members of'; -COMMENT ON POLICY "authenticated_users_can_update_org_projects" ON "public"."Project" IS 'Authenticated users can only update projects in organizations they are members of'; +ALTER TABLE "public"."project" ENABLE ROW LEVEL SECURITY; -CREATE POLICY "service_role_can_delete_all_projects" ON "public"."Project" FOR DELETE TO "service_role" USING (true); +CREATE POLICY "service_role_can_delete_all_projects" ON "public"."project" FOR DELETE TO "service_role" USING (true); -COMMENT ON POLICY "service_role_can_delete_all_projects" ON "public"."Project" IS 'Service role can delete any project (for jobs)'; +COMMENT ON POLICY "service_role_can_delete_all_projects" ON "public"."project" IS 'Service role can delete any project (for jobs)'; -CREATE POLICY "service_role_can_insert_all_projects" ON "public"."Project" FOR INSERT TO "service_role" WITH CHECK (true); +CREATE POLICY "service_role_can_insert_all_projects" ON "public"."project" FOR INSERT TO "service_role" WITH CHECK (true); -COMMENT ON POLICY "service_role_can_insert_all_projects" ON "public"."Project" IS 'Service role can create any project (for jobs)'; +COMMENT ON POLICY "service_role_can_insert_all_projects" ON "public"."project" IS 'Service role can create any project (for jobs)'; -CREATE POLICY "service_role_can_select_all_projects" ON "public"."Project" FOR SELECT TO "service_role" USING (true); +CREATE POLICY "service_role_can_select_all_projects" ON "public"."project" FOR SELECT TO "service_role" USING (true); -COMMENT ON POLICY "service_role_can_select_all_projects" ON "public"."Project" IS 'Service role can view all projects (for jobs)'; +COMMENT ON POLICY "service_role_can_select_all_projects" ON "public"."project" IS 'Service role can view all projects (for jobs)'; -CREATE POLICY "service_role_can_update_all_projects" ON "public"."Project" FOR UPDATE TO "service_role" USING (true) WITH CHECK (true); +CREATE POLICY "service_role_can_update_all_projects" ON "public"."project" FOR UPDATE TO "service_role" USING (true) WITH CHECK (true); -COMMENT ON POLICY "service_role_can_update_all_projects" ON "public"."Project" IS 'Service role can update any project (for jobs)'; +COMMENT ON POLICY "service_role_can_update_all_projects" ON "public"."project" IS 'Service role can update any project (for jobs)'; @@ -948,111 +948,111 @@ GRANT ALL ON FUNCTION "public"."sync_existing_users"() TO "service_role"; -GRANT ALL ON TABLE "public"."GitHubDocFilePath" TO "anon"; -GRANT ALL ON TABLE "public"."GitHubDocFilePath" TO "authenticated"; -GRANT ALL ON TABLE "public"."GitHubDocFilePath" TO "service_role"; +GRANT ALL ON TABLE "public"."github_doc_file_path" TO "anon"; +GRANT ALL ON TABLE "public"."github_doc_file_path" TO "authenticated"; +GRANT ALL ON TABLE "public"."github_doc_file_path" TO "service_role"; -GRANT ALL ON TABLE "public"."GitHubSchemaFilePath" TO "anon"; -GRANT ALL ON TABLE "public"."GitHubSchemaFilePath" TO "authenticated"; -GRANT ALL ON TABLE "public"."GitHubSchemaFilePath" TO "service_role"; +GRANT ALL ON TABLE "public"."github_schema_file_path" TO "anon"; +GRANT ALL ON TABLE "public"."github_schema_file_path" TO "authenticated"; +GRANT ALL ON TABLE "public"."github_schema_file_path" TO "service_role"; -GRANT ALL ON TABLE "public"."KnowledgeSuggestion" TO "anon"; -GRANT ALL ON TABLE "public"."KnowledgeSuggestion" TO "authenticated"; -GRANT ALL ON TABLE "public"."KnowledgeSuggestion" TO "service_role"; +GRANT ALL ON TABLE "public"."knowledge_suggestion" TO "anon"; +GRANT ALL ON TABLE "public"."knowledge_suggestion" TO "authenticated"; +GRANT ALL ON TABLE "public"."knowledge_suggestion" TO "service_role"; -GRANT ALL ON TABLE "public"."KnowledgeSuggestionDocMapping" TO "anon"; -GRANT ALL ON TABLE "public"."KnowledgeSuggestionDocMapping" TO "authenticated"; -GRANT ALL ON TABLE "public"."KnowledgeSuggestionDocMapping" TO "service_role"; +GRANT ALL ON TABLE "public"."knowledge_suggestion_doc_mapping" TO "anon"; +GRANT ALL ON TABLE "public"."knowledge_suggestion_doc_mapping" TO "authenticated"; +GRANT ALL ON TABLE "public"."knowledge_suggestion_doc_mapping" TO "service_role"; -GRANT ALL ON TABLE "public"."MembershipInvites" TO "anon"; -GRANT ALL ON TABLE "public"."MembershipInvites" TO "authenticated"; -GRANT ALL ON TABLE "public"."MembershipInvites" TO "service_role"; +GRANT ALL ON TABLE "public"."membership_invites" TO "anon"; +GRANT ALL ON TABLE "public"."membership_invites" TO "authenticated"; +GRANT ALL ON TABLE "public"."membership_invites" TO "service_role"; -GRANT ALL ON TABLE "public"."Migration" TO "anon"; -GRANT ALL ON TABLE "public"."Migration" TO "authenticated"; -GRANT ALL ON TABLE "public"."Migration" TO "service_role"; +GRANT ALL ON TABLE "public"."migration" TO "anon"; +GRANT ALL ON TABLE "public"."migration" TO "authenticated"; +GRANT ALL ON TABLE "public"."migration" TO "service_role"; -GRANT ALL ON TABLE "public"."Organization" TO "anon"; -GRANT ALL ON TABLE "public"."Organization" TO "authenticated"; -GRANT ALL ON TABLE "public"."Organization" TO "service_role"; +GRANT ALL ON TABLE "public"."organization" TO "anon"; +GRANT ALL ON TABLE "public"."organization" TO "authenticated"; +GRANT ALL ON TABLE "public"."organization" TO "service_role"; -GRANT ALL ON TABLE "public"."OrganizationMember" TO "anon"; -GRANT ALL ON TABLE "public"."OrganizationMember" TO "authenticated"; -GRANT ALL ON TABLE "public"."OrganizationMember" TO "service_role"; +GRANT ALL ON TABLE "public"."organization_member" TO "anon"; +GRANT ALL ON TABLE "public"."organization_member" TO "authenticated"; +GRANT ALL ON TABLE "public"."organization_member" TO "service_role"; -GRANT ALL ON TABLE "public"."OverallReview" TO "anon"; -GRANT ALL ON TABLE "public"."OverallReview" TO "authenticated"; -GRANT ALL ON TABLE "public"."OverallReview" TO "service_role"; +GRANT ALL ON TABLE "public"."overall_review" TO "anon"; +GRANT ALL ON TABLE "public"."overall_review" TO "authenticated"; +GRANT ALL ON TABLE "public"."overall_review" TO "service_role"; -GRANT ALL ON TABLE "public"."OverallReviewKnowledgeSuggestionMapping" TO "anon"; -GRANT ALL ON TABLE "public"."OverallReviewKnowledgeSuggestionMapping" TO "authenticated"; -GRANT ALL ON TABLE "public"."OverallReviewKnowledgeSuggestionMapping" TO "service_role"; +GRANT ALL ON TABLE "public"."overall_review_knowledge_suggestion_mapping" TO "anon"; +GRANT ALL ON TABLE "public"."overall_review_knowledge_suggestion_mapping" TO "authenticated"; +GRANT ALL ON TABLE "public"."overall_review_knowledge_suggestion_mapping" TO "service_role"; -GRANT ALL ON TABLE "public"."Project" TO "anon"; -GRANT ALL ON TABLE "public"."Project" TO "authenticated"; -GRANT ALL ON TABLE "public"."Project" TO "service_role"; +GRANT ALL ON TABLE "public"."project" TO "anon"; +GRANT ALL ON TABLE "public"."project" TO "authenticated"; +GRANT ALL ON TABLE "public"."project" TO "service_role"; -GRANT ALL ON TABLE "public"."ProjectRepositoryMapping" TO "anon"; -GRANT ALL ON TABLE "public"."ProjectRepositoryMapping" TO "authenticated"; -GRANT ALL ON TABLE "public"."ProjectRepositoryMapping" TO "service_role"; +GRANT ALL ON TABLE "public"."project_repository_mapping" TO "anon"; +GRANT ALL ON TABLE "public"."project_repository_mapping" TO "authenticated"; +GRANT ALL ON TABLE "public"."project_repository_mapping" TO "service_role"; -GRANT ALL ON TABLE "public"."PullRequest" TO "anon"; -GRANT ALL ON TABLE "public"."PullRequest" TO "authenticated"; -GRANT ALL ON TABLE "public"."PullRequest" TO "service_role"; +GRANT ALL ON TABLE "public"."pull_request" TO "anon"; +GRANT ALL ON TABLE "public"."pull_request" TO "authenticated"; +GRANT ALL ON TABLE "public"."pull_request" TO "service_role"; -GRANT ALL ON TABLE "public"."Repository" TO "anon"; -GRANT ALL ON TABLE "public"."Repository" TO "authenticated"; -GRANT ALL ON TABLE "public"."Repository" TO "service_role"; +GRANT ALL ON TABLE "public"."repository" TO "anon"; +GRANT ALL ON TABLE "public"."repository" TO "authenticated"; +GRANT ALL ON TABLE "public"."repository" TO "service_role"; -GRANT ALL ON TABLE "public"."ReviewFeedback" TO "anon"; -GRANT ALL ON TABLE "public"."ReviewFeedback" TO "authenticated"; -GRANT ALL ON TABLE "public"."ReviewFeedback" TO "service_role"; +GRANT ALL ON TABLE "public"."review_feedback" TO "anon"; +GRANT ALL ON TABLE "public"."review_feedback" TO "authenticated"; +GRANT ALL ON TABLE "public"."review_feedback" TO "service_role"; -GRANT ALL ON TABLE "public"."ReviewFeedbackComment" TO "anon"; -GRANT ALL ON TABLE "public"."ReviewFeedbackComment" TO "authenticated"; -GRANT ALL ON TABLE "public"."ReviewFeedbackComment" TO "service_role"; +GRANT ALL ON TABLE "public"."review_feedback_comment" TO "anon"; +GRANT ALL ON TABLE "public"."review_feedback_comment" TO "authenticated"; +GRANT ALL ON TABLE "public"."review_feedback_comment" TO "service_role"; -GRANT ALL ON TABLE "public"."ReviewSuggestionSnippet" TO "anon"; -GRANT ALL ON TABLE "public"."ReviewSuggestionSnippet" TO "authenticated"; -GRANT ALL ON TABLE "public"."ReviewSuggestionSnippet" TO "service_role"; +GRANT ALL ON TABLE "public"."review_suggestion_snippet" TO "anon"; +GRANT ALL ON TABLE "public"."review_suggestion_snippet" TO "authenticated"; +GRANT ALL ON TABLE "public"."review_suggestion_snippet" TO "service_role"; -GRANT ALL ON TABLE "public"."User" TO "anon"; -GRANT ALL ON TABLE "public"."User" TO "authenticated"; -GRANT ALL ON TABLE "public"."User" TO "service_role"; +GRANT ALL ON TABLE "public"."user" TO "anon"; +GRANT ALL ON TABLE "public"."user" TO "authenticated"; +GRANT ALL ON TABLE "public"."user" TO "service_role"; diff --git a/frontend/packages/db/supabase/database.types.ts b/frontend/packages/db/supabase/database.types.ts index 18e1b43c0b..8dfd7b2716 100644 --- a/frontend/packages/db/supabase/database.types.ts +++ b/frontend/packages/db/supabase/database.types.ts @@ -34,243 +34,243 @@ export type Database = { } public: { Tables: { - GitHubDocFilePath: { + github_doc_file_path: { Row: { - createdAt: string + created_at: string id: string - isReviewEnabled: boolean + is_review_enabled: boolean path: string - projectId: string - updatedAt: string + project_id: string + updated_at: string } Insert: { - createdAt?: string + created_at?: string id?: string - isReviewEnabled?: boolean + is_review_enabled?: boolean path: string - projectId: string - updatedAt: string + project_id: string + updated_at: string } Update: { - createdAt?: string + created_at?: string id?: string - isReviewEnabled?: boolean + is_review_enabled?: boolean path?: string - projectId?: string - updatedAt?: string + project_id?: string + updated_at?: string } Relationships: [ { - foreignKeyName: 'GitHubDocFilePath_projectId_fkey' - columns: ['projectId'] + foreignKeyName: 'github_doc_file_path_project_id_fkey' + columns: ['project_id'] isOneToOne: false - referencedRelation: 'Project' + referencedRelation: 'project' referencedColumns: ['id'] }, ] } - GitHubSchemaFilePath: { + github_schema_file_path: { Row: { - createdAt: string - format: Database['public']['Enums']['SchemaFormatEnum'] + created_at: string + format: Database['public']['Enums']['schema_format_enum'] id: string path: string - projectId: string - updatedAt: string + project_id: string + updated_at: string } Insert: { - createdAt?: string - format: Database['public']['Enums']['SchemaFormatEnum'] + created_at?: string + format: Database['public']['Enums']['schema_format_enum'] id?: string path: string - projectId: string - updatedAt: string + project_id: string + updated_at: string } Update: { - createdAt?: string - format?: Database['public']['Enums']['SchemaFormatEnum'] + created_at?: string + format?: Database['public']['Enums']['schema_format_enum'] id?: string path?: string - projectId?: string - updatedAt?: string + project_id?: string + updated_at?: string } Relationships: [ { - foreignKeyName: 'GitHubSchemaFilePath_projectId_fkey' - columns: ['projectId'] + foreignKeyName: 'github_schema_file_path_project_id_fkey' + columns: ['project_id'] isOneToOne: false - referencedRelation: 'Project' + referencedRelation: 'project' referencedColumns: ['id'] }, ] } - KnowledgeSuggestion: { + knowledge_suggestion: { Row: { - approvedAt: string | null - branchName: string + approved_at: string | null + branch_name: string content: string - createdAt: string - fileSha: string | null + created_at: string + file_sha: string | null id: string path: string - projectId: string + project_id: string reasoning: string | null title: string - traceId: string | null - type: Database['public']['Enums']['KnowledgeType'] - updatedAt: string + trace_id: string | null + type: Database['public']['Enums']['knowledge_type'] + updated_at: string } Insert: { - approvedAt?: string | null - branchName: string + approved_at?: string | null + branch_name: string content: string - createdAt?: string - fileSha?: string | null + created_at?: string + file_sha?: string | null id?: string path: string - projectId: string + project_id: string reasoning?: string | null title: string - traceId?: string | null - type: Database['public']['Enums']['KnowledgeType'] - updatedAt: string + trace_id?: string | null + type: Database['public']['Enums']['knowledge_type'] + updated_at: string } Update: { - approvedAt?: string | null - branchName?: string + approved_at?: string | null + branch_name?: string content?: string - createdAt?: string - fileSha?: string | null + created_at?: string + file_sha?: string | null id?: string path?: string - projectId?: string + project_id?: string reasoning?: string | null title?: string - traceId?: string | null - type?: Database['public']['Enums']['KnowledgeType'] - updatedAt?: string + trace_id?: string | null + type?: Database['public']['Enums']['knowledge_type'] + updated_at?: string } Relationships: [ { - foreignKeyName: 'KnowledgeSuggestion_projectId_fkey' - columns: ['projectId'] + foreignKeyName: 'knowledge_suggestion_project_id_fkey' + columns: ['project_id'] isOneToOne: false - referencedRelation: 'Project' + referencedRelation: 'project' referencedColumns: ['id'] }, ] } - KnowledgeSuggestionDocMapping: { + knowledge_suggestion_doc_mapping: { Row: { - createdAt: string - gitHubDocFilePathId: string + created_at: string + github_doc_file_path_id: string id: string - knowledgeSuggestionId: string - updatedAt: string + knowledge_suggestion_id: string + updated_at: string } Insert: { - createdAt?: string - gitHubDocFilePathId: string + created_at?: string + github_doc_file_path_id: string id?: string - knowledgeSuggestionId: string - updatedAt: string + knowledge_suggestion_id: string + updated_at: string } Update: { - createdAt?: string - gitHubDocFilePathId?: string + created_at?: string + github_doc_file_path_id?: string id?: string - knowledgeSuggestionId?: string - updatedAt?: string + knowledge_suggestion_id?: string + updated_at?: string } Relationships: [ { - foreignKeyName: 'KnowledgeSuggestionDocMapping_gitHubDocFilePathId_fkey' - columns: ['gitHubDocFilePathId'] + foreignKeyName: 'knowledge_suggestion_doc_mapping_github_doc_file_path_id_fkey' + columns: ['github_doc_file_path_id'] isOneToOne: false - referencedRelation: 'GitHubDocFilePath' + referencedRelation: 'github_doc_file_path' referencedColumns: ['id'] }, { - foreignKeyName: 'KnowledgeSuggestionDocMapping_knowledgeSuggestionId_fkey' - columns: ['knowledgeSuggestionId'] + foreignKeyName: 'knowledge_suggestion_doc_mapping_knowledge_suggestion_id_fkey' + columns: ['knowledge_suggestion_id'] isOneToOne: false - referencedRelation: 'KnowledgeSuggestion' + referencedRelation: 'knowledge_suggestion' referencedColumns: ['id'] }, ] } - MembershipInvites: { + membership_invites: { Row: { email: string id: string - inviteByUserId: string - invitedAt: string | null - organizationId: string + invite_by_user_id: string + invited_at: string | null + organization_id: string } Insert: { email: string id?: string - inviteByUserId: string - invitedAt?: string | null - organizationId: string + invite_by_user_id: string + invited_at?: string | null + organization_id: string } Update: { email?: string id?: string - inviteByUserId?: string - invitedAt?: string | null - organizationId?: string + invite_by_user_id?: string + invited_at?: string | null + organization_id?: string } Relationships: [ { - foreignKeyName: 'MembershipInvites_inviteByUserId_fkey' - columns: ['inviteByUserId'] + foreignKeyName: 'membership_invites_invite_by_user_id_fkey' + columns: ['invite_by_user_id'] isOneToOne: false - referencedRelation: 'User' + referencedRelation: 'user' referencedColumns: ['id'] }, { - foreignKeyName: 'MembershipInvites_organizationId_fkey' - columns: ['organizationId'] + foreignKeyName: 'membership_invites_organization_id_fkey' + columns: ['organization_id'] isOneToOne: false - referencedRelation: 'Organization' + referencedRelation: 'organization' referencedColumns: ['id'] }, ] } - Migration: { + migration: { Row: { - createdAt: string + created_at: string id: string - pullRequestId: string + pull_request_id: string title: string - updatedAt: string + updated_at: string } Insert: { - createdAt?: string + created_at?: string id?: string - pullRequestId: string + pull_request_id: string title: string - updatedAt: string + updated_at: string } Update: { - createdAt?: string + created_at?: string id?: string - pullRequestId?: string + pull_request_id?: string title?: string - updatedAt?: string + updated_at?: string } Relationships: [ { - foreignKeyName: 'Migration_pullRequestId_fkey' - columns: ['pullRequestId'] + foreignKeyName: 'migration_pull_request_id_fkey' + columns: ['pull_request_id'] isOneToOne: false - referencedRelation: 'PullRequest' + referencedRelation: 'pull_request' referencedColumns: ['id'] }, ] } - Organization: { + organization: { Row: { id: string name: string @@ -285,393 +285,393 @@ export type Database = { } Relationships: [] } - OrganizationMember: { + organization_member: { Row: { id: string - joinedAt: string | null - organizationId: string - userId: string + joined_at: string | null + organization_id: string + user_id: string } Insert: { id?: string - joinedAt?: string | null - organizationId: string - userId: string + joined_at?: string | null + organization_id: string + user_id: string } Update: { id?: string - joinedAt?: string | null - organizationId?: string - userId?: string + joined_at?: string | null + organization_id?: string + user_id?: string } Relationships: [ { - foreignKeyName: 'OrganizationMember_organizationId_fkey' - columns: ['organizationId'] + foreignKeyName: 'organization_member_organization_id_fkey' + columns: ['organization_id'] isOneToOne: false - referencedRelation: 'Organization' + referencedRelation: 'organization' referencedColumns: ['id'] }, { - foreignKeyName: 'OrganizationMember_userId_fkey' - columns: ['userId'] + foreignKeyName: 'organization_member_user_id_fkey' + columns: ['user_id'] isOneToOne: false - referencedRelation: 'User' + referencedRelation: 'user' referencedColumns: ['id'] }, ] } - OverallReview: { + overall_review: { Row: { - branchName: string - createdAt: string + branch_name: string + created_at: string id: string - projectId: string | null - pullRequestId: string - reviewComment: string | null - reviewedAt: string - traceId: string | null - updatedAt: string + project_id: string | null + pull_request_id: string + review_comment: string | null + reviewed_at: string + trace_id: string | null + updated_at: string } Insert: { - branchName: string - createdAt?: string + branch_name: string + created_at?: string id?: string - projectId?: string | null - pullRequestId: string - reviewComment?: string | null - reviewedAt?: string - traceId?: string | null - updatedAt: string + project_id?: string | null + pull_request_id: string + review_comment?: string | null + reviewed_at?: string + trace_id?: string | null + updated_at: string } Update: { - branchName?: string - createdAt?: string + branch_name?: string + created_at?: string id?: string - projectId?: string | null - pullRequestId?: string - reviewComment?: string | null - reviewedAt?: string - traceId?: string | null - updatedAt?: string + project_id?: string | null + pull_request_id?: string + review_comment?: string | null + reviewed_at?: string + trace_id?: string | null + updated_at?: string } Relationships: [ { - foreignKeyName: 'OverallReview_projectId_fkey' - columns: ['projectId'] + foreignKeyName: 'overall_review_project_id_fkey' + columns: ['project_id'] isOneToOne: false - referencedRelation: 'Project' + referencedRelation: 'project' referencedColumns: ['id'] }, { - foreignKeyName: 'OverallReview_pullRequestId_fkey' - columns: ['pullRequestId'] + foreignKeyName: 'overall_review_pull_request_id_fkey' + columns: ['pull_request_id'] isOneToOne: false - referencedRelation: 'PullRequest' + referencedRelation: 'pull_request' referencedColumns: ['id'] }, ] } - OverallReviewKnowledgeSuggestionMapping: { + overall_review_knowledge_suggestion_mapping: { Row: { - createdAt: string + created_at: string id: string - knowledgeSuggestionId: string - overallReviewId: string - updatedAt: string + knowledge_suggestion_id: string + overall_review_id: string + updated_at: string } Insert: { - createdAt?: string + created_at?: string id?: string - knowledgeSuggestionId: string - overallReviewId: string - updatedAt: string + knowledge_suggestion_id: string + overall_review_id: string + updated_at: string } Update: { - createdAt?: string + created_at?: string id?: string - knowledgeSuggestionId?: string - overallReviewId?: string - updatedAt?: string + knowledge_suggestion_id?: string + overall_review_id?: string + updated_at?: string } Relationships: [ { - foreignKeyName: 'OverallReviewKnowledgeSuggestionMapping_knowledgeSuggestionId_f' - columns: ['knowledgeSuggestionId'] + foreignKeyName: 'overall_review_knowledge_suggestion_mapping_knowledge_suggestio' + columns: ['knowledge_suggestion_id'] isOneToOne: false - referencedRelation: 'KnowledgeSuggestion' + referencedRelation: 'knowledge_suggestion' referencedColumns: ['id'] }, { - foreignKeyName: 'OverallReviewKnowledgeSuggestionMapping_overallReviewId_fkey' - columns: ['overallReviewId'] + foreignKeyName: 'overall_review_knowledge_suggestion_mapping_overall_review_id_f' + columns: ['overall_review_id'] isOneToOne: false - referencedRelation: 'OverallReview' + referencedRelation: 'overall_review' referencedColumns: ['id'] }, ] } - Project: { + project: { Row: { - createdAt: string + created_at: string id: string name: string - organizationId: string | null - updatedAt: string + organization_id: string | null + updated_at: string } Insert: { - createdAt?: string + created_at?: string id?: string name: string - organizationId?: string | null - updatedAt: string + organization_id?: string | null + updated_at: string } Update: { - createdAt?: string + created_at?: string id?: string name?: string - organizationId?: string | null - updatedAt?: string + organization_id?: string | null + updated_at?: string } Relationships: [ { - foreignKeyName: 'Project_organizationId_fkey' - columns: ['organizationId'] + foreignKeyName: 'project_organization_id_fkey' + columns: ['organization_id'] isOneToOne: false - referencedRelation: 'Organization' + referencedRelation: 'organization' referencedColumns: ['id'] }, ] } - ProjectRepositoryMapping: { + project_repository_mapping: { Row: { - createdAt: string + created_at: string id: string - projectId: string - repositoryId: string - updatedAt: string + project_id: string + repository_id: string + updated_at: string } Insert: { - createdAt?: string + created_at?: string id?: string - projectId: string - repositoryId: string - updatedAt: string + project_id: string + repository_id: string + updated_at: string } Update: { - createdAt?: string + created_at?: string id?: string - projectId?: string - repositoryId?: string - updatedAt?: string + project_id?: string + repository_id?: string + updated_at?: string } Relationships: [ { - foreignKeyName: 'ProjectRepositoryMapping_projectId_fkey' - columns: ['projectId'] + foreignKeyName: 'project_repository_mapping_project_id_fkey' + columns: ['project_id'] isOneToOne: false - referencedRelation: 'Project' + referencedRelation: 'project' referencedColumns: ['id'] }, { - foreignKeyName: 'ProjectRepositoryMapping_repositoryId_fkey' - columns: ['repositoryId'] + foreignKeyName: 'project_repository_mapping_repository_id_fkey' + columns: ['repository_id'] isOneToOne: false - referencedRelation: 'Repository' + referencedRelation: 'repository' referencedColumns: ['id'] }, ] } - PullRequest: { + pull_request: { Row: { - commentId: number | null - createdAt: string + comment_id: number | null + created_at: string id: string - pullNumber: number - repositoryId: string - updatedAt: string + pull_number: number + repository_id: string + updated_at: string } Insert: { - commentId?: number | null - createdAt?: string + comment_id?: number | null + created_at?: string id?: string - pullNumber: number - repositoryId: string - updatedAt: string + pull_number: number + repository_id: string + updated_at: string } Update: { - commentId?: number | null - createdAt?: string + comment_id?: number | null + created_at?: string id?: string - pullNumber?: number - repositoryId?: string - updatedAt?: string + pull_number?: number + repository_id?: string + updated_at?: string } Relationships: [ { - foreignKeyName: 'PullRequest_repositoryId_fkey' - columns: ['repositoryId'] + foreignKeyName: 'pull_request_repository_id_fkey' + columns: ['repository_id'] isOneToOne: false - referencedRelation: 'Repository' + referencedRelation: 'repository' referencedColumns: ['id'] }, ] } - Repository: { + repository: { Row: { - createdAt: string + created_at: string id: string - installationId: number - isActive: boolean + installation_id: number + is_active: boolean name: string owner: string - updatedAt: string + updated_at: string } Insert: { - createdAt?: string + created_at?: string id?: string - installationId: number - isActive?: boolean + installation_id: number + is_active?: boolean name: string owner: string - updatedAt: string + updated_at: string } Update: { - createdAt?: string + created_at?: string id?: string - installationId?: number - isActive?: boolean + installation_id?: number + is_active?: boolean name?: string owner?: string - updatedAt?: string + updated_at?: string } Relationships: [] } - ReviewFeedback: { + review_feedback: { Row: { - category: Database['public']['Enums']['CategoryEnum'] - createdAt: string + category: Database['public']['Enums']['category_enum'] + created_at: string description: string id: string - overallReviewId: string - resolutionComment: string | null - resolvedAt: string | null - severity: Database['public']['Enums']['SeverityEnum'] + overall_review_id: string + resolution_comment: string | null + resolved_at: string | null + severity: Database['public']['Enums']['severity_enum'] suggestion: string - updatedAt: string + updated_at: string } Insert: { - category: Database['public']['Enums']['CategoryEnum'] - createdAt?: string + category: Database['public']['Enums']['category_enum'] + created_at?: string description: string id?: string - overallReviewId: string - resolutionComment?: string | null - resolvedAt?: string | null - severity: Database['public']['Enums']['SeverityEnum'] + overall_review_id: string + resolution_comment?: string | null + resolved_at?: string | null + severity: Database['public']['Enums']['severity_enum'] suggestion: string - updatedAt: string + updated_at: string } Update: { - category?: Database['public']['Enums']['CategoryEnum'] - createdAt?: string + category?: Database['public']['Enums']['category_enum'] + created_at?: string description?: string id?: string - overallReviewId?: string - resolutionComment?: string | null - resolvedAt?: string | null - severity?: Database['public']['Enums']['SeverityEnum'] + overall_review_id?: string + resolution_comment?: string | null + resolved_at?: string | null + severity?: Database['public']['Enums']['severity_enum'] suggestion?: string - updatedAt?: string + updated_at?: string } Relationships: [ { - foreignKeyName: 'ReviewFeedback_overallReviewId_fkey' - columns: ['overallReviewId'] + foreignKeyName: 'review_feedback_overall_review_id_fkey' + columns: ['overall_review_id'] isOneToOne: false - referencedRelation: 'OverallReview' + referencedRelation: 'overall_review' referencedColumns: ['id'] }, ] } - ReviewFeedbackComment: { + review_feedback_comment: { Row: { content: string - createdAt: string + created_at: string id: string - reviewFeedbackId: string - updatedAt: string - userId: string + review_feedback_id: string + updated_at: string + user_id: string } Insert: { content: string - createdAt?: string + created_at?: string id?: string - reviewFeedbackId: string - updatedAt: string - userId: string + review_feedback_id: string + updated_at: string + user_id: string } Update: { content?: string - createdAt?: string + created_at?: string id?: string - reviewFeedbackId?: string - updatedAt?: string - userId?: string + review_feedback_id?: string + updated_at?: string + user_id?: string } Relationships: [ { - foreignKeyName: 'ReviewFeedbackComment_reviewFeedbackId_fkey' - columns: ['reviewFeedbackId'] + foreignKeyName: 'review_feedback_comment_review_feedback_id_fkey' + columns: ['review_feedback_id'] isOneToOne: false - referencedRelation: 'ReviewFeedback' + referencedRelation: 'review_feedback' referencedColumns: ['id'] }, { - foreignKeyName: 'ReviewFeedbackComment_userId_fkey' - columns: ['userId'] + foreignKeyName: 'review_feedback_comment_user_id_fkey' + columns: ['user_id'] isOneToOne: false - referencedRelation: 'User' + referencedRelation: 'user' referencedColumns: ['id'] }, ] } - ReviewSuggestionSnippet: { + review_suggestion_snippet: { Row: { - createdAt: string + created_at: string filename: string id: string - reviewFeedbackId: string + review_feedback_id: string snippet: string - updatedAt: string + updated_at: string } Insert: { - createdAt?: string + created_at?: string filename: string id?: string - reviewFeedbackId: string + review_feedback_id: string snippet: string - updatedAt: string + updated_at: string } Update: { - createdAt?: string + created_at?: string filename?: string id?: string - reviewFeedbackId?: string + review_feedback_id?: string snippet?: string - updatedAt?: string + updated_at?: string } Relationships: [ { - foreignKeyName: 'ReviewSuggestionSnippet_reviewFeedbackId_fkey' - columns: ['reviewFeedbackId'] + foreignKeyName: 'review_suggestion_snippet_review_feedback_id_fkey' + columns: ['review_feedback_id'] isOneToOne: false - referencedRelation: 'ReviewFeedback' + referencedRelation: 'review_feedback' referencedColumns: ['id'] }, ] } - User: { + user: { Row: { email: string id: string @@ -700,15 +700,15 @@ export type Database = { } } Enums: { - CategoryEnum: + category_enum: | 'MIGRATION_SAFETY' | 'DATA_INTEGRITY' | 'PERFORMANCE_IMPACT' | 'PROJECT_RULES_CONSISTENCY' | 'SECURITY_OR_SCALABILITY' - KnowledgeType: 'SCHEMA' | 'DOCS' - SchemaFormatEnum: 'schemarb' | 'postgres' | 'prisma' | 'tbls' - SeverityEnum: 'CRITICAL' | 'WARNING' | 'POSITIVE' | 'QUESTION' + knowledge_type: 'SCHEMA' | 'DOCS' + schema_format_enum: 'schemarb' | 'postgres' | 'prisma' | 'tbls' + severity_enum: 'CRITICAL' | 'WARNING' | 'POSITIVE' | 'QUESTION' } CompositeTypes: { [_ in never]: never @@ -827,16 +827,16 @@ export const Constants = { }, public: { Enums: { - CategoryEnum: [ + category_enum: [ 'MIGRATION_SAFETY', 'DATA_INTEGRITY', 'PERFORMANCE_IMPACT', 'PROJECT_RULES_CONSISTENCY', 'SECURITY_OR_SCALABILITY', ], - KnowledgeType: ['SCHEMA', 'DOCS'], - SchemaFormatEnum: ['schemarb', 'postgres', 'prisma', 'tbls'], - SeverityEnum: ['CRITICAL', 'WARNING', 'POSITIVE', 'QUESTION'], + knowledge_type: ['SCHEMA', 'DOCS'], + schema_format_enum: ['schemarb', 'postgres', 'prisma', 'tbls'], + severity_enum: ['CRITICAL', 'WARNING', 'POSITIVE', 'QUESTION'], }, }, } as const diff --git a/frontend/packages/db/supabase/migrations/20250416105745_initial_squash.sql b/frontend/packages/db/supabase/migrations/20250416105745_initial_squash.sql index 395958082b..240ecd6a2a 100644 --- a/frontend/packages/db/supabase/migrations/20250416105745_initial_squash.sql +++ b/frontend/packages/db/supabase/migrations/20250416105745_initial_squash.sql @@ -63,7 +63,7 @@ CREATE EXTENSION IF NOT EXISTS "uuid-ossp" WITH SCHEMA "extensions"; -CREATE TYPE "public"."CategoryEnum" AS ENUM ( +CREATE TYPE "public"."category_enum" AS ENUM ( 'MIGRATION_SAFETY', 'DATA_INTEGRITY', 'PERFORMANCE_IMPACT', @@ -72,19 +72,19 @@ CREATE TYPE "public"."CategoryEnum" AS ENUM ( ); -ALTER TYPE "public"."CategoryEnum" OWNER TO "postgres"; +ALTER TYPE "public"."category_enum" OWNER TO "postgres"; -CREATE TYPE "public"."KnowledgeType" AS ENUM ( +CREATE TYPE "public"."knowledge_type" AS ENUM ( 'SCHEMA', 'DOCS' ); -ALTER TYPE "public"."KnowledgeType" OWNER TO "postgres"; +ALTER TYPE "public"."knowledge_type" OWNER TO "postgres"; -CREATE TYPE "public"."SchemaFormatEnum" AS ENUM ( +CREATE TYPE "public"."schema_format_enum" AS ENUM ( 'schemarb', 'postgres', 'prisma', @@ -92,10 +92,10 @@ CREATE TYPE "public"."SchemaFormatEnum" AS ENUM ( ); -ALTER TYPE "public"."SchemaFormatEnum" OWNER TO "postgres"; +ALTER TYPE "public"."schema_format_enum" OWNER TO "postgres"; -CREATE TYPE "public"."SeverityEnum" AS ENUM ( +CREATE TYPE "public"."severity_enum" AS ENUM ( 'CRITICAL', 'WARNING', 'POSITIVE', @@ -103,7 +103,7 @@ CREATE TYPE "public"."SeverityEnum" AS ENUM ( ); -ALTER TYPE "public"."SeverityEnum" OWNER TO "postgres"; +ALTER TYPE "public"."severity_enum" OWNER TO "postgres"; CREATE OR REPLACE FUNCTION "public"."handle_new_user"() RETURNS "trigger" @@ -111,7 +111,7 @@ CREATE OR REPLACE FUNCTION "public"."handle_new_user"() RETURNS "trigger" SET "search_path" TO '' AS $$ BEGIN - INSERT INTO public."User" (id, name, email) + INSERT INTO public."user" (id, name, email) VALUES ( NEW.id, COALESCE(NEW.raw_user_meta_data->>'name', NEW.email), @@ -129,13 +129,13 @@ CREATE OR REPLACE FUNCTION "public"."sync_existing_users"() RETURNS "void" LANGUAGE "plpgsql" SECURITY DEFINER AS $$ BEGIN - INSERT INTO public."User" (id, name, email) + INSERT INTO public."user" (id, name, email) SELECT au.id, COALESCE(au.raw_user_meta_data->>'name', au.email), au.email FROM auth.users au - LEFT JOIN public."User" pu ON au.id = pu.id + LEFT JOIN public."user" pu ON au.id = pu.id WHERE pu.id IS NULL; END; $$; @@ -148,17 +148,17 @@ SET default_tablespace = ''; SET default_table_access_method = "heap"; -CREATE TABLE IF NOT EXISTS "public"."GitHubDocFilePath" ( +CREATE TABLE IF NOT EXISTS "public"."github_doc_file_path" ( "id" uuid NOT NULL DEFAULT gen_random_uuid(), "path" "text" NOT NULL, - "isReviewEnabled" boolean DEFAULT true NOT NULL, - "projectId" uuid NOT NULL, - "createdAt" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "updatedAt" timestamp(3) without time zone NOT NULL + "is_review_enabled" boolean DEFAULT true NOT NULL, + "project_id" uuid NOT NULL, + "created_at" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "updated_at" timestamp(3) without time zone NOT NULL ); -ALTER TABLE "public"."GitHubDocFilePath" OWNER TO "postgres"; +ALTER TABLE "public"."github_doc_file_path" OWNER TO "postgres"; @@ -168,17 +168,17 @@ ALTER TABLE "public"."GitHubDocFilePath" OWNER TO "postgres"; -CREATE TABLE IF NOT EXISTS "public"."GitHubSchemaFilePath" ( +CREATE TABLE IF NOT EXISTS "public"."github_schema_file_path" ( "id" uuid NOT NULL DEFAULT gen_random_uuid(), "path" "text" NOT NULL, - "projectId" uuid NOT NULL, - "createdAt" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "updatedAt" timestamp(3) without time zone NOT NULL, - "format" "public"."SchemaFormatEnum" NOT NULL + "project_id" uuid NOT NULL, + "created_at" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "updated_at" timestamp(3) without time zone NOT NULL, + "format" "public"."schema_format_enum" NOT NULL ); -ALTER TABLE "public"."GitHubSchemaFilePath" OWNER TO "postgres"; +ALTER TABLE "public"."github_schema_file_path" OWNER TO "postgres"; @@ -188,36 +188,36 @@ ALTER TABLE "public"."GitHubSchemaFilePath" OWNER TO "postgres"; -CREATE TABLE IF NOT EXISTS "public"."KnowledgeSuggestion" ( +CREATE TABLE IF NOT EXISTS "public"."knowledge_suggestion" ( "id" uuid NOT NULL DEFAULT gen_random_uuid(), - "type" "public"."KnowledgeType" NOT NULL, + "type" "public"."knowledge_type" NOT NULL, "title" "text" NOT NULL, "path" "text" NOT NULL, "content" "text" NOT NULL, - "fileSha" "text", - "projectId" uuid NOT NULL, - "approvedAt" timestamp(3) without time zone, - "createdAt" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "updatedAt" timestamp(3) without time zone NOT NULL, - "branchName" "text" NOT NULL, - "traceId" "text", + "file_sha" "text", + "project_id" uuid NOT NULL, + "approved_at" timestamp(3) without time zone, + "created_at" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "updated_at" timestamp(3) without time zone NOT NULL, + "branch_name" "text" NOT NULL, + "trace_id" "text", "reasoning" "text" DEFAULT ''::"text" ); -ALTER TABLE "public"."KnowledgeSuggestion" OWNER TO "postgres"; +ALTER TABLE "public"."knowledge_suggestion" OWNER TO "postgres"; -CREATE TABLE IF NOT EXISTS "public"."KnowledgeSuggestionDocMapping" ( +CREATE TABLE IF NOT EXISTS "public"."knowledge_suggestion_doc_mapping" ( "id" uuid NOT NULL DEFAULT gen_random_uuid(), - "knowledgeSuggestionId" uuid NOT NULL, - "gitHubDocFilePathId" uuid NOT NULL, - "createdAt" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "updatedAt" timestamp(3) without time zone NOT NULL + "knowledge_suggestion_id" uuid NOT NULL, + "github_doc_file_path_id" uuid NOT NULL, + "created_at" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "updated_at" timestamp(3) without time zone NOT NULL ); -ALTER TABLE "public"."KnowledgeSuggestionDocMapping" OWNER TO "postgres"; +ALTER TABLE "public"."knowledge_suggestion_doc_mapping" OWNER TO "postgres"; @@ -234,28 +234,28 @@ ALTER TABLE "public"."KnowledgeSuggestionDocMapping" OWNER TO "postgres"; -CREATE TABLE IF NOT EXISTS "public"."MembershipInvites" ( +CREATE TABLE IF NOT EXISTS "public"."membership_invites" ( "id" uuid NOT NULL DEFAULT gen_random_uuid(), "email" "text" NOT NULL, - "inviteByUserId" "uuid" NOT NULL, - "organizationId" uuid NOT NULL, - "invitedAt" timestamp with time zone DEFAULT CURRENT_TIMESTAMP + "invite_by_user_id" "uuid" NOT NULL, + "organization_id" uuid NOT NULL, + "invited_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP ); -ALTER TABLE "public"."MembershipInvites" OWNER TO "postgres"; +ALTER TABLE "public"."membership_invites" OWNER TO "postgres"; -CREATE TABLE IF NOT EXISTS "public"."Migration" ( +CREATE TABLE IF NOT EXISTS "public"."migration" ( "id" uuid NOT NULL DEFAULT gen_random_uuid(), "title" "text" NOT NULL, - "pullRequestId" uuid NOT NULL, - "createdAt" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "updatedAt" timestamp(3) without time zone NOT NULL + "pull_request_id" uuid NOT NULL, + "created_at" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "updated_at" timestamp(3) without time zone NOT NULL ); -ALTER TABLE "public"."Migration" OWNER TO "postgres"; +ALTER TABLE "public"."migration" OWNER TO "postgres"; @@ -265,54 +265,54 @@ ALTER TABLE "public"."Migration" OWNER TO "postgres"; -CREATE TABLE IF NOT EXISTS "public"."Organization" ( +CREATE TABLE IF NOT EXISTS "public"."organization" ( "id" uuid NOT NULL DEFAULT gen_random_uuid(), "name" "text" NOT NULL ); -ALTER TABLE "public"."Organization" OWNER TO "postgres"; +ALTER TABLE "public"."organization" OWNER TO "postgres"; -CREATE TABLE IF NOT EXISTS "public"."OrganizationMember" ( +CREATE TABLE IF NOT EXISTS "public"."organization_member" ( "id" uuid NOT NULL DEFAULT gen_random_uuid(), - "userId" "uuid" NOT NULL, - "organizationId" uuid NOT NULL, - "joinedAt" timestamp with time zone DEFAULT CURRENT_TIMESTAMP + "user_id" "uuid" NOT NULL, + "organization_id" uuid NOT NULL, + "joined_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP ); -ALTER TABLE "public"."OrganizationMember" OWNER TO "postgres"; +ALTER TABLE "public"."organization_member" OWNER TO "postgres"; -CREATE TABLE IF NOT EXISTS "public"."OverallReview" ( +CREATE TABLE IF NOT EXISTS "public"."overall_review" ( "id" uuid NOT NULL DEFAULT gen_random_uuid(), - "projectId" uuid, - "pullRequestId" uuid NOT NULL, - "reviewComment" "text", - "reviewedAt" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "createdAt" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "updatedAt" timestamp(3) without time zone NOT NULL, - "branchName" "text" NOT NULL, - "traceId" "text" + "project_id" uuid, + "pull_request_id" uuid NOT NULL, + "review_comment" "text", + "reviewed_at" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "created_at" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "updated_at" timestamp(3) without time zone NOT NULL, + "branch_name" "text" NOT NULL, + "trace_id" "text" ); -ALTER TABLE "public"."OverallReview" OWNER TO "postgres"; +ALTER TABLE "public"."overall_review" OWNER TO "postgres"; -CREATE TABLE IF NOT EXISTS "public"."OverallReviewKnowledgeSuggestionMapping" ( +CREATE TABLE IF NOT EXISTS "public"."overall_review_knowledge_suggestion_mapping" ( "id" uuid NOT NULL DEFAULT gen_random_uuid(), - "overallReviewId" uuid NOT NULL, - "knowledgeSuggestionId" uuid NOT NULL, - "createdAt" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "updatedAt" timestamp(3) without time zone NOT NULL + "overall_review_id" uuid NOT NULL, + "knowledge_suggestion_id" uuid NOT NULL, + "created_at" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "updated_at" timestamp(3) without time zone NOT NULL ); -ALTER TABLE "public"."OverallReviewKnowledgeSuggestionMapping" OWNER TO "postgres"; +ALTER TABLE "public"."overall_review_knowledge_suggestion_mapping" OWNER TO "postgres"; @@ -329,27 +329,27 @@ ALTER TABLE "public"."OverallReviewKnowledgeSuggestionMapping" OWNER TO "postgre -CREATE TABLE IF NOT EXISTS "public"."Project" ( +CREATE TABLE IF NOT EXISTS "public"."project" ( "id" uuid NOT NULL DEFAULT gen_random_uuid(), "name" "text" NOT NULL, - "createdAt" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "updatedAt" timestamp(3) without time zone NOT NULL, - "organizationId" uuid ); + "created_at" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "updated_at" timestamp(3) without time zone NOT NULL, + "organization_id" uuid ); -ALTER TABLE "public"."Project" OWNER TO "postgres"; +ALTER TABLE "public"."project" OWNER TO "postgres"; -CREATE TABLE IF NOT EXISTS "public"."ProjectRepositoryMapping" ( +CREATE TABLE IF NOT EXISTS "public"."project_repository_mapping" ( "id" uuid NOT NULL DEFAULT gen_random_uuid(), - "projectId" uuid NOT NULL, - "repositoryId" uuid NOT NULL, - "createdAt" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "updatedAt" timestamp(3) without time zone NOT NULL + "project_id" uuid NOT NULL, + "repository_id" uuid NOT NULL, + "created_at" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "updated_at" timestamp(3) without time zone NOT NULL ); -ALTER TABLE "public"."ProjectRepositoryMapping" OWNER TO "postgres"; +ALTER TABLE "public"."project_repository_mapping" OWNER TO "postgres"; @@ -366,17 +366,17 @@ ALTER TABLE "public"."ProjectRepositoryMapping" OWNER TO "postgres"; -CREATE TABLE IF NOT EXISTS "public"."PullRequest" ( +CREATE TABLE IF NOT EXISTS "public"."pull_request" ( "id" uuid NOT NULL DEFAULT gen_random_uuid(), - "pullNumber" bigint NOT NULL, - "commentId" bigint, - "createdAt" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "updatedAt" timestamp(3) without time zone NOT NULL, - "repositoryId" uuid NOT NULL + "pull_number" bigint NOT NULL, + "comment_id" bigint, + "created_at" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "updated_at" timestamp(3) without time zone NOT NULL, + "repository_id" uuid NOT NULL ); -ALTER TABLE "public"."PullRequest" OWNER TO "postgres"; +ALTER TABLE "public"."pull_request" OWNER TO "postgres"; @@ -386,18 +386,18 @@ ALTER TABLE "public"."PullRequest" OWNER TO "postgres"; -CREATE TABLE IF NOT EXISTS "public"."Repository" ( +CREATE TABLE IF NOT EXISTS "public"."repository" ( "id" uuid NOT NULL DEFAULT gen_random_uuid(), "name" "text" NOT NULL, "owner" "text" NOT NULL, - "installationId" integer NOT NULL, - "isActive" boolean DEFAULT true NOT NULL, - "createdAt" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "updatedAt" timestamp(3) without time zone NOT NULL + "installation_id" integer NOT NULL, + "is_active" boolean DEFAULT true NOT NULL, + "created_at" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "updated_at" timestamp(3) without time zone NOT NULL ); -ALTER TABLE "public"."Repository" OWNER TO "postgres"; +ALTER TABLE "public"."repository" OWNER TO "postgres"; @@ -407,38 +407,38 @@ ALTER TABLE "public"."Repository" OWNER TO "postgres"; -CREATE TABLE IF NOT EXISTS "public"."ReviewFeedback" ( +CREATE TABLE IF NOT EXISTS "public"."review_feedback" ( "id" uuid NOT NULL DEFAULT gen_random_uuid(), - "overallReviewId" uuid NOT NULL, - "category" "public"."CategoryEnum" NOT NULL, - "severity" "public"."SeverityEnum" NOT NULL, + "overall_review_id" uuid NOT NULL, + "category" "public"."category_enum" NOT NULL, + "severity" "public"."severity_enum" NOT NULL, "description" "text" NOT NULL, - "createdAt" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "updatedAt" timestamp(3) without time zone NOT NULL, + "created_at" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "updated_at" timestamp(3) without time zone NOT NULL, "suggestion" "text" NOT NULL, - "resolvedAt" timestamp(3) without time zone, - "resolutionComment" "text" + "resolved_at" timestamp(3) without time zone, + "resolution_comment" "text" ); -ALTER TABLE "public"."ReviewFeedback" OWNER TO "postgres"; +ALTER TABLE "public"."review_feedback" OWNER TO "postgres"; -CREATE TABLE IF NOT EXISTS "public"."ReviewFeedbackComment" ( +CREATE TABLE IF NOT EXISTS "public"."review_feedback_comment" ( "id" uuid DEFAULT gen_random_uuid(), - "reviewFeedbackId" uuid NOT NULL, - "userId" "uuid" NOT NULL, + "review_feedback_id" uuid NOT NULL, + "user_id" "uuid" NOT NULL, "content" "text" NOT NULL, - "createdAt" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "updatedAt" timestamp(3) without time zone NOT NULL + "created_at" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "updated_at" timestamp(3) without time zone NOT NULL ); -ALTER TABLE "public"."ReviewFeedbackComment" OWNER TO "postgres"; +ALTER TABLE "public"."review_feedback_comment" OWNER TO "postgres"; @@ -452,27 +452,27 @@ ALTER TABLE "public"."ReviewFeedbackComment" OWNER TO "postgres"; -CREATE TABLE IF NOT EXISTS "public"."ReviewSuggestionSnippet" ( +CREATE TABLE IF NOT EXISTS "public"."review_suggestion_snippet" ( "id" uuid DEFAULT gen_random_uuid(), - "reviewFeedbackId" uuid NOT NULL, + "review_feedback_id" uuid NOT NULL, "filename" "text" NOT NULL, "snippet" "text" NOT NULL, - "createdAt" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "updatedAt" timestamp(3) without time zone NOT NULL + "created_at" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "updated_at" timestamp(3) without time zone NOT NULL ); -ALTER TABLE "public"."ReviewSuggestionSnippet" OWNER TO "postgres"; +ALTER TABLE "public"."review_suggestion_snippet" OWNER TO "postgres"; -CREATE TABLE IF NOT EXISTS "public"."User" ( +CREATE TABLE IF NOT EXISTS "public"."user" ( "id" "uuid" NOT NULL, "name" "text" NOT NULL, "email" "text" NOT NULL ); -ALTER TABLE "public"."User" OWNER TO "postgres"; +ALTER TABLE "public"."user" OWNER TO "postgres"; @@ -511,351 +511,351 @@ ALTER TABLE "public"."User" OWNER TO "postgres"; -ALTER TABLE ONLY "public"."GitHubDocFilePath" - ADD CONSTRAINT "GitHubDocFilePath_pkey" PRIMARY KEY ("id"); +ALTER TABLE ONLY "public"."github_doc_file_path" + ADD CONSTRAINT "github_doc_file_path_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."GitHubSchemaFilePath" - ADD CONSTRAINT "GitHubSchemaFilePath_path_projectId_key" UNIQUE ("path", "projectId"); +ALTER TABLE ONLY "public"."github_schema_file_path" + ADD CONSTRAINT "github_schema_file_path_path_project_id_key" UNIQUE ("path", "project_id"); -ALTER TABLE ONLY "public"."GitHubSchemaFilePath" - ADD CONSTRAINT "GitHubSchemaFilePath_pkey" PRIMARY KEY ("id"); +ALTER TABLE ONLY "public"."github_schema_file_path" + ADD CONSTRAINT "github_schema_file_path_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."KnowledgeSuggestionDocMapping" - ADD CONSTRAINT "KnowledgeSuggestionDocMapping_pkey" PRIMARY KEY ("id"); +ALTER TABLE ONLY "public"."knowledge_suggestion_doc_mapping" + ADD CONSTRAINT "knowledge_suggestion_doc_mapping_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."KnowledgeSuggestion" - ADD CONSTRAINT "KnowledgeSuggestion_pkey" PRIMARY KEY ("id"); +ALTER TABLE ONLY "public"."knowledge_suggestion" + ADD CONSTRAINT "knowledge_suggestion_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."MembershipInvites" - ADD CONSTRAINT "MembershipInvites_pkey" PRIMARY KEY ("id"); +ALTER TABLE ONLY "public"."membership_invites" + ADD CONSTRAINT "membership_invites_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."Migration" - ADD CONSTRAINT "Migration_pkey" PRIMARY KEY ("id"); +ALTER TABLE ONLY "public"."migration" + ADD CONSTRAINT "migration_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."OrganizationMember" - ADD CONSTRAINT "OrganizationMember_pkey" PRIMARY KEY ("id"); +ALTER TABLE ONLY "public"."organization_member" + ADD CONSTRAINT "organization_member_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."OrganizationMember" - ADD CONSTRAINT "OrganizationMember_userId_organizationId_key" UNIQUE ("userId", "organizationId"); +ALTER TABLE ONLY "public"."organization_member" + ADD CONSTRAINT "organization_member_user_id_organization_id_key" UNIQUE ("user_id", "organization_id"); -ALTER TABLE ONLY "public"."Organization" - ADD CONSTRAINT "Organization_pkey" PRIMARY KEY ("id"); +ALTER TABLE ONLY "public"."organization" + ADD CONSTRAINT "organization_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."OverallReviewKnowledgeSuggestionMapping" - ADD CONSTRAINT "OverallReviewKnowledgeSuggestionMapping_pkey" PRIMARY KEY ("id"); +ALTER TABLE ONLY "public"."overall_review_knowledge_suggestion_mapping" + ADD CONSTRAINT "overall_review_knowledge_suggestion_mapping_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."OverallReview" - ADD CONSTRAINT "OverallReview_pkey" PRIMARY KEY ("id"); +ALTER TABLE ONLY "public"."overall_review" + ADD CONSTRAINT "overall_review_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."ProjectRepositoryMapping" - ADD CONSTRAINT "ProjectRepositoryMapping_pkey" PRIMARY KEY ("id"); +ALTER TABLE ONLY "public"."project_repository_mapping" + ADD CONSTRAINT "project_repository_mapping_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."Project" - ADD CONSTRAINT "Project_pkey" PRIMARY KEY ("id"); +ALTER TABLE ONLY "public"."project" + ADD CONSTRAINT "project_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."PullRequest" - ADD CONSTRAINT "PullRequest_pkey" PRIMARY KEY ("id"); +ALTER TABLE ONLY "public"."pull_request" + ADD CONSTRAINT "pull_request_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."Repository" - ADD CONSTRAINT "Repository_pkey" PRIMARY KEY ("id"); +ALTER TABLE ONLY "public"."repository" + ADD CONSTRAINT "repository_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."ReviewFeedbackComment" - ADD CONSTRAINT "ReviewFeedbackComment_pkey" PRIMARY KEY ("id"); +ALTER TABLE ONLY "public"."review_feedback_comment" + ADD CONSTRAINT "review_feedback_comment_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."ReviewFeedback" - ADD CONSTRAINT "ReviewFeedback_pkey" PRIMARY KEY ("id"); +ALTER TABLE ONLY "public"."review_feedback" + ADD CONSTRAINT "review_feedback_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."ReviewSuggestionSnippet" - ADD CONSTRAINT "ReviewSuggestionSnippet_pkey" PRIMARY KEY ("id"); +ALTER TABLE ONLY "public"."review_suggestion_snippet" + ADD CONSTRAINT "review_suggestion_snippet_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."User" - ADD CONSTRAINT "User_email_key" UNIQUE ("email"); +ALTER TABLE ONLY "public"."user" + ADD CONSTRAINT "user_email_key" UNIQUE ("email"); -ALTER TABLE ONLY "public"."User" - ADD CONSTRAINT "User_pkey" PRIMARY KEY ("id"); +ALTER TABLE ONLY "public"."user" + ADD CONSTRAINT "user_pkey" PRIMARY KEY ("id"); -CREATE UNIQUE INDEX "GitHubDocFilePath_path_projectId_key" ON "public"."GitHubDocFilePath" USING "btree" ("path", "projectId"); +CREATE UNIQUE INDEX "github_doc_file_path_path_project_id_key" ON "public"."github_doc_file_path" USING "btree" ("path", "project_id"); -CREATE UNIQUE INDEX "GitHubSchemaFilePath_projectId_key" ON "public"."GitHubSchemaFilePath" USING "btree" ("projectId"); +CREATE UNIQUE INDEX "github_schema_file_path_project_id_key" ON "public"."github_schema_file_path" USING "btree" ("project_id"); -CREATE UNIQUE INDEX "KnowledgeSuggestionDocMapping_unique_mapping" ON "public"."KnowledgeSuggestionDocMapping" USING "btree" ("knowledgeSuggestionId", "gitHubDocFilePathId"); +CREATE UNIQUE INDEX "knowledge_suggestion_doc_mapping_unique_mapping" ON "public"."knowledge_suggestion_doc_mapping" USING "btree" ("knowledge_suggestion_id", "github_doc_file_path_id"); -CREATE UNIQUE INDEX "Migration_pullRequestId_key" ON "public"."Migration" USING "btree" ("pullRequestId"); +CREATE UNIQUE INDEX "migration_pull_request_id_key" ON "public"."migration" USING "btree" ("pull_request_id"); -CREATE UNIQUE INDEX "OverallReviewKnowledgeSuggestionMapping_unique_mapping" ON "public"."OverallReviewKnowledgeSuggestionMapping" USING "btree" ("overallReviewId", "knowledgeSuggestionId"); +CREATE UNIQUE INDEX "overall_review_knowledge_suggestion_mapping_unique_mapping" ON "public"."overall_review_knowledge_suggestion_mapping" USING "btree" ("overall_review_id", "knowledge_suggestion_id"); -CREATE UNIQUE INDEX "ProjectRepositoryMapping_projectId_repositoryId_key" ON "public"."ProjectRepositoryMapping" USING "btree" ("projectId", "repositoryId"); +CREATE UNIQUE INDEX "project_repository_mapping_project_id_repository_id_key" ON "public"."project_repository_mapping" USING "btree" ("project_id", "repository_id"); -CREATE UNIQUE INDEX "PullRequest_repositoryId_pullNumber_key" ON "public"."PullRequest" USING "btree" ("repositoryId", "pullNumber"); +CREATE UNIQUE INDEX "pull_request_repository_id_pull_number_key" ON "public"."pull_request" USING "btree" ("repository_id", "pull_number"); -CREATE UNIQUE INDEX "Repository_owner_name_key" ON "public"."Repository" USING "btree" ("owner", "name"); +CREATE UNIQUE INDEX "repository_owner_name_key" ON "public"."repository" USING "btree" ("owner", "name"); -CREATE INDEX "idx_project_organizationId" ON "public"."Project" USING "btree" ("organizationId"); +CREATE INDEX "idx_project_organization_id" ON "public"."project" USING "btree" ("organization_id"); -CREATE INDEX "idx_review_feedback_comment_review_feedback_id" ON "public"."ReviewFeedbackComment" USING "btree" ("reviewFeedbackId"); +CREATE INDEX "idx_review_feedback_comment_review_feedback_id" ON "public"."review_feedback_comment" USING "btree" ("review_feedback_id"); -CREATE INDEX "membership_invites_email_idx" ON "public"."MembershipInvites" USING "btree" ("email"); +CREATE INDEX "membership_invites_email_idx" ON "public"."membership_invites" USING "btree" ("email"); -CREATE INDEX "membership_invites_orgId_idx" ON "public"."MembershipInvites" USING "btree" ("organizationId"); +CREATE INDEX "membership_invites_org_id_idx" ON "public"."membership_invites" USING "btree" ("organization_id"); -CREATE INDEX "organization_member_organizationId_idx" ON "public"."OrganizationMember" USING "btree" ("organizationId"); +CREATE INDEX "organization_member_organization_id_idx" ON "public"."organization_member" USING "btree" ("organization_id"); -CREATE INDEX "organization_member_userId_idx" ON "public"."OrganizationMember" USING "btree" ("userId"); +CREATE INDEX "organization_member_user_id_idx" ON "public"."organization_member" USING "btree" ("user_id"); -ALTER TABLE ONLY "public"."GitHubDocFilePath" - ADD CONSTRAINT "GitHubDocFilePath_projectId_fkey" FOREIGN KEY ("projectId") REFERENCES "public"."Project"("id") ON UPDATE CASCADE ON DELETE RESTRICT; +ALTER TABLE ONLY "public"."github_doc_file_path" + ADD CONSTRAINT "github_doc_file_path_project_id_fkey" FOREIGN KEY ("project_id") REFERENCES "public"."project"("id") ON UPDATE CASCADE ON DELETE RESTRICT; -ALTER TABLE ONLY "public"."GitHubSchemaFilePath" - ADD CONSTRAINT "GitHubSchemaFilePath_projectId_fkey" FOREIGN KEY ("projectId") REFERENCES "public"."Project"("id") ON UPDATE CASCADE ON DELETE RESTRICT; +ALTER TABLE ONLY "public"."github_schema_file_path" + ADD CONSTRAINT "github_schema_file_path_project_id_fkey" FOREIGN KEY ("project_id") REFERENCES "public"."project"("id") ON UPDATE CASCADE ON DELETE RESTRICT; -ALTER TABLE ONLY "public"."KnowledgeSuggestionDocMapping" - ADD CONSTRAINT "KnowledgeSuggestionDocMapping_gitHubDocFilePathId_fkey" FOREIGN KEY ("gitHubDocFilePathId") REFERENCES "public"."GitHubDocFilePath"("id") ON UPDATE CASCADE ON DELETE CASCADE; +ALTER TABLE ONLY "public"."knowledge_suggestion_doc_mapping" + ADD CONSTRAINT "knowledge_suggestion_doc_mapping_github_doc_file_path_id_fkey" FOREIGN KEY ("github_doc_file_path_id") REFERENCES "public"."github_doc_file_path"("id") ON UPDATE CASCADE ON DELETE CASCADE; -ALTER TABLE ONLY "public"."KnowledgeSuggestionDocMapping" - ADD CONSTRAINT "KnowledgeSuggestionDocMapping_knowledgeSuggestionId_fkey" FOREIGN KEY ("knowledgeSuggestionId") REFERENCES "public"."KnowledgeSuggestion"("id") ON UPDATE CASCADE ON DELETE CASCADE; +ALTER TABLE ONLY "public"."knowledge_suggestion_doc_mapping" + ADD CONSTRAINT "knowledge_suggestion_doc_mapping_knowledge_suggestion_id_fkey" FOREIGN KEY ("knowledge_suggestion_id") REFERENCES "public"."knowledge_suggestion"("id") ON UPDATE CASCADE ON DELETE CASCADE; -ALTER TABLE ONLY "public"."KnowledgeSuggestion" - ADD CONSTRAINT "KnowledgeSuggestion_projectId_fkey" FOREIGN KEY ("projectId") REFERENCES "public"."Project"("id") ON UPDATE CASCADE ON DELETE RESTRICT; +ALTER TABLE ONLY "public"."knowledge_suggestion" + ADD CONSTRAINT "knowledge_suggestion_project_id_fkey" FOREIGN KEY ("project_id") REFERENCES "public"."project"("id") ON UPDATE CASCADE ON DELETE RESTRICT; -ALTER TABLE ONLY "public"."MembershipInvites" - ADD CONSTRAINT "MembershipInvites_inviteByUserId_fkey" FOREIGN KEY ("inviteByUserId") REFERENCES "public"."User"("id") ON DELETE CASCADE; +ALTER TABLE ONLY "public"."membership_invites" + ADD CONSTRAINT "membership_invites_invite_by_user_id_fkey" FOREIGN KEY ("invite_by_user_id") REFERENCES "public"."user"("id") ON DELETE CASCADE; -ALTER TABLE ONLY "public"."MembershipInvites" - ADD CONSTRAINT "MembershipInvites_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "public"."Organization"("id") ON DELETE CASCADE; +ALTER TABLE ONLY "public"."membership_invites" + ADD CONSTRAINT "membership_invites_organization_id_fkey" FOREIGN KEY ("organization_id") REFERENCES "public"."organization"("id") ON DELETE CASCADE; -ALTER TABLE ONLY "public"."Migration" - ADD CONSTRAINT "Migration_pullRequestId_fkey" FOREIGN KEY ("pullRequestId") REFERENCES "public"."PullRequest"("id") ON UPDATE CASCADE ON DELETE RESTRICT; +ALTER TABLE ONLY "public"."migration" + ADD CONSTRAINT "migration_pull_request_id_fkey" FOREIGN KEY ("pull_request_id") REFERENCES "public"."pull_request"("id") ON UPDATE CASCADE ON DELETE RESTRICT; -ALTER TABLE ONLY "public"."OrganizationMember" - ADD CONSTRAINT "OrganizationMember_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "public"."Organization"("id") ON DELETE CASCADE; +ALTER TABLE ONLY "public"."organization_member" + ADD CONSTRAINT "organization_member_organization_id_fkey" FOREIGN KEY ("organization_id") REFERENCES "public"."organization"("id") ON DELETE CASCADE; -ALTER TABLE ONLY "public"."OrganizationMember" - ADD CONSTRAINT "OrganizationMember_userId_fkey" FOREIGN KEY ("userId") REFERENCES "public"."User"("id") ON DELETE CASCADE; +ALTER TABLE ONLY "public"."organization_member" + ADD CONSTRAINT "organization_member_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE CASCADE; -ALTER TABLE ONLY "public"."OverallReviewKnowledgeSuggestionMapping" - ADD CONSTRAINT "OverallReviewKnowledgeSuggestionMapping_knowledgeSuggestionId_f" FOREIGN KEY ("knowledgeSuggestionId") REFERENCES "public"."KnowledgeSuggestion"("id") ON UPDATE CASCADE ON DELETE CASCADE; +ALTER TABLE ONLY "public"."overall_review_knowledge_suggestion_mapping" + ADD CONSTRAINT "overall_review_knowledge_suggestion_mapping_knowledge_suggestion_id_f" FOREIGN KEY ("knowledge_suggestion_id") REFERENCES "public"."knowledge_suggestion"("id") ON UPDATE CASCADE ON DELETE CASCADE; -ALTER TABLE ONLY "public"."OverallReviewKnowledgeSuggestionMapping" - ADD CONSTRAINT "OverallReviewKnowledgeSuggestionMapping_overallReviewId_fkey" FOREIGN KEY ("overallReviewId") REFERENCES "public"."OverallReview"("id") ON UPDATE CASCADE ON DELETE CASCADE; +ALTER TABLE ONLY "public"."overall_review_knowledge_suggestion_mapping" + ADD CONSTRAINT "overall_review_knowledge_suggestion_mapping_overall_review_id_fkey" FOREIGN KEY ("overall_review_id") REFERENCES "public"."overall_review"("id") ON UPDATE CASCADE ON DELETE CASCADE; -ALTER TABLE ONLY "public"."OverallReview" - ADD CONSTRAINT "OverallReview_projectId_fkey" FOREIGN KEY ("projectId") REFERENCES "public"."Project"("id") ON UPDATE CASCADE ON DELETE SET NULL; +ALTER TABLE ONLY "public"."overall_review" + ADD CONSTRAINT "overall_review_project_id_fkey" FOREIGN KEY ("project_id") REFERENCES "public"."project"("id") ON UPDATE CASCADE ON DELETE SET NULL; -ALTER TABLE ONLY "public"."OverallReview" - ADD CONSTRAINT "OverallReview_pullRequestId_fkey" FOREIGN KEY ("pullRequestId") REFERENCES "public"."PullRequest"("id") ON UPDATE CASCADE ON DELETE RESTRICT; +ALTER TABLE ONLY "public"."overall_review" + ADD CONSTRAINT "overall_review_pull_request_id_fkey" FOREIGN KEY ("pull_request_id") REFERENCES "public"."pull_request"("id") ON UPDATE CASCADE ON DELETE RESTRICT; -ALTER TABLE ONLY "public"."ProjectRepositoryMapping" - ADD CONSTRAINT "ProjectRepositoryMapping_projectId_fkey" FOREIGN KEY ("projectId") REFERENCES "public"."Project"("id") ON UPDATE CASCADE ON DELETE RESTRICT; +ALTER TABLE ONLY "public"."project_repository_mapping" + ADD CONSTRAINT "project_repository_mapping_project_id_fkey" FOREIGN KEY ("project_id") REFERENCES "public"."project"("id") ON UPDATE CASCADE ON DELETE RESTRICT; -ALTER TABLE ONLY "public"."ProjectRepositoryMapping" - ADD CONSTRAINT "ProjectRepositoryMapping_repositoryId_fkey" FOREIGN KEY ("repositoryId") REFERENCES "public"."Repository"("id") ON UPDATE CASCADE ON DELETE RESTRICT; +ALTER TABLE ONLY "public"."project_repository_mapping" + ADD CONSTRAINT "project_repository_mapping_repository_id_fkey" FOREIGN KEY ("repository_id") REFERENCES "public"."repository"("id") ON UPDATE CASCADE ON DELETE RESTRICT; -ALTER TABLE ONLY "public"."Project" - ADD CONSTRAINT "Project_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "public"."Organization"("id") ON UPDATE CASCADE ON DELETE CASCADE; +ALTER TABLE ONLY "public"."project" + ADD CONSTRAINT "project_organization_id_fkey" FOREIGN KEY ("organization_id") REFERENCES "public"."organization"("id") ON UPDATE CASCADE ON DELETE CASCADE; -ALTER TABLE ONLY "public"."PullRequest" - ADD CONSTRAINT "PullRequest_repositoryId_fkey" FOREIGN KEY ("repositoryId") REFERENCES "public"."Repository"("id") ON UPDATE CASCADE ON DELETE RESTRICT; +ALTER TABLE ONLY "public"."pull_request" + ADD CONSTRAINT "pull_request_repository_id_fkey" FOREIGN KEY ("repository_id") REFERENCES "public"."repository"("id") ON UPDATE CASCADE ON DELETE RESTRICT; -ALTER TABLE ONLY "public"."ReviewFeedbackComment" - ADD CONSTRAINT "ReviewFeedbackComment_reviewFeedbackId_fkey" FOREIGN KEY ("reviewFeedbackId") REFERENCES "public"."ReviewFeedback"("id") ON UPDATE CASCADE ON DELETE CASCADE; +ALTER TABLE ONLY "public"."review_feedback_comment" + ADD CONSTRAINT "review_feedback_comment_review_feedback_id_fkey" FOREIGN KEY ("review_feedback_id") REFERENCES "public"."review_feedback"("id") ON UPDATE CASCADE ON DELETE CASCADE; -ALTER TABLE ONLY "public"."ReviewFeedbackComment" - ADD CONSTRAINT "ReviewFeedbackComment_userId_fkey" FOREIGN KEY ("userId") REFERENCES "public"."User"("id") ON UPDATE CASCADE ON DELETE CASCADE; +ALTER TABLE ONLY "public"."review_feedback_comment" + ADD CONSTRAINT "review_feedback_comment_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON UPDATE CASCADE ON DELETE CASCADE; -ALTER TABLE ONLY "public"."ReviewFeedback" - ADD CONSTRAINT "ReviewFeedback_overallReviewId_fkey" FOREIGN KEY ("overallReviewId") REFERENCES "public"."OverallReview"("id") ON UPDATE CASCADE ON DELETE RESTRICT; +ALTER TABLE ONLY "public"."review_feedback" + ADD CONSTRAINT "review_feedback_overall_review_id_fkey" FOREIGN KEY ("overall_review_id") REFERENCES "public"."overall_review"("id") ON UPDATE CASCADE ON DELETE RESTRICT; -ALTER TABLE ONLY "public"."ReviewSuggestionSnippet" - ADD CONSTRAINT "ReviewSuggestionSnippet_reviewFeedbackId_fkey" FOREIGN KEY ("reviewFeedbackId") REFERENCES "public"."ReviewFeedback"("id") ON UPDATE CASCADE ON DELETE CASCADE; +ALTER TABLE ONLY "public"."review_suggestion_snippet" + ADD CONSTRAINT "review_suggestion_snippet_review_feedback_id_fkey" FOREIGN KEY ("review_feedback_id") REFERENCES "public"."review_feedback"("id") ON UPDATE CASCADE ON DELETE CASCADE; -ALTER TABLE "public"."Project" ENABLE ROW LEVEL SECURITY; +ALTER TABLE "public"."project" ENABLE ROW LEVEL SECURITY; -CREATE POLICY "authenticated_users_can_delete_org_projects" ON "public"."Project" FOR DELETE TO "authenticated" USING (("organizationId" IN ( SELECT "OrganizationMember"."organizationId" - FROM "public"."OrganizationMember" - WHERE ("OrganizationMember"."userId" = "auth"."uid"())))); +CREATE POLICY "authenticated_users_can_delete_org_projects" ON "public"."project" FOR DELETE TO "authenticated" USING (("organization_id" IN ( SELECT "organization_member"."organization_id" + FROM "public"."organization_member" + WHERE ("organization_member"."user_id" = "auth"."uid"())))); -COMMENT ON POLICY "authenticated_users_can_delete_org_projects" ON "public"."Project" IS 'Authenticated users can only delete projects in organizations they are members of'; +COMMENT ON POLICY "authenticated_users_can_delete_org_projects" ON "public"."project" IS 'Authenticated users can only delete projects in organizations they are members of'; -CREATE POLICY "authenticated_users_can_insert_projects" ON "public"."Project" FOR INSERT TO "authenticated" WITH CHECK (("organizationId" IN ( SELECT "OrganizationMember"."organizationId" - FROM "public"."OrganizationMember" - WHERE ("OrganizationMember"."userId" = "auth"."uid"())))); +CREATE POLICY "authenticated_users_can_insert_projects" ON "public"."project" FOR INSERT TO "authenticated" WITH CHECK (("organization_id" IN ( SELECT "organization_member"."organization_id" + FROM "public"."organization_member" + WHERE ("organization_member"."user_id" = "auth"."uid"())))); -COMMENT ON POLICY "authenticated_users_can_insert_projects" ON "public"."Project" IS 'Authenticated users can create any project'; +COMMENT ON POLICY "authenticated_users_can_insert_projects" ON "public"."project" IS 'Authenticated users can create any project'; -CREATE POLICY "authenticated_users_can_select_org_projects" ON "public"."Project" FOR SELECT TO "authenticated" USING (("organizationId" IN ( SELECT "OrganizationMember"."organizationId" - FROM "public"."OrganizationMember" - WHERE ("OrganizationMember"."userId" = "auth"."uid"())))); +CREATE POLICY "authenticated_users_can_select_org_projects" ON "public"."project" FOR SELECT TO "authenticated" USING (("organization_id" IN ( SELECT "organization_member"."organization_id" + FROM "public"."organization_member" + WHERE ("organization_member"."user_id" = "auth"."uid"())))); -COMMENT ON POLICY "authenticated_users_can_select_org_projects" ON "public"."Project" IS 'Authenticated users can only view projects belonging to organizations they are members of'; +COMMENT ON POLICY "authenticated_users_can_select_org_projects" ON "public"."project" IS 'Authenticated users can only view projects belonging to organizations they are members of'; -CREATE POLICY "authenticated_users_can_update_org_projects" ON "public"."Project" FOR UPDATE TO "authenticated" USING (("organizationId" IN ( SELECT "OrganizationMember"."organizationId" - FROM "public"."OrganizationMember" - WHERE ("OrganizationMember"."userId" = "auth"."uid"())))) WITH CHECK (("organizationId" IN ( SELECT "OrganizationMember"."organizationId" - FROM "public"."OrganizationMember" - WHERE ("OrganizationMember"."userId" = "auth"."uid"())))); +CREATE POLICY "authenticated_users_can_update_org_projects" ON "public"."project" FOR UPDATE TO "authenticated" USING (("organization_id" IN ( SELECT "organization_member"."organization_id" + FROM "public"."organization_member" + WHERE ("organization_member"."user_id" = "auth"."uid"())))) WITH CHECK (("organization_id" IN ( SELECT "organization_member"."organization_id" + FROM "public"."organization_member" + WHERE ("organization_member"."user_id" = "auth"."uid"())))); -COMMENT ON POLICY "authenticated_users_can_update_org_projects" ON "public"."Project" IS 'Authenticated users can only update projects in organizations they are members of'; +COMMENT ON POLICY "authenticated_users_can_update_org_projects" ON "public"."project" IS 'Authenticated users can only update projects in organizations they are members of'; -CREATE POLICY "service_role_can_delete_all_projects" ON "public"."Project" FOR DELETE TO "service_role" USING (true); +CREATE POLICY "service_role_can_delete_all_projects" ON "public"."project" FOR DELETE TO "service_role" USING (true); -COMMENT ON POLICY "service_role_can_delete_all_projects" ON "public"."Project" IS 'Service role can delete any project (for jobs)'; +COMMENT ON POLICY "service_role_can_delete_all_projects" ON "public"."project" IS 'Service role can delete any project (for jobs)'; -CREATE POLICY "service_role_can_insert_all_projects" ON "public"."Project" FOR INSERT TO "service_role" WITH CHECK (true); +CREATE POLICY "service_role_can_insert_all_projects" ON "public"."project" FOR INSERT TO "service_role" WITH CHECK (true); -COMMENT ON POLICY "service_role_can_insert_all_projects" ON "public"."Project" IS 'Service role can create any project (for jobs)'; +COMMENT ON POLICY "service_role_can_insert_all_projects" ON "public"."project" IS 'Service role can create any project (for jobs)'; -CREATE POLICY "service_role_can_select_all_projects" ON "public"."Project" FOR SELECT TO "service_role" USING (true); +CREATE POLICY "service_role_can_select_all_projects" ON "public"."project" FOR SELECT TO "service_role" USING (true); -COMMENT ON POLICY "service_role_can_select_all_projects" ON "public"."Project" IS 'Service role can view all projects (for jobs)'; +COMMENT ON POLICY "service_role_can_select_all_projects" ON "public"."project" IS 'Service role can view all projects (for jobs)'; -CREATE POLICY "service_role_can_update_all_projects" ON "public"."Project" FOR UPDATE TO "service_role" USING (true) WITH CHECK (true); +CREATE POLICY "service_role_can_update_all_projects" ON "public"."project" FOR UPDATE TO "service_role" USING (true) WITH CHECK (true); -COMMENT ON POLICY "service_role_can_update_all_projects" ON "public"."Project" IS 'Service role can update any project (for jobs)'; +COMMENT ON POLICY "service_role_can_update_all_projects" ON "public"."project" IS 'Service role can update any project (for jobs)'; @@ -1075,33 +1075,33 @@ GRANT ALL ON FUNCTION "public"."sync_existing_users"() TO "service_role"; -GRANT ALL ON TABLE "public"."GitHubDocFilePath" TO "anon"; -GRANT ALL ON TABLE "public"."GitHubDocFilePath" TO "authenticated"; -GRANT ALL ON TABLE "public"."GitHubDocFilePath" TO "service_role"; +GRANT ALL ON TABLE "public"."github_doc_file_path" TO "anon"; +GRANT ALL ON TABLE "public"."github_doc_file_path" TO "authenticated"; +GRANT ALL ON TABLE "public"."github_doc_file_path" TO "service_role"; -GRANT ALL ON TABLE "public"."GitHubSchemaFilePath" TO "anon"; -GRANT ALL ON TABLE "public"."GitHubSchemaFilePath" TO "authenticated"; -GRANT ALL ON TABLE "public"."GitHubSchemaFilePath" TO "service_role"; +GRANT ALL ON TABLE "public"."github_schema_file_path" TO "anon"; +GRANT ALL ON TABLE "public"."github_schema_file_path" TO "authenticated"; +GRANT ALL ON TABLE "public"."github_schema_file_path" TO "service_role"; -GRANT ALL ON TABLE "public"."KnowledgeSuggestion" TO "anon"; -GRANT ALL ON TABLE "public"."KnowledgeSuggestion" TO "authenticated"; -GRANT ALL ON TABLE "public"."KnowledgeSuggestion" TO "service_role"; +GRANT ALL ON TABLE "public"."knowledge_suggestion" TO "anon"; +GRANT ALL ON TABLE "public"."knowledge_suggestion" TO "authenticated"; +GRANT ALL ON TABLE "public"."knowledge_suggestion" TO "service_role"; -GRANT ALL ON TABLE "public"."KnowledgeSuggestionDocMapping" TO "anon"; -GRANT ALL ON TABLE "public"."KnowledgeSuggestionDocMapping" TO "authenticated"; -GRANT ALL ON TABLE "public"."KnowledgeSuggestionDocMapping" TO "service_role"; +GRANT ALL ON TABLE "public"."knowledge_suggestion_doc_mapping" TO "anon"; +GRANT ALL ON TABLE "public"."knowledge_suggestion_doc_mapping" TO "authenticated"; +GRANT ALL ON TABLE "public"."knowledge_suggestion_doc_mapping" TO "service_role"; @@ -1111,33 +1111,33 @@ GRANT ALL ON TABLE "public"."KnowledgeSuggestionDocMapping" TO "service_role"; -GRANT ALL ON TABLE "public"."MembershipInvites" TO "anon"; -GRANT ALL ON TABLE "public"."MembershipInvites" TO "authenticated"; -GRANT ALL ON TABLE "public"."MembershipInvites" TO "service_role"; +GRANT ALL ON TABLE "public"."membership_invites" TO "anon"; +GRANT ALL ON TABLE "public"."membership_invites" TO "authenticated"; +GRANT ALL ON TABLE "public"."membership_invites" TO "service_role"; -GRANT ALL ON TABLE "public"."Migration" TO "anon"; -GRANT ALL ON TABLE "public"."Migration" TO "authenticated"; -GRANT ALL ON TABLE "public"."Migration" TO "service_role"; +GRANT ALL ON TABLE "public"."migration" TO "anon"; +GRANT ALL ON TABLE "public"."migration" TO "authenticated"; +GRANT ALL ON TABLE "public"."migration" TO "service_role"; -GRANT ALL ON TABLE "public"."Organization" TO "anon"; -GRANT ALL ON TABLE "public"."Organization" TO "authenticated"; -GRANT ALL ON TABLE "public"."Organization" TO "service_role"; +GRANT ALL ON TABLE "public"."organization" TO "anon"; +GRANT ALL ON TABLE "public"."organization" TO "authenticated"; +GRANT ALL ON TABLE "public"."organization" TO "service_role"; -GRANT ALL ON TABLE "public"."OrganizationMember" TO "anon"; -GRANT ALL ON TABLE "public"."OrganizationMember" TO "authenticated"; -GRANT ALL ON TABLE "public"."OrganizationMember" TO "service_role"; +GRANT ALL ON TABLE "public"."organization_member" TO "anon"; +GRANT ALL ON TABLE "public"."organization_member" TO "authenticated"; +GRANT ALL ON TABLE "public"."organization_member" TO "service_role"; @@ -1147,15 +1147,15 @@ GRANT ALL ON TABLE "public"."OrganizationMember" TO "service_role"; -GRANT ALL ON TABLE "public"."OverallReview" TO "anon"; -GRANT ALL ON TABLE "public"."OverallReview" TO "authenticated"; -GRANT ALL ON TABLE "public"."OverallReview" TO "service_role"; +GRANT ALL ON TABLE "public"."overall_review" TO "anon"; +GRANT ALL ON TABLE "public"."overall_review" TO "authenticated"; +GRANT ALL ON TABLE "public"."overall_review" TO "service_role"; -GRANT ALL ON TABLE "public"."OverallReviewKnowledgeSuggestionMapping" TO "anon"; -GRANT ALL ON TABLE "public"."OverallReviewKnowledgeSuggestionMapping" TO "authenticated"; -GRANT ALL ON TABLE "public"."OverallReviewKnowledgeSuggestionMapping" TO "service_role"; +GRANT ALL ON TABLE "public"."overall_review_knowledge_suggestion_mapping" TO "anon"; +GRANT ALL ON TABLE "public"."overall_review_knowledge_suggestion_mapping" TO "authenticated"; +GRANT ALL ON TABLE "public"."overall_review_knowledge_suggestion_mapping" TO "service_role"; @@ -1165,15 +1165,15 @@ GRANT ALL ON TABLE "public"."OverallReviewKnowledgeSuggestionMapping" TO "servic -GRANT ALL ON TABLE "public"."Project" TO "anon"; -GRANT ALL ON TABLE "public"."Project" TO "authenticated"; -GRANT ALL ON TABLE "public"."Project" TO "service_role"; +GRANT ALL ON TABLE "public"."project" TO "anon"; +GRANT ALL ON TABLE "public"."project" TO "authenticated"; +GRANT ALL ON TABLE "public"."project" TO "service_role"; -GRANT ALL ON TABLE "public"."ProjectRepositoryMapping" TO "anon"; -GRANT ALL ON TABLE "public"."ProjectRepositoryMapping" TO "authenticated"; -GRANT ALL ON TABLE "public"."ProjectRepositoryMapping" TO "service_role"; +GRANT ALL ON TABLE "public"."project_repository_mapping" TO "anon"; +GRANT ALL ON TABLE "public"."project_repository_mapping" TO "authenticated"; +GRANT ALL ON TABLE "public"."project_repository_mapping" TO "service_role"; @@ -1183,36 +1183,36 @@ GRANT ALL ON TABLE "public"."ProjectRepositoryMapping" TO "service_role"; -GRANT ALL ON TABLE "public"."PullRequest" TO "anon"; -GRANT ALL ON TABLE "public"."PullRequest" TO "authenticated"; -GRANT ALL ON TABLE "public"."PullRequest" TO "service_role"; +GRANT ALL ON TABLE "public"."pull_request" TO "anon"; +GRANT ALL ON TABLE "public"."pull_request" TO "authenticated"; +GRANT ALL ON TABLE "public"."pull_request" TO "service_role"; -GRANT ALL ON TABLE "public"."Repository" TO "anon"; -GRANT ALL ON TABLE "public"."Repository" TO "authenticated"; -GRANT ALL ON TABLE "public"."Repository" TO "service_role"; +GRANT ALL ON TABLE "public"."repository" TO "anon"; +GRANT ALL ON TABLE "public"."repository" TO "authenticated"; +GRANT ALL ON TABLE "public"."repository" TO "service_role"; -GRANT ALL ON TABLE "public"."ReviewFeedback" TO "anon"; -GRANT ALL ON TABLE "public"."ReviewFeedback" TO "authenticated"; -GRANT ALL ON TABLE "public"."ReviewFeedback" TO "service_role"; +GRANT ALL ON TABLE "public"."review_feedback" TO "anon"; +GRANT ALL ON TABLE "public"."review_feedback" TO "authenticated"; +GRANT ALL ON TABLE "public"."review_feedback" TO "service_role"; -GRANT ALL ON TABLE "public"."ReviewFeedbackComment" TO "anon"; -GRANT ALL ON TABLE "public"."ReviewFeedbackComment" TO "authenticated"; -GRANT ALL ON TABLE "public"."ReviewFeedbackComment" TO "service_role"; +GRANT ALL ON TABLE "public"."review_feedback_comment" TO "anon"; +GRANT ALL ON TABLE "public"."review_feedback_comment" TO "authenticated"; +GRANT ALL ON TABLE "public"."review_feedback_comment" TO "service_role"; @@ -1222,15 +1222,15 @@ GRANT ALL ON TABLE "public"."ReviewFeedbackComment" TO "service_role"; -GRANT ALL ON TABLE "public"."ReviewSuggestionSnippet" TO "anon"; -GRANT ALL ON TABLE "public"."ReviewSuggestionSnippet" TO "authenticated"; -GRANT ALL ON TABLE "public"."ReviewSuggestionSnippet" TO "service_role"; +GRANT ALL ON TABLE "public"."review_suggestion_snippet" TO "anon"; +GRANT ALL ON TABLE "public"."review_suggestion_snippet" TO "authenticated"; +GRANT ALL ON TABLE "public"."review_suggestion_snippet" TO "service_role"; -GRANT ALL ON TABLE "public"."User" TO "anon"; -GRANT ALL ON TABLE "public"."User" TO "authenticated"; -GRANT ALL ON TABLE "public"."User" TO "service_role"; +GRANT ALL ON TABLE "public"."user" TO "anon"; +GRANT ALL ON TABLE "public"."user" TO "authenticated"; +GRANT ALL ON TABLE "public"."user" TO "service_role"; From 3678992e4d0475ad867b011f80fd1dc890e4db2b Mon Sep 17 00:00:00 2001 From: hoshinotsuyoshi Date: Thu, 17 Apr 2025 14:03:10 +0900 Subject: [PATCH 2/9] Rename tables to use pluralized names --- frontend/packages/db/schema/schema.sql | 450 +++++++++--------- .../packages/db/supabase/database.types.ts | 346 +++++++------- .../20250416105745_initial_squash.sql | 417 ++++++++-------- 3 files changed, 587 insertions(+), 626 deletions(-) diff --git a/frontend/packages/db/schema/schema.sql b/frontend/packages/db/schema/schema.sql index ac270e5ec8..9031d54662 100644 --- a/frontend/packages/db/schema/schema.sql +++ b/frontend/packages/db/schema/schema.sql @@ -113,7 +113,7 @@ CREATE OR REPLACE FUNCTION "public"."handle_new_user"() RETURNS "trigger" SET "search_path" TO '' AS $$ BEGIN - INSERT INTO public."user" (id, name, email) + INSERT INTO public."users" (id, name, email) VALUES ( NEW.id, COALESCE(NEW.raw_user_meta_data->>'name', NEW.email), @@ -131,13 +131,13 @@ CREATE OR REPLACE FUNCTION "public"."sync_existing_users"() RETURNS "void" LANGUAGE "plpgsql" SECURITY DEFINER AS $$ BEGIN - INSERT INTO public."user" (id, name, email) + INSERT INTO public."users" (id, name, email) SELECT au.id, COALESCE(au.raw_user_meta_data->>'name', au.email), au.email FROM auth.users au - LEFT JOIN public."user" pu ON au.id = pu.id + LEFT JOIN public."users" pu ON au.id = pu.id WHERE pu.id IS NULL; END; $$; @@ -150,7 +150,7 @@ SET default_tablespace = ''; SET default_table_access_method = "heap"; -CREATE TABLE IF NOT EXISTS "public"."github_doc_file_path" ( +CREATE TABLE IF NOT EXISTS "public"."github_doc_file_paths" ( "id" "uuid" DEFAULT "gen_random_uuid"() NOT NULL, "path" "text" NOT NULL, "is_review_enabled" boolean DEFAULT true NOT NULL, @@ -160,10 +160,10 @@ CREATE TABLE IF NOT EXISTS "public"."github_doc_file_path" ( ); -ALTER TABLE "public"."github_doc_file_path" OWNER TO "postgres"; +ALTER TABLE "public"."github_doc_file_paths" OWNER TO "postgres"; -CREATE TABLE IF NOT EXISTS "public"."github_schema_file_path" ( +CREATE TABLE IF NOT EXISTS "public"."github_schema_file_paths" ( "id" "uuid" DEFAULT "gen_random_uuid"() NOT NULL, "path" "text" NOT NULL, "project_id" "uuid" NOT NULL, @@ -173,10 +173,22 @@ CREATE TABLE IF NOT EXISTS "public"."github_schema_file_path" ( ); -ALTER TABLE "public"."github_schema_file_path" OWNER TO "postgres"; +ALTER TABLE "public"."github_schema_file_paths" OWNER TO "postgres"; -CREATE TABLE IF NOT EXISTS "public"."knowledge_suggestion" ( +CREATE TABLE IF NOT EXISTS "public"."knowledge_suggestion_doc_mappings" ( + "id" "uuid" DEFAULT "gen_random_uuid"() NOT NULL, + "knowledge_suggestion_id" "uuid" NOT NULL, + "github_doc_file_path_id" "uuid" NOT NULL, + "created_at" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "updated_at" timestamp(3) without time zone NOT NULL +); + + +ALTER TABLE "public"."knowledge_suggestion_doc_mappings" OWNER TO "postgres"; + + +CREATE TABLE IF NOT EXISTS "public"."knowledge_suggestions" ( "id" "uuid" DEFAULT "gen_random_uuid"() NOT NULL, "type" "public"."knowledge_type" NOT NULL, "title" "text" NOT NULL, @@ -193,19 +205,7 @@ CREATE TABLE IF NOT EXISTS "public"."knowledge_suggestion" ( ); -ALTER TABLE "public"."knowledge_suggestion" OWNER TO "postgres"; - - -CREATE TABLE IF NOT EXISTS "public"."knowledge_suggestion_doc_mapping" ( - "id" "uuid" DEFAULT "gen_random_uuid"() NOT NULL, - "knowledge_suggestion_id" "uuid" NOT NULL, - "github_doc_file_path_id" "uuid" NOT NULL, - "created_at" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "updated_at" timestamp(3) without time zone NOT NULL -); - - -ALTER TABLE "public"."knowledge_suggestion_doc_mapping" OWNER TO "postgres"; +ALTER TABLE "public"."knowledge_suggestions" OWNER TO "postgres"; CREATE TABLE IF NOT EXISTS "public"."membership_invites" ( @@ -220,7 +220,7 @@ CREATE TABLE IF NOT EXISTS "public"."membership_invites" ( ALTER TABLE "public"."membership_invites" OWNER TO "postgres"; -CREATE TABLE IF NOT EXISTS "public"."migration" ( +CREATE TABLE IF NOT EXISTS "public"."migrations" ( "id" "uuid" DEFAULT "gen_random_uuid"() NOT NULL, "title" "text" NOT NULL, "pull_request_id" "uuid" NOT NULL, @@ -229,30 +229,42 @@ CREATE TABLE IF NOT EXISTS "public"."migration" ( ); -ALTER TABLE "public"."migration" OWNER TO "postgres"; +ALTER TABLE "public"."migrations" OWNER TO "postgres"; + + +CREATE TABLE IF NOT EXISTS "public"."organization_members" ( + "id" "uuid" DEFAULT "gen_random_uuid"() NOT NULL, + "user_id" "uuid" NOT NULL, + "organization_id" "uuid" NOT NULL, + "joined_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP +); + + +ALTER TABLE "public"."organization_members" OWNER TO "postgres"; -CREATE TABLE IF NOT EXISTS "public"."organization" ( +CREATE TABLE IF NOT EXISTS "public"."organizations" ( "id" "uuid" DEFAULT "gen_random_uuid"() NOT NULL, "name" "text" NOT NULL ); -ALTER TABLE "public"."organization" OWNER TO "postgres"; +ALTER TABLE "public"."organizations" OWNER TO "postgres"; -CREATE TABLE IF NOT EXISTS "public"."organization_member" ( +CREATE TABLE IF NOT EXISTS "public"."overall_review_knowledge_suggestion_mappings" ( "id" "uuid" DEFAULT "gen_random_uuid"() NOT NULL, - "user_id" "uuid" NOT NULL, - "organization_id" "uuid" NOT NULL, - "joined_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP + "overall_review_id" "uuid" NOT NULL, + "knowledge_suggestion_id" "uuid" NOT NULL, + "created_at" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "updated_at" timestamp(3) without time zone NOT NULL ); -ALTER TABLE "public"."organization_member" OWNER TO "postgres"; +ALTER TABLE "public"."overall_review_knowledge_suggestion_mappings" OWNER TO "postgres"; -CREATE TABLE IF NOT EXISTS "public"."overall_review" ( +CREATE TABLE IF NOT EXISTS "public"."overall_reviews" ( "id" "uuid" DEFAULT "gen_random_uuid"() NOT NULL, "project_id" "uuid", "pull_request_id" "uuid" NOT NULL, @@ -265,22 +277,22 @@ CREATE TABLE IF NOT EXISTS "public"."overall_review" ( ); -ALTER TABLE "public"."overall_review" OWNER TO "postgres"; +ALTER TABLE "public"."overall_reviews" OWNER TO "postgres"; -CREATE TABLE IF NOT EXISTS "public"."overall_review_knowledge_suggestion_mapping" ( +CREATE TABLE IF NOT EXISTS "public"."project_repository_mappings" ( "id" "uuid" DEFAULT "gen_random_uuid"() NOT NULL, - "overall_review_id" "uuid" NOT NULL, - "knowledge_suggestion_id" "uuid" NOT NULL, + "project_id" "uuid" NOT NULL, + "repository_id" "uuid" NOT NULL, "created_at" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, "updated_at" timestamp(3) without time zone NOT NULL ); -ALTER TABLE "public"."overall_review_knowledge_suggestion_mapping" OWNER TO "postgres"; +ALTER TABLE "public"."project_repository_mappings" OWNER TO "postgres"; -CREATE TABLE IF NOT EXISTS "public"."project" ( +CREATE TABLE IF NOT EXISTS "public"."projects" ( "id" "uuid" DEFAULT "gen_random_uuid"() NOT NULL, "name" "text" NOT NULL, "created_at" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, @@ -289,22 +301,10 @@ CREATE TABLE IF NOT EXISTS "public"."project" ( ); -ALTER TABLE "public"."project" OWNER TO "postgres"; - - -CREATE TABLE IF NOT EXISTS "public"."project_repository_mapping" ( - "id" "uuid" DEFAULT "gen_random_uuid"() NOT NULL, - "project_id" "uuid" NOT NULL, - "repository_id" "uuid" NOT NULL, - "created_at" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "updated_at" timestamp(3) without time zone NOT NULL -); - - -ALTER TABLE "public"."project_repository_mapping" OWNER TO "postgres"; +ALTER TABLE "public"."projects" OWNER TO "postgres"; -CREATE TABLE IF NOT EXISTS "public"."pull_request" ( +CREATE TABLE IF NOT EXISTS "public"."pull_requests" ( "id" "uuid" DEFAULT "gen_random_uuid"() NOT NULL, "pull_number" bigint NOT NULL, "comment_id" bigint, @@ -314,10 +314,10 @@ CREATE TABLE IF NOT EXISTS "public"."pull_request" ( ); -ALTER TABLE "public"."pull_request" OWNER TO "postgres"; +ALTER TABLE "public"."pull_requests" OWNER TO "postgres"; -CREATE TABLE IF NOT EXISTS "public"."repository" ( +CREATE TABLE IF NOT EXISTS "public"."repositories" ( "id" "uuid" DEFAULT "gen_random_uuid"() NOT NULL, "name" "text" NOT NULL, "owner" "text" NOT NULL, @@ -328,10 +328,23 @@ CREATE TABLE IF NOT EXISTS "public"."repository" ( ); -ALTER TABLE "public"."repository" OWNER TO "postgres"; +ALTER TABLE "public"."repositories" OWNER TO "postgres"; + + +CREATE TABLE IF NOT EXISTS "public"."review_feedback_comments" ( + "id" "uuid" DEFAULT "gen_random_uuid"() NOT NULL, + "review_feedback_id" "uuid" NOT NULL, + "user_id" "uuid" NOT NULL, + "content" "text" NOT NULL, + "created_at" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "updated_at" timestamp(3) without time zone NOT NULL +); + + +ALTER TABLE "public"."review_feedback_comments" OWNER TO "postgres"; -CREATE TABLE IF NOT EXISTS "public"."review_feedback" ( +CREATE TABLE IF NOT EXISTS "public"."review_feedbacks" ( "id" "uuid" DEFAULT "gen_random_uuid"() NOT NULL, "overall_review_id" "uuid" NOT NULL, "category" "public"."category_enum" NOT NULL, @@ -345,23 +358,10 @@ CREATE TABLE IF NOT EXISTS "public"."review_feedback" ( ); -ALTER TABLE "public"."review_feedback" OWNER TO "postgres"; - - -CREATE TABLE IF NOT EXISTS "public"."review_feedback_comment" ( - "id" "uuid" DEFAULT "gen_random_uuid"() NOT NULL, - "review_feedback_id" "uuid" NOT NULL, - "user_id" "uuid" NOT NULL, - "content" "text" NOT NULL, - "created_at" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "updated_at" timestamp(3) without time zone NOT NULL -); - - -ALTER TABLE "public"."review_feedback_comment" OWNER TO "postgres"; +ALTER TABLE "public"."review_feedbacks" OWNER TO "postgres"; -CREATE TABLE IF NOT EXISTS "public"."review_suggestion_snippet" ( +CREATE TABLE IF NOT EXISTS "public"."review_suggestion_snippets" ( "id" "uuid" DEFAULT "gen_random_uuid"() NOT NULL, "review_feedback_id" "uuid" NOT NULL, "filename" "text" NOT NULL, @@ -371,40 +371,40 @@ CREATE TABLE IF NOT EXISTS "public"."review_suggestion_snippet" ( ); -ALTER TABLE "public"."review_suggestion_snippet" OWNER TO "postgres"; +ALTER TABLE "public"."review_suggestion_snippets" OWNER TO "postgres"; -CREATE TABLE IF NOT EXISTS "public"."user" ( +CREATE TABLE IF NOT EXISTS "public"."users" ( "id" "uuid" NOT NULL, "name" "text" NOT NULL, "email" "text" NOT NULL ); -ALTER TABLE "public"."user" OWNER TO "postgres"; +ALTER TABLE "public"."users" OWNER TO "postgres"; -ALTER TABLE ONLY "public"."github_doc_file_path" +ALTER TABLE ONLY "public"."github_doc_file_paths" ADD CONSTRAINT "github_doc_file_path_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."github_schema_file_path" +ALTER TABLE ONLY "public"."github_schema_file_paths" ADD CONSTRAINT "github_schema_file_path_path_project_id_key" UNIQUE ("path", "project_id"); -ALTER TABLE ONLY "public"."github_schema_file_path" +ALTER TABLE ONLY "public"."github_schema_file_paths" ADD CONSTRAINT "github_schema_file_path_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."knowledge_suggestion_doc_mapping" +ALTER TABLE ONLY "public"."knowledge_suggestion_doc_mappings" ADD CONSTRAINT "knowledge_suggestion_doc_mapping_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."knowledge_suggestion" +ALTER TABLE ONLY "public"."knowledge_suggestions" ADD CONSTRAINT "knowledge_suggestion_pkey" PRIMARY KEY ("id"); @@ -414,98 +414,98 @@ ALTER TABLE ONLY "public"."membership_invites" -ALTER TABLE ONLY "public"."migration" +ALTER TABLE ONLY "public"."migrations" ADD CONSTRAINT "migration_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."organization_member" +ALTER TABLE ONLY "public"."organization_members" ADD CONSTRAINT "organization_member_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."organization_member" +ALTER TABLE ONLY "public"."organization_members" ADD CONSTRAINT "organization_member_user_id_organization_id_key" UNIQUE ("user_id", "organization_id"); -ALTER TABLE ONLY "public"."organization" +ALTER TABLE ONLY "public"."organizations" ADD CONSTRAINT "organization_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."overall_review_knowledge_suggestion_mapping" +ALTER TABLE ONLY "public"."overall_review_knowledge_suggestion_mappings" ADD CONSTRAINT "overall_review_knowledge_suggestion_mapping_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."overall_review" +ALTER TABLE ONLY "public"."overall_reviews" ADD CONSTRAINT "overall_review_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."project" +ALTER TABLE ONLY "public"."projects" ADD CONSTRAINT "project_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."project_repository_mapping" +ALTER TABLE ONLY "public"."project_repository_mappings" ADD CONSTRAINT "project_repository_mapping_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."pull_request" +ALTER TABLE ONLY "public"."pull_requests" ADD CONSTRAINT "pull_request_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."repository" +ALTER TABLE ONLY "public"."repositories" ADD CONSTRAINT "repository_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."review_feedback_comment" +ALTER TABLE ONLY "public"."review_feedback_comments" ADD CONSTRAINT "review_feedback_comment_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."review_feedback" +ALTER TABLE ONLY "public"."review_feedbacks" ADD CONSTRAINT "review_feedback_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."review_suggestion_snippet" +ALTER TABLE ONLY "public"."review_suggestion_snippets" ADD CONSTRAINT "review_suggestion_snippet_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."user" +ALTER TABLE ONLY "public"."users" ADD CONSTRAINT "user_email_key" UNIQUE ("email"); -ALTER TABLE ONLY "public"."user" +ALTER TABLE ONLY "public"."users" ADD CONSTRAINT "user_pkey" PRIMARY KEY ("id"); -CREATE UNIQUE INDEX "github_doc_file_path_path_project_id_key" ON "public"."github_doc_file_path" USING "btree" ("path", "project_id"); +CREATE UNIQUE INDEX "github_doc_file_path_path_project_id_key" ON "public"."github_doc_file_paths" USING "btree" ("path", "project_id"); -CREATE UNIQUE INDEX "github_schema_file_path_project_id_key" ON "public"."github_schema_file_path" USING "btree" ("project_id"); +CREATE UNIQUE INDEX "github_schema_file_path_project_id_key" ON "public"."github_schema_file_paths" USING "btree" ("project_id"); -CREATE INDEX "idx_project_organization_id" ON "public"."project" USING "btree" ("organization_id"); +CREATE INDEX "idx_project_organization_id" ON "public"."projects" USING "btree" ("organization_id"); -CREATE INDEX "idx_review_feedback_comment_review_feedback_id" ON "public"."review_feedback_comment" USING "btree" ("review_feedback_id"); +CREATE INDEX "idx_review_feedback_comment_review_feedback_id" ON "public"."review_feedback_comments" USING "btree" ("review_feedback_id"); -CREATE UNIQUE INDEX "knowledge_suggestion_doc_mapping_unique_mapping" ON "public"."knowledge_suggestion_doc_mapping" USING "btree" ("knowledge_suggestion_id", "github_doc_file_path_id"); +CREATE UNIQUE INDEX "knowledge_suggestion_doc_mapping_unique_mapping" ON "public"."knowledge_suggestion_doc_mappings" USING "btree" ("knowledge_suggestion_id", "github_doc_file_path_id"); @@ -517,218 +517,218 @@ CREATE INDEX "membership_invites_org_id_idx" ON "public"."membership_invites" US -CREATE UNIQUE INDEX "migration_pull_request_id_key" ON "public"."migration" USING "btree" ("pull_request_id"); +CREATE UNIQUE INDEX "migration_pull_request_id_key" ON "public"."migrations" USING "btree" ("pull_request_id"); -CREATE INDEX "organization_member_organization_id_idx" ON "public"."organization_member" USING "btree" ("organization_id"); +CREATE INDEX "organization_member_organization_id_idx" ON "public"."organization_members" USING "btree" ("organization_id"); -CREATE INDEX "organization_member_user_id_idx" ON "public"."organization_member" USING "btree" ("user_id"); +CREATE INDEX "organization_member_user_id_idx" ON "public"."organization_members" USING "btree" ("user_id"); -CREATE UNIQUE INDEX "overall_review_knowledge_suggestion_mapping_unique_mapping" ON "public"."overall_review_knowledge_suggestion_mapping" USING "btree" ("overall_review_id", "knowledge_suggestion_id"); +CREATE UNIQUE INDEX "overall_review_knowledge_suggestion_mapping_unique_mapping" ON "public"."overall_review_knowledge_suggestion_mappings" USING "btree" ("overall_review_id", "knowledge_suggestion_id"); -CREATE UNIQUE INDEX "project_repository_mapping_project_id_repository_id_key" ON "public"."project_repository_mapping" USING "btree" ("project_id", "repository_id"); +CREATE UNIQUE INDEX "project_repository_mapping_project_id_repository_id_key" ON "public"."project_repository_mappings" USING "btree" ("project_id", "repository_id"); -CREATE UNIQUE INDEX "pull_request_repository_id_pull_number_key" ON "public"."pull_request" USING "btree" ("repository_id", "pull_number"); +CREATE UNIQUE INDEX "pull_request_repository_id_pull_number_key" ON "public"."pull_requests" USING "btree" ("repository_id", "pull_number"); -CREATE UNIQUE INDEX "repository_owner_name_key" ON "public"."repository" USING "btree" ("owner", "name"); +CREATE UNIQUE INDEX "repository_owner_name_key" ON "public"."repositories" USING "btree" ("owner", "name"); -ALTER TABLE ONLY "public"."github_doc_file_path" - ADD CONSTRAINT "github_doc_file_path_project_id_fkey" FOREIGN KEY ("project_id") REFERENCES "public"."project"("id") ON UPDATE CASCADE ON DELETE RESTRICT; +ALTER TABLE ONLY "public"."github_doc_file_paths" + ADD CONSTRAINT "github_doc_file_path_project_id_fkey" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON UPDATE CASCADE ON DELETE RESTRICT; -ALTER TABLE ONLY "public"."github_schema_file_path" - ADD CONSTRAINT "github_schema_file_path_project_id_fkey" FOREIGN KEY ("project_id") REFERENCES "public"."project"("id") ON UPDATE CASCADE ON DELETE RESTRICT; +ALTER TABLE ONLY "public"."github_schema_file_paths" + ADD CONSTRAINT "github_schema_file_path_project_id_fkey" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON UPDATE CASCADE ON DELETE RESTRICT; -ALTER TABLE ONLY "public"."knowledge_suggestion_doc_mapping" - ADD CONSTRAINT "knowledge_suggestion_doc_mapping_github_doc_file_path_id_fkey" FOREIGN KEY ("github_doc_file_path_id") REFERENCES "public"."github_doc_file_path"("id") ON UPDATE CASCADE ON DELETE CASCADE; +ALTER TABLE ONLY "public"."knowledge_suggestion_doc_mappings" + ADD CONSTRAINT "knowledge_suggestion_doc_mapping_github_doc_file_path_id_fkey" FOREIGN KEY ("github_doc_file_path_id") REFERENCES "public"."github_doc_file_paths"("id") ON UPDATE CASCADE ON DELETE CASCADE; -ALTER TABLE ONLY "public"."knowledge_suggestion_doc_mapping" - ADD CONSTRAINT "knowledge_suggestion_doc_mapping_knowledge_suggestion_id_fkey" FOREIGN KEY ("knowledge_suggestion_id") REFERENCES "public"."knowledge_suggestion"("id") ON UPDATE CASCADE ON DELETE CASCADE; +ALTER TABLE ONLY "public"."knowledge_suggestion_doc_mappings" + ADD CONSTRAINT "knowledge_suggestion_doc_mapping_knowledge_suggestion_id_fkey" FOREIGN KEY ("knowledge_suggestion_id") REFERENCES "public"."knowledge_suggestions"("id") ON UPDATE CASCADE ON DELETE CASCADE; -ALTER TABLE ONLY "public"."knowledge_suggestion" - ADD CONSTRAINT "knowledge_suggestion_project_id_fkey" FOREIGN KEY ("project_id") REFERENCES "public"."project"("id") ON UPDATE CASCADE ON DELETE RESTRICT; +ALTER TABLE ONLY "public"."knowledge_suggestions" + ADD CONSTRAINT "knowledge_suggestion_project_id_fkey" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON UPDATE CASCADE ON DELETE RESTRICT; ALTER TABLE ONLY "public"."membership_invites" - ADD CONSTRAINT "membership_invites_invite_by_user_id_fkey" FOREIGN KEY ("invite_by_user_id") REFERENCES "public"."user"("id") ON DELETE CASCADE; + ADD CONSTRAINT "membership_invites_invite_by_user_id_fkey" FOREIGN KEY ("invite_by_user_id") REFERENCES "public"."users"("id") ON DELETE CASCADE; ALTER TABLE ONLY "public"."membership_invites" - ADD CONSTRAINT "membership_invites_organization_id_fkey" FOREIGN KEY ("organization_id") REFERENCES "public"."organization"("id") ON DELETE CASCADE; + ADD CONSTRAINT "membership_invites_organization_id_fkey" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE CASCADE; -ALTER TABLE ONLY "public"."migration" - ADD CONSTRAINT "migration_pull_request_id_fkey" FOREIGN KEY ("pull_request_id") REFERENCES "public"."pull_request"("id") ON UPDATE CASCADE ON DELETE RESTRICT; +ALTER TABLE ONLY "public"."migrations" + ADD CONSTRAINT "migration_pull_request_id_fkey" FOREIGN KEY ("pull_request_id") REFERENCES "public"."pull_requests"("id") ON UPDATE CASCADE ON DELETE RESTRICT; -ALTER TABLE ONLY "public"."organization_member" - ADD CONSTRAINT "organization_member_organization_id_fkey" FOREIGN KEY ("organization_id") REFERENCES "public"."organization"("id") ON DELETE CASCADE; +ALTER TABLE ONLY "public"."organization_members" + ADD CONSTRAINT "organization_member_organization_id_fkey" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE CASCADE; -ALTER TABLE ONLY "public"."organization_member" - ADD CONSTRAINT "organization_member_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE CASCADE; +ALTER TABLE ONLY "public"."organization_members" + ADD CONSTRAINT "organization_member_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE CASCADE; -ALTER TABLE ONLY "public"."overall_review_knowledge_suggestion_mapping" - ADD CONSTRAINT "overall_review_knowledge_suggestion_mapping_knowledge_suggestio" FOREIGN KEY ("knowledge_suggestion_id") REFERENCES "public"."knowledge_suggestion"("id") ON UPDATE CASCADE ON DELETE CASCADE; +ALTER TABLE ONLY "public"."overall_review_knowledge_suggestion_mappings" + ADD CONSTRAINT "overall_review_knowledge_suggestion_mapping_knowledge_suggestio" FOREIGN KEY ("knowledge_suggestion_id") REFERENCES "public"."knowledge_suggestions"("id") ON UPDATE CASCADE ON DELETE CASCADE; -ALTER TABLE ONLY "public"."overall_review_knowledge_suggestion_mapping" - ADD CONSTRAINT "overall_review_knowledge_suggestion_mapping_overall_review_id_f" FOREIGN KEY ("overall_review_id") REFERENCES "public"."overall_review"("id") ON UPDATE CASCADE ON DELETE CASCADE; +ALTER TABLE ONLY "public"."overall_review_knowledge_suggestion_mappings" + ADD CONSTRAINT "overall_review_knowledge_suggestion_mapping_overall_review_id_f" FOREIGN KEY ("overall_review_id") REFERENCES "public"."overall_reviews"("id") ON UPDATE CASCADE ON DELETE CASCADE; -ALTER TABLE ONLY "public"."overall_review" - ADD CONSTRAINT "overall_review_project_id_fkey" FOREIGN KEY ("project_id") REFERENCES "public"."project"("id") ON UPDATE CASCADE ON DELETE SET NULL; +ALTER TABLE ONLY "public"."overall_reviews" + ADD CONSTRAINT "overall_review_project_id_fkey" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON UPDATE CASCADE ON DELETE SET NULL; -ALTER TABLE ONLY "public"."overall_review" - ADD CONSTRAINT "overall_review_pull_request_id_fkey" FOREIGN KEY ("pull_request_id") REFERENCES "public"."pull_request"("id") ON UPDATE CASCADE ON DELETE RESTRICT; +ALTER TABLE ONLY "public"."overall_reviews" + ADD CONSTRAINT "overall_review_pull_request_id_fkey" FOREIGN KEY ("pull_request_id") REFERENCES "public"."pull_requests"("id") ON UPDATE CASCADE ON DELETE RESTRICT; -ALTER TABLE ONLY "public"."project" - ADD CONSTRAINT "project_organization_id_fkey" FOREIGN KEY ("organization_id") REFERENCES "public"."organization"("id") ON UPDATE CASCADE ON DELETE CASCADE; +ALTER TABLE ONLY "public"."projects" + ADD CONSTRAINT "project_organization_id_fkey" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON UPDATE CASCADE ON DELETE CASCADE; -ALTER TABLE ONLY "public"."project_repository_mapping" - ADD CONSTRAINT "project_repository_mapping_project_id_fkey" FOREIGN KEY ("project_id") REFERENCES "public"."project"("id") ON UPDATE CASCADE ON DELETE RESTRICT; +ALTER TABLE ONLY "public"."project_repository_mappings" + ADD CONSTRAINT "project_repository_mapping_project_id_fkey" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON UPDATE CASCADE ON DELETE RESTRICT; -ALTER TABLE ONLY "public"."project_repository_mapping" - ADD CONSTRAINT "project_repository_mapping_repository_id_fkey" FOREIGN KEY ("repository_id") REFERENCES "public"."repository"("id") ON UPDATE CASCADE ON DELETE RESTRICT; +ALTER TABLE ONLY "public"."project_repository_mappings" + ADD CONSTRAINT "project_repository_mapping_repository_id_fkey" FOREIGN KEY ("repository_id") REFERENCES "public"."repositories"("id") ON UPDATE CASCADE ON DELETE RESTRICT; -ALTER TABLE ONLY "public"."pull_request" - ADD CONSTRAINT "pull_request_repository_id_fkey" FOREIGN KEY ("repository_id") REFERENCES "public"."repository"("id") ON UPDATE CASCADE ON DELETE RESTRICT; +ALTER TABLE ONLY "public"."pull_requests" + ADD CONSTRAINT "pull_request_repository_id_fkey" FOREIGN KEY ("repository_id") REFERENCES "public"."repositories"("id") ON UPDATE CASCADE ON DELETE RESTRICT; -ALTER TABLE ONLY "public"."review_feedback_comment" - ADD CONSTRAINT "review_feedback_comment_review_feedback_id_fkey" FOREIGN KEY ("review_feedback_id") REFERENCES "public"."review_feedback"("id") ON UPDATE CASCADE ON DELETE CASCADE; +ALTER TABLE ONLY "public"."review_feedback_comments" + ADD CONSTRAINT "review_feedback_comment_review_feedback_id_fkey" FOREIGN KEY ("review_feedback_id") REFERENCES "public"."review_feedbacks"("id") ON UPDATE CASCADE ON DELETE CASCADE; -ALTER TABLE ONLY "public"."review_feedback_comment" - ADD CONSTRAINT "review_feedback_comment_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON UPDATE CASCADE ON DELETE CASCADE; +ALTER TABLE ONLY "public"."review_feedback_comments" + ADD CONSTRAINT "review_feedback_comment_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON UPDATE CASCADE ON DELETE CASCADE; -ALTER TABLE ONLY "public"."review_feedback" - ADD CONSTRAINT "review_feedback_overall_review_id_fkey" FOREIGN KEY ("overall_review_id") REFERENCES "public"."overall_review"("id") ON UPDATE CASCADE ON DELETE RESTRICT; +ALTER TABLE ONLY "public"."review_feedbacks" + ADD CONSTRAINT "review_feedback_overall_review_id_fkey" FOREIGN KEY ("overall_review_id") REFERENCES "public"."overall_reviews"("id") ON UPDATE CASCADE ON DELETE RESTRICT; -ALTER TABLE ONLY "public"."review_suggestion_snippet" - ADD CONSTRAINT "review_suggestion_snippet_review_feedback_id_fkey" FOREIGN KEY ("review_feedback_id") REFERENCES "public"."review_feedback"("id") ON UPDATE CASCADE ON DELETE CASCADE; +ALTER TABLE ONLY "public"."review_suggestion_snippets" + ADD CONSTRAINT "review_suggestion_snippet_review_feedback_id_fkey" FOREIGN KEY ("review_feedback_id") REFERENCES "public"."review_feedbacks"("id") ON UPDATE CASCADE ON DELETE CASCADE; -CREATE POLICY "authenticated_users_can_delete_org_projects" ON "public"."project" FOR DELETE TO "authenticated" USING (("organization_id" IN ( SELECT "organization_member"."organization_id" - FROM "public"."organization_member" - WHERE ("organization_member"."user_id" = "auth"."uid"())))); +CREATE POLICY "authenticated_users_can_delete_org_projects" ON "public"."projects" FOR DELETE TO "authenticated" USING (("organization_id" IN ( SELECT "organization_members"."organization_id" + FROM "public"."organization_members" + WHERE ("organization_members"."user_id" = "auth"."uid"())))); -COMMENT ON POLICY "authenticated_users_can_delete_org_projects" ON "public"."project" IS 'Authenticated users can only delete projects in organizations they are members of'; +COMMENT ON POLICY "authenticated_users_can_delete_org_projects" ON "public"."projects" IS 'Authenticated users can only delete projects in organizations they are members of'; -CREATE POLICY "authenticated_users_can_insert_projects" ON "public"."project" FOR INSERT TO "authenticated" WITH CHECK (("organization_id" IN ( SELECT "organization_member"."organization_id" - FROM "public"."organization_member" - WHERE ("organization_member"."user_id" = "auth"."uid"())))); +CREATE POLICY "authenticated_users_can_insert_projects" ON "public"."projects" FOR INSERT TO "authenticated" WITH CHECK (("organization_id" IN ( SELECT "organization_members"."organization_id" + FROM "public"."organization_members" + WHERE ("organization_members"."user_id" = "auth"."uid"())))); -COMMENT ON POLICY "authenticated_users_can_insert_projects" ON "public"."project" IS 'Authenticated users can create any project'; +COMMENT ON POLICY "authenticated_users_can_insert_projects" ON "public"."projects" IS 'Authenticated users can create any project'; -CREATE POLICY "authenticated_users_can_select_org_projects" ON "public"."project" FOR SELECT TO "authenticated" USING (("organization_id" IN ( SELECT "organization_member"."organization_id" - FROM "public"."organization_member" - WHERE ("organization_member"."user_id" = "auth"."uid"())))); +CREATE POLICY "authenticated_users_can_select_org_projects" ON "public"."projects" FOR SELECT TO "authenticated" USING (("organization_id" IN ( SELECT "organization_members"."organization_id" + FROM "public"."organization_members" + WHERE ("organization_members"."user_id" = "auth"."uid"())))); -COMMENT ON POLICY "authenticated_users_can_select_org_projects" ON "public"."project" IS 'Authenticated users can only view projects belonging to organizations they are members of'; +COMMENT ON POLICY "authenticated_users_can_select_org_projects" ON "public"."projects" IS 'Authenticated users can only view projects belonging to organizations they are members of'; -CREATE POLICY "authenticated_users_can_update_org_projects" ON "public"."project" FOR UPDATE TO "authenticated" USING (("organization_id" IN ( SELECT "organization_member"."organization_id" - FROM "public"."organization_member" - WHERE ("organization_member"."user_id" = "auth"."uid"())))) WITH CHECK (("organization_id" IN ( SELECT "organization_member"."organization_id" - FROM "public"."organization_member" - WHERE ("organization_member"."user_id" = "auth"."uid"())))); +CREATE POLICY "authenticated_users_can_update_org_projects" ON "public"."projects" FOR UPDATE TO "authenticated" USING (("organization_id" IN ( SELECT "organization_members"."organization_id" + FROM "public"."organization_members" + WHERE ("organization_members"."user_id" = "auth"."uid"())))) WITH CHECK (("organization_id" IN ( SELECT "organization_members"."organization_id" + FROM "public"."organization_members" + WHERE ("organization_members"."user_id" = "auth"."uid"())))); -COMMENT ON POLICY "authenticated_users_can_update_org_projects" ON "public"."project" IS 'Authenticated users can only update projects in organizations they are members of'; +COMMENT ON POLICY "authenticated_users_can_update_org_projects" ON "public"."projects" IS 'Authenticated users can only update projects in organizations they are members of'; -ALTER TABLE "public"."project" ENABLE ROW LEVEL SECURITY; +ALTER TABLE "public"."projects" ENABLE ROW LEVEL SECURITY; -CREATE POLICY "service_role_can_delete_all_projects" ON "public"."project" FOR DELETE TO "service_role" USING (true); +CREATE POLICY "service_role_can_delete_all_projects" ON "public"."projects" FOR DELETE TO "service_role" USING (true); -COMMENT ON POLICY "service_role_can_delete_all_projects" ON "public"."project" IS 'Service role can delete any project (for jobs)'; +COMMENT ON POLICY "service_role_can_delete_all_projects" ON "public"."projects" IS 'Service role can delete any project (for jobs)'; -CREATE POLICY "service_role_can_insert_all_projects" ON "public"."project" FOR INSERT TO "service_role" WITH CHECK (true); +CREATE POLICY "service_role_can_insert_all_projects" ON "public"."projects" FOR INSERT TO "service_role" WITH CHECK (true); -COMMENT ON POLICY "service_role_can_insert_all_projects" ON "public"."project" IS 'Service role can create any project (for jobs)'; +COMMENT ON POLICY "service_role_can_insert_all_projects" ON "public"."projects" IS 'Service role can create any project (for jobs)'; -CREATE POLICY "service_role_can_select_all_projects" ON "public"."project" FOR SELECT TO "service_role" USING (true); +CREATE POLICY "service_role_can_select_all_projects" ON "public"."projects" FOR SELECT TO "service_role" USING (true); -COMMENT ON POLICY "service_role_can_select_all_projects" ON "public"."project" IS 'Service role can view all projects (for jobs)'; +COMMENT ON POLICY "service_role_can_select_all_projects" ON "public"."projects" IS 'Service role can view all projects (for jobs)'; -CREATE POLICY "service_role_can_update_all_projects" ON "public"."project" FOR UPDATE TO "service_role" USING (true) WITH CHECK (true); +CREATE POLICY "service_role_can_update_all_projects" ON "public"."projects" FOR UPDATE TO "service_role" USING (true) WITH CHECK (true); -COMMENT ON POLICY "service_role_can_update_all_projects" ON "public"."project" IS 'Service role can update any project (for jobs)'; +COMMENT ON POLICY "service_role_can_update_all_projects" ON "public"."projects" IS 'Service role can update any project (for jobs)'; @@ -948,27 +948,27 @@ GRANT ALL ON FUNCTION "public"."sync_existing_users"() TO "service_role"; -GRANT ALL ON TABLE "public"."github_doc_file_path" TO "anon"; -GRANT ALL ON TABLE "public"."github_doc_file_path" TO "authenticated"; -GRANT ALL ON TABLE "public"."github_doc_file_path" TO "service_role"; +GRANT ALL ON TABLE "public"."github_doc_file_paths" TO "anon"; +GRANT ALL ON TABLE "public"."github_doc_file_paths" TO "authenticated"; +GRANT ALL ON TABLE "public"."github_doc_file_paths" TO "service_role"; -GRANT ALL ON TABLE "public"."github_schema_file_path" TO "anon"; -GRANT ALL ON TABLE "public"."github_schema_file_path" TO "authenticated"; -GRANT ALL ON TABLE "public"."github_schema_file_path" TO "service_role"; +GRANT ALL ON TABLE "public"."github_schema_file_paths" TO "anon"; +GRANT ALL ON TABLE "public"."github_schema_file_paths" TO "authenticated"; +GRANT ALL ON TABLE "public"."github_schema_file_paths" TO "service_role"; -GRANT ALL ON TABLE "public"."knowledge_suggestion" TO "anon"; -GRANT ALL ON TABLE "public"."knowledge_suggestion" TO "authenticated"; -GRANT ALL ON TABLE "public"."knowledge_suggestion" TO "service_role"; +GRANT ALL ON TABLE "public"."knowledge_suggestion_doc_mappings" TO "anon"; +GRANT ALL ON TABLE "public"."knowledge_suggestion_doc_mappings" TO "authenticated"; +GRANT ALL ON TABLE "public"."knowledge_suggestion_doc_mappings" TO "service_role"; -GRANT ALL ON TABLE "public"."knowledge_suggestion_doc_mapping" TO "anon"; -GRANT ALL ON TABLE "public"."knowledge_suggestion_doc_mapping" TO "authenticated"; -GRANT ALL ON TABLE "public"."knowledge_suggestion_doc_mapping" TO "service_role"; +GRANT ALL ON TABLE "public"."knowledge_suggestions" TO "anon"; +GRANT ALL ON TABLE "public"."knowledge_suggestions" TO "authenticated"; +GRANT ALL ON TABLE "public"."knowledge_suggestions" TO "service_role"; @@ -978,81 +978,81 @@ GRANT ALL ON TABLE "public"."membership_invites" TO "service_role"; -GRANT ALL ON TABLE "public"."migration" TO "anon"; -GRANT ALL ON TABLE "public"."migration" TO "authenticated"; -GRANT ALL ON TABLE "public"."migration" TO "service_role"; +GRANT ALL ON TABLE "public"."migrations" TO "anon"; +GRANT ALL ON TABLE "public"."migrations" TO "authenticated"; +GRANT ALL ON TABLE "public"."migrations" TO "service_role"; -GRANT ALL ON TABLE "public"."organization" TO "anon"; -GRANT ALL ON TABLE "public"."organization" TO "authenticated"; -GRANT ALL ON TABLE "public"."organization" TO "service_role"; +GRANT ALL ON TABLE "public"."organization_members" TO "anon"; +GRANT ALL ON TABLE "public"."organization_members" TO "authenticated"; +GRANT ALL ON TABLE "public"."organization_members" TO "service_role"; -GRANT ALL ON TABLE "public"."organization_member" TO "anon"; -GRANT ALL ON TABLE "public"."organization_member" TO "authenticated"; -GRANT ALL ON TABLE "public"."organization_member" TO "service_role"; +GRANT ALL ON TABLE "public"."organizations" TO "anon"; +GRANT ALL ON TABLE "public"."organizations" TO "authenticated"; +GRANT ALL ON TABLE "public"."organizations" TO "service_role"; -GRANT ALL ON TABLE "public"."overall_review" TO "anon"; -GRANT ALL ON TABLE "public"."overall_review" TO "authenticated"; -GRANT ALL ON TABLE "public"."overall_review" TO "service_role"; +GRANT ALL ON TABLE "public"."overall_review_knowledge_suggestion_mappings" TO "anon"; +GRANT ALL ON TABLE "public"."overall_review_knowledge_suggestion_mappings" TO "authenticated"; +GRANT ALL ON TABLE "public"."overall_review_knowledge_suggestion_mappings" TO "service_role"; -GRANT ALL ON TABLE "public"."overall_review_knowledge_suggestion_mapping" TO "anon"; -GRANT ALL ON TABLE "public"."overall_review_knowledge_suggestion_mapping" TO "authenticated"; -GRANT ALL ON TABLE "public"."overall_review_knowledge_suggestion_mapping" TO "service_role"; +GRANT ALL ON TABLE "public"."overall_reviews" TO "anon"; +GRANT ALL ON TABLE "public"."overall_reviews" TO "authenticated"; +GRANT ALL ON TABLE "public"."overall_reviews" TO "service_role"; -GRANT ALL ON TABLE "public"."project" TO "anon"; -GRANT ALL ON TABLE "public"."project" TO "authenticated"; -GRANT ALL ON TABLE "public"."project" TO "service_role"; +GRANT ALL ON TABLE "public"."project_repository_mappings" TO "anon"; +GRANT ALL ON TABLE "public"."project_repository_mappings" TO "authenticated"; +GRANT ALL ON TABLE "public"."project_repository_mappings" TO "service_role"; -GRANT ALL ON TABLE "public"."project_repository_mapping" TO "anon"; -GRANT ALL ON TABLE "public"."project_repository_mapping" TO "authenticated"; -GRANT ALL ON TABLE "public"."project_repository_mapping" TO "service_role"; +GRANT ALL ON TABLE "public"."projects" TO "anon"; +GRANT ALL ON TABLE "public"."projects" TO "authenticated"; +GRANT ALL ON TABLE "public"."projects" TO "service_role"; -GRANT ALL ON TABLE "public"."pull_request" TO "anon"; -GRANT ALL ON TABLE "public"."pull_request" TO "authenticated"; -GRANT ALL ON TABLE "public"."pull_request" TO "service_role"; +GRANT ALL ON TABLE "public"."pull_requests" TO "anon"; +GRANT ALL ON TABLE "public"."pull_requests" TO "authenticated"; +GRANT ALL ON TABLE "public"."pull_requests" TO "service_role"; -GRANT ALL ON TABLE "public"."repository" TO "anon"; -GRANT ALL ON TABLE "public"."repository" TO "authenticated"; -GRANT ALL ON TABLE "public"."repository" TO "service_role"; +GRANT ALL ON TABLE "public"."repositories" TO "anon"; +GRANT ALL ON TABLE "public"."repositories" TO "authenticated"; +GRANT ALL ON TABLE "public"."repositories" TO "service_role"; -GRANT ALL ON TABLE "public"."review_feedback" TO "anon"; -GRANT ALL ON TABLE "public"."review_feedback" TO "authenticated"; -GRANT ALL ON TABLE "public"."review_feedback" TO "service_role"; +GRANT ALL ON TABLE "public"."review_feedback_comments" TO "anon"; +GRANT ALL ON TABLE "public"."review_feedback_comments" TO "authenticated"; +GRANT ALL ON TABLE "public"."review_feedback_comments" TO "service_role"; -GRANT ALL ON TABLE "public"."review_feedback_comment" TO "anon"; -GRANT ALL ON TABLE "public"."review_feedback_comment" TO "authenticated"; -GRANT ALL ON TABLE "public"."review_feedback_comment" TO "service_role"; +GRANT ALL ON TABLE "public"."review_feedbacks" TO "anon"; +GRANT ALL ON TABLE "public"."review_feedbacks" TO "authenticated"; +GRANT ALL ON TABLE "public"."review_feedbacks" TO "service_role"; -GRANT ALL ON TABLE "public"."review_suggestion_snippet" TO "anon"; -GRANT ALL ON TABLE "public"."review_suggestion_snippet" TO "authenticated"; -GRANT ALL ON TABLE "public"."review_suggestion_snippet" TO "service_role"; +GRANT ALL ON TABLE "public"."review_suggestion_snippets" TO "anon"; +GRANT ALL ON TABLE "public"."review_suggestion_snippets" TO "authenticated"; +GRANT ALL ON TABLE "public"."review_suggestion_snippets" TO "service_role"; -GRANT ALL ON TABLE "public"."user" TO "anon"; -GRANT ALL ON TABLE "public"."user" TO "authenticated"; -GRANT ALL ON TABLE "public"."user" TO "service_role"; +GRANT ALL ON TABLE "public"."users" TO "anon"; +GRANT ALL ON TABLE "public"."users" TO "authenticated"; +GRANT ALL ON TABLE "public"."users" TO "service_role"; diff --git a/frontend/packages/db/supabase/database.types.ts b/frontend/packages/db/supabase/database.types.ts index 8dfd7b2716..06b4c6af80 100644 --- a/frontend/packages/db/supabase/database.types.ts +++ b/frontend/packages/db/supabase/database.types.ts @@ -34,7 +34,7 @@ export type Database = { } public: { Tables: { - github_doc_file_path: { + github_doc_file_paths: { Row: { created_at: string id: string @@ -64,12 +64,12 @@ export type Database = { foreignKeyName: 'github_doc_file_path_project_id_fkey' columns: ['project_id'] isOneToOne: false - referencedRelation: 'project' + referencedRelation: 'projects' referencedColumns: ['id'] }, ] } - github_schema_file_path: { + github_schema_file_paths: { Row: { created_at: string format: Database['public']['Enums']['schema_format_enum'] @@ -99,12 +99,51 @@ export type Database = { foreignKeyName: 'github_schema_file_path_project_id_fkey' columns: ['project_id'] isOneToOne: false - referencedRelation: 'project' + referencedRelation: 'projects' referencedColumns: ['id'] }, ] } - knowledge_suggestion: { + knowledge_suggestion_doc_mappings: { + Row: { + created_at: string + github_doc_file_path_id: string + id: string + knowledge_suggestion_id: string + updated_at: string + } + Insert: { + created_at?: string + github_doc_file_path_id: string + id?: string + knowledge_suggestion_id: string + updated_at: string + } + Update: { + created_at?: string + github_doc_file_path_id?: string + id?: string + knowledge_suggestion_id?: string + updated_at?: string + } + Relationships: [ + { + foreignKeyName: 'knowledge_suggestion_doc_mapping_github_doc_file_path_id_fkey' + columns: ['github_doc_file_path_id'] + isOneToOne: false + referencedRelation: 'github_doc_file_paths' + referencedColumns: ['id'] + }, + { + foreignKeyName: 'knowledge_suggestion_doc_mapping_knowledge_suggestion_id_fkey' + columns: ['knowledge_suggestion_id'] + isOneToOne: false + referencedRelation: 'knowledge_suggestions' + referencedColumns: ['id'] + }, + ] + } + knowledge_suggestions: { Row: { approved_at: string | null branch_name: string @@ -155,46 +194,7 @@ export type Database = { foreignKeyName: 'knowledge_suggestion_project_id_fkey' columns: ['project_id'] isOneToOne: false - referencedRelation: 'project' - referencedColumns: ['id'] - }, - ] - } - knowledge_suggestion_doc_mapping: { - Row: { - created_at: string - github_doc_file_path_id: string - id: string - knowledge_suggestion_id: string - updated_at: string - } - Insert: { - created_at?: string - github_doc_file_path_id: string - id?: string - knowledge_suggestion_id: string - updated_at: string - } - Update: { - created_at?: string - github_doc_file_path_id?: string - id?: string - knowledge_suggestion_id?: string - updated_at?: string - } - Relationships: [ - { - foreignKeyName: 'knowledge_suggestion_doc_mapping_github_doc_file_path_id_fkey' - columns: ['github_doc_file_path_id'] - isOneToOne: false - referencedRelation: 'github_doc_file_path' - referencedColumns: ['id'] - }, - { - foreignKeyName: 'knowledge_suggestion_doc_mapping_knowledge_suggestion_id_fkey' - columns: ['knowledge_suggestion_id'] - isOneToOne: false - referencedRelation: 'knowledge_suggestion' + referencedRelation: 'projects' referencedColumns: ['id'] }, ] @@ -226,19 +226,19 @@ export type Database = { foreignKeyName: 'membership_invites_invite_by_user_id_fkey' columns: ['invite_by_user_id'] isOneToOne: false - referencedRelation: 'user' + referencedRelation: 'users' referencedColumns: ['id'] }, { foreignKeyName: 'membership_invites_organization_id_fkey' columns: ['organization_id'] isOneToOne: false - referencedRelation: 'organization' + referencedRelation: 'organizations' referencedColumns: ['id'] }, ] } - migration: { + migrations: { Row: { created_at: string id: string @@ -265,12 +265,48 @@ export type Database = { foreignKeyName: 'migration_pull_request_id_fkey' columns: ['pull_request_id'] isOneToOne: false - referencedRelation: 'pull_request' + referencedRelation: 'pull_requests' referencedColumns: ['id'] }, ] } - organization: { + organization_members: { + Row: { + id: string + joined_at: string | null + organization_id: string + user_id: string + } + Insert: { + id?: string + joined_at?: string | null + organization_id: string + user_id: string + } + Update: { + id?: string + joined_at?: string | null + organization_id?: string + user_id?: string + } + Relationships: [ + { + foreignKeyName: 'organization_member_organization_id_fkey' + columns: ['organization_id'] + isOneToOne: false + referencedRelation: 'organizations' + referencedColumns: ['id'] + }, + { + foreignKeyName: 'organization_member_user_id_fkey' + columns: ['user_id'] + isOneToOne: false + referencedRelation: 'users' + referencedColumns: ['id'] + }, + ] + } + organizations: { Row: { id: string name: string @@ -285,43 +321,46 @@ export type Database = { } Relationships: [] } - organization_member: { + overall_review_knowledge_suggestion_mappings: { Row: { + created_at: string id: string - joined_at: string | null - organization_id: string - user_id: string + knowledge_suggestion_id: string + overall_review_id: string + updated_at: string } Insert: { + created_at?: string id?: string - joined_at?: string | null - organization_id: string - user_id: string + knowledge_suggestion_id: string + overall_review_id: string + updated_at: string } Update: { + created_at?: string id?: string - joined_at?: string | null - organization_id?: string - user_id?: string + knowledge_suggestion_id?: string + overall_review_id?: string + updated_at?: string } Relationships: [ { - foreignKeyName: 'organization_member_organization_id_fkey' - columns: ['organization_id'] + foreignKeyName: 'overall_review_knowledge_suggestion_mapping_knowledge_suggestio' + columns: ['knowledge_suggestion_id'] isOneToOne: false - referencedRelation: 'organization' + referencedRelation: 'knowledge_suggestions' referencedColumns: ['id'] }, { - foreignKeyName: 'organization_member_user_id_fkey' - columns: ['user_id'] + foreignKeyName: 'overall_review_knowledge_suggestion_mapping_overall_review_id_f' + columns: ['overall_review_id'] isOneToOne: false - referencedRelation: 'user' + referencedRelation: 'overall_reviews' referencedColumns: ['id'] }, ] } - overall_review: { + overall_reviews: { Row: { branch_name: string created_at: string @@ -360,58 +399,58 @@ export type Database = { foreignKeyName: 'overall_review_project_id_fkey' columns: ['project_id'] isOneToOne: false - referencedRelation: 'project' + referencedRelation: 'projects' referencedColumns: ['id'] }, { foreignKeyName: 'overall_review_pull_request_id_fkey' columns: ['pull_request_id'] isOneToOne: false - referencedRelation: 'pull_request' + referencedRelation: 'pull_requests' referencedColumns: ['id'] }, ] } - overall_review_knowledge_suggestion_mapping: { + project_repository_mappings: { Row: { created_at: string id: string - knowledge_suggestion_id: string - overall_review_id: string + project_id: string + repository_id: string updated_at: string } Insert: { created_at?: string id?: string - knowledge_suggestion_id: string - overall_review_id: string + project_id: string + repository_id: string updated_at: string } Update: { created_at?: string id?: string - knowledge_suggestion_id?: string - overall_review_id?: string + project_id?: string + repository_id?: string updated_at?: string } Relationships: [ { - foreignKeyName: 'overall_review_knowledge_suggestion_mapping_knowledge_suggestio' - columns: ['knowledge_suggestion_id'] + foreignKeyName: 'project_repository_mapping_project_id_fkey' + columns: ['project_id'] isOneToOne: false - referencedRelation: 'knowledge_suggestion' + referencedRelation: 'projects' referencedColumns: ['id'] }, { - foreignKeyName: 'overall_review_knowledge_suggestion_mapping_overall_review_id_f' - columns: ['overall_review_id'] + foreignKeyName: 'project_repository_mapping_repository_id_fkey' + columns: ['repository_id'] isOneToOne: false - referencedRelation: 'overall_review' + referencedRelation: 'repositories' referencedColumns: ['id'] }, ] } - project: { + projects: { Row: { created_at: string id: string @@ -438,51 +477,12 @@ export type Database = { foreignKeyName: 'project_organization_id_fkey' columns: ['organization_id'] isOneToOne: false - referencedRelation: 'organization' + referencedRelation: 'organizations' referencedColumns: ['id'] }, ] } - project_repository_mapping: { - Row: { - created_at: string - id: string - project_id: string - repository_id: string - updated_at: string - } - Insert: { - created_at?: string - id?: string - project_id: string - repository_id: string - updated_at: string - } - Update: { - created_at?: string - id?: string - project_id?: string - repository_id?: string - updated_at?: string - } - Relationships: [ - { - foreignKeyName: 'project_repository_mapping_project_id_fkey' - columns: ['project_id'] - isOneToOne: false - referencedRelation: 'project' - referencedColumns: ['id'] - }, - { - foreignKeyName: 'project_repository_mapping_repository_id_fkey' - columns: ['repository_id'] - isOneToOne: false - referencedRelation: 'repository' - referencedColumns: ['id'] - }, - ] - } - pull_request: { + pull_requests: { Row: { comment_id: number | null created_at: string @@ -512,12 +512,12 @@ export type Database = { foreignKeyName: 'pull_request_repository_id_fkey' columns: ['repository_id'] isOneToOne: false - referencedRelation: 'repository' + referencedRelation: 'repositories' referencedColumns: ['id'] }, ] } - repository: { + repositories: { Row: { created_at: string id: string @@ -547,7 +547,49 @@ export type Database = { } Relationships: [] } - review_feedback: { + review_feedback_comments: { + Row: { + content: string + created_at: string + id: string + review_feedback_id: string + updated_at: string + user_id: string + } + Insert: { + content: string + created_at?: string + id?: string + review_feedback_id: string + updated_at: string + user_id: string + } + Update: { + content?: string + created_at?: string + id?: string + review_feedback_id?: string + updated_at?: string + user_id?: string + } + Relationships: [ + { + foreignKeyName: 'review_feedback_comment_review_feedback_id_fkey' + columns: ['review_feedback_id'] + isOneToOne: false + referencedRelation: 'review_feedbacks' + referencedColumns: ['id'] + }, + { + foreignKeyName: 'review_feedback_comment_user_id_fkey' + columns: ['user_id'] + isOneToOne: false + referencedRelation: 'users' + referencedColumns: ['id'] + }, + ] + } + review_feedbacks: { Row: { category: Database['public']['Enums']['category_enum'] created_at: string @@ -589,54 +631,12 @@ export type Database = { foreignKeyName: 'review_feedback_overall_review_id_fkey' columns: ['overall_review_id'] isOneToOne: false - referencedRelation: 'overall_review' - referencedColumns: ['id'] - }, - ] - } - review_feedback_comment: { - Row: { - content: string - created_at: string - id: string - review_feedback_id: string - updated_at: string - user_id: string - } - Insert: { - content: string - created_at?: string - id?: string - review_feedback_id: string - updated_at: string - user_id: string - } - Update: { - content?: string - created_at?: string - id?: string - review_feedback_id?: string - updated_at?: string - user_id?: string - } - Relationships: [ - { - foreignKeyName: 'review_feedback_comment_review_feedback_id_fkey' - columns: ['review_feedback_id'] - isOneToOne: false - referencedRelation: 'review_feedback' - referencedColumns: ['id'] - }, - { - foreignKeyName: 'review_feedback_comment_user_id_fkey' - columns: ['user_id'] - isOneToOne: false - referencedRelation: 'user' + referencedRelation: 'overall_reviews' referencedColumns: ['id'] }, ] } - review_suggestion_snippet: { + review_suggestion_snippets: { Row: { created_at: string filename: string @@ -666,12 +666,12 @@ export type Database = { foreignKeyName: 'review_suggestion_snippet_review_feedback_id_fkey' columns: ['review_feedback_id'] isOneToOne: false - referencedRelation: 'review_feedback' + referencedRelation: 'review_feedbacks' referencedColumns: ['id'] }, ] } - user: { + users: { Row: { email: string id: string diff --git a/frontend/packages/db/supabase/migrations/20250416105745_initial_squash.sql b/frontend/packages/db/supabase/migrations/20250416105745_initial_squash.sql index 240ecd6a2a..46b5c19ee0 100644 --- a/frontend/packages/db/supabase/migrations/20250416105745_initial_squash.sql +++ b/frontend/packages/db/supabase/migrations/20250416105745_initial_squash.sql @@ -111,7 +111,7 @@ CREATE OR REPLACE FUNCTION "public"."handle_new_user"() RETURNS "trigger" SET "search_path" TO '' AS $$ BEGIN - INSERT INTO public."user" (id, name, email) + INSERT INTO public."users" (id, name, email) VALUES ( NEW.id, COALESCE(NEW.raw_user_meta_data->>'name', NEW.email), @@ -129,13 +129,13 @@ CREATE OR REPLACE FUNCTION "public"."sync_existing_users"() RETURNS "void" LANGUAGE "plpgsql" SECURITY DEFINER AS $$ BEGIN - INSERT INTO public."user" (id, name, email) + INSERT INTO public."users" (id, name, email) SELECT au.id, COALESCE(au.raw_user_meta_data->>'name', au.email), au.email FROM auth.users au - LEFT JOIN public."user" pu ON au.id = pu.id + LEFT JOIN public."users" pu ON au.id = pu.id WHERE pu.id IS NULL; END; $$; @@ -148,7 +148,7 @@ SET default_tablespace = ''; SET default_table_access_method = "heap"; -CREATE TABLE IF NOT EXISTS "public"."github_doc_file_path" ( +CREATE TABLE IF NOT EXISTS "public"."github_doc_file_paths" ( "id" uuid NOT NULL DEFAULT gen_random_uuid(), "path" "text" NOT NULL, "is_review_enabled" boolean DEFAULT true NOT NULL, @@ -158,7 +158,7 @@ CREATE TABLE IF NOT EXISTS "public"."github_doc_file_path" ( ); -ALTER TABLE "public"."github_doc_file_path" OWNER TO "postgres"; +ALTER TABLE "public"."github_doc_file_paths" OWNER TO "postgres"; @@ -168,7 +168,7 @@ ALTER TABLE "public"."github_doc_file_path" OWNER TO "postgres"; -CREATE TABLE IF NOT EXISTS "public"."github_schema_file_path" ( +CREATE TABLE IF NOT EXISTS "public"."github_schema_file_paths" ( "id" uuid NOT NULL DEFAULT gen_random_uuid(), "path" "text" NOT NULL, "project_id" uuid NOT NULL, @@ -178,7 +178,7 @@ CREATE TABLE IF NOT EXISTS "public"."github_schema_file_path" ( ); -ALTER TABLE "public"."github_schema_file_path" OWNER TO "postgres"; +ALTER TABLE "public"."github_schema_file_paths" OWNER TO "postgres"; @@ -188,7 +188,7 @@ ALTER TABLE "public"."github_schema_file_path" OWNER TO "postgres"; -CREATE TABLE IF NOT EXISTS "public"."knowledge_suggestion" ( +CREATE TABLE IF NOT EXISTS "public"."knowledge_suggestions" ( "id" uuid NOT NULL DEFAULT gen_random_uuid(), "type" "public"."knowledge_type" NOT NULL, "title" "text" NOT NULL, @@ -205,10 +205,10 @@ CREATE TABLE IF NOT EXISTS "public"."knowledge_suggestion" ( ); -ALTER TABLE "public"."knowledge_suggestion" OWNER TO "postgres"; +ALTER TABLE "public"."knowledge_suggestions" OWNER TO "postgres"; -CREATE TABLE IF NOT EXISTS "public"."knowledge_suggestion_doc_mapping" ( +CREATE TABLE IF NOT EXISTS "public"."knowledge_suggestion_doc_mappings" ( "id" uuid NOT NULL DEFAULT gen_random_uuid(), "knowledge_suggestion_id" uuid NOT NULL, "github_doc_file_path_id" uuid NOT NULL, @@ -217,7 +217,7 @@ CREATE TABLE IF NOT EXISTS "public"."knowledge_suggestion_doc_mapping" ( ); -ALTER TABLE "public"."knowledge_suggestion_doc_mapping" OWNER TO "postgres"; +ALTER TABLE "public"."knowledge_suggestion_doc_mappings" OWNER TO "postgres"; @@ -246,7 +246,7 @@ CREATE TABLE IF NOT EXISTS "public"."membership_invites" ( ALTER TABLE "public"."membership_invites" OWNER TO "postgres"; -CREATE TABLE IF NOT EXISTS "public"."migration" ( +CREATE TABLE IF NOT EXISTS "public"."migrations" ( "id" uuid NOT NULL DEFAULT gen_random_uuid(), "title" "text" NOT NULL, "pull_request_id" uuid NOT NULL, @@ -255,7 +255,7 @@ CREATE TABLE IF NOT EXISTS "public"."migration" ( ); -ALTER TABLE "public"."migration" OWNER TO "postgres"; +ALTER TABLE "public"."migrations" OWNER TO "postgres"; @@ -265,16 +265,16 @@ ALTER TABLE "public"."migration" OWNER TO "postgres"; -CREATE TABLE IF NOT EXISTS "public"."organization" ( +CREATE TABLE IF NOT EXISTS "public"."organizations" ( "id" uuid NOT NULL DEFAULT gen_random_uuid(), "name" "text" NOT NULL ); -ALTER TABLE "public"."organization" OWNER TO "postgres"; +ALTER TABLE "public"."organizations" OWNER TO "postgres"; -CREATE TABLE IF NOT EXISTS "public"."organization_member" ( +CREATE TABLE IF NOT EXISTS "public"."organization_members" ( "id" uuid NOT NULL DEFAULT gen_random_uuid(), "user_id" "uuid" NOT NULL, "organization_id" uuid NOT NULL, @@ -282,12 +282,12 @@ CREATE TABLE IF NOT EXISTS "public"."organization_member" ( ); -ALTER TABLE "public"."organization_member" OWNER TO "postgres"; +ALTER TABLE "public"."organization_members" OWNER TO "postgres"; -CREATE TABLE IF NOT EXISTS "public"."overall_review" ( +CREATE TABLE IF NOT EXISTS "public"."overall_reviews" ( "id" uuid NOT NULL DEFAULT gen_random_uuid(), "project_id" uuid, "pull_request_id" uuid NOT NULL, @@ -300,10 +300,10 @@ CREATE TABLE IF NOT EXISTS "public"."overall_review" ( ); -ALTER TABLE "public"."overall_review" OWNER TO "postgres"; +ALTER TABLE "public"."overall_reviews" OWNER TO "postgres"; -CREATE TABLE IF NOT EXISTS "public"."overall_review_knowledge_suggestion_mapping" ( +CREATE TABLE IF NOT EXISTS "public"."overall_review_knowledge_suggestion_mappings" ( "id" uuid NOT NULL DEFAULT gen_random_uuid(), "overall_review_id" uuid NOT NULL, "knowledge_suggestion_id" uuid NOT NULL, @@ -312,7 +312,7 @@ CREATE TABLE IF NOT EXISTS "public"."overall_review_knowledge_suggestion_mapping ); -ALTER TABLE "public"."overall_review_knowledge_suggestion_mapping" OWNER TO "postgres"; +ALTER TABLE "public"."overall_review_knowledge_suggestion_mappings" OWNER TO "postgres"; @@ -329,7 +329,7 @@ ALTER TABLE "public"."overall_review_knowledge_suggestion_mapping" OWNER TO "pos -CREATE TABLE IF NOT EXISTS "public"."project" ( +CREATE TABLE IF NOT EXISTS "public"."projects" ( "id" uuid NOT NULL DEFAULT gen_random_uuid(), "name" "text" NOT NULL, "created_at" timestamp(3) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, @@ -337,10 +337,10 @@ CREATE TABLE IF NOT EXISTS "public"."project" ( "organization_id" uuid ); -ALTER TABLE "public"."project" OWNER TO "postgres"; +ALTER TABLE "public"."projects" OWNER TO "postgres"; -CREATE TABLE IF NOT EXISTS "public"."project_repository_mapping" ( +CREATE TABLE IF NOT EXISTS "public"."project_repository_mappings" ( "id" uuid NOT NULL DEFAULT gen_random_uuid(), "project_id" uuid NOT NULL, "repository_id" uuid NOT NULL, @@ -349,7 +349,7 @@ CREATE TABLE IF NOT EXISTS "public"."project_repository_mapping" ( ); -ALTER TABLE "public"."project_repository_mapping" OWNER TO "postgres"; +ALTER TABLE "public"."project_repository_mappings" OWNER TO "postgres"; @@ -366,7 +366,7 @@ ALTER TABLE "public"."project_repository_mapping" OWNER TO "postgres"; -CREATE TABLE IF NOT EXISTS "public"."pull_request" ( +CREATE TABLE IF NOT EXISTS "public"."pull_requests" ( "id" uuid NOT NULL DEFAULT gen_random_uuid(), "pull_number" bigint NOT NULL, "comment_id" bigint, @@ -376,7 +376,7 @@ CREATE TABLE IF NOT EXISTS "public"."pull_request" ( ); -ALTER TABLE "public"."pull_request" OWNER TO "postgres"; +ALTER TABLE "public"."pull_requests" OWNER TO "postgres"; @@ -386,7 +386,7 @@ ALTER TABLE "public"."pull_request" OWNER TO "postgres"; -CREATE TABLE IF NOT EXISTS "public"."repository" ( +CREATE TABLE IF NOT EXISTS "public"."repositories" ( "id" uuid NOT NULL DEFAULT gen_random_uuid(), "name" "text" NOT NULL, "owner" "text" NOT NULL, @@ -397,7 +397,7 @@ CREATE TABLE IF NOT EXISTS "public"."repository" ( ); -ALTER TABLE "public"."repository" OWNER TO "postgres"; +ALTER TABLE "public"."repositories" OWNER TO "postgres"; @@ -407,7 +407,7 @@ ALTER TABLE "public"."repository" OWNER TO "postgres"; -CREATE TABLE IF NOT EXISTS "public"."review_feedback" ( +CREATE TABLE IF NOT EXISTS "public"."review_feedbacks" ( "id" uuid NOT NULL DEFAULT gen_random_uuid(), "overall_review_id" uuid NOT NULL, "category" "public"."category_enum" NOT NULL, @@ -421,14 +421,14 @@ CREATE TABLE IF NOT EXISTS "public"."review_feedback" ( ); -ALTER TABLE "public"."review_feedback" OWNER TO "postgres"; +ALTER TABLE "public"."review_feedbacks" OWNER TO "postgres"; -CREATE TABLE IF NOT EXISTS "public"."review_feedback_comment" ( +CREATE TABLE IF NOT EXISTS "public"."review_feedback_comments" ( "id" uuid DEFAULT gen_random_uuid(), "review_feedback_id" uuid NOT NULL, "user_id" "uuid" NOT NULL, @@ -438,7 +438,7 @@ CREATE TABLE IF NOT EXISTS "public"."review_feedback_comment" ( ); -ALTER TABLE "public"."review_feedback_comment" OWNER TO "postgres"; +ALTER TABLE "public"."review_feedback_comments" OWNER TO "postgres"; @@ -452,7 +452,7 @@ ALTER TABLE "public"."review_feedback_comment" OWNER TO "postgres"; -CREATE TABLE IF NOT EXISTS "public"."review_suggestion_snippet" ( +CREATE TABLE IF NOT EXISTS "public"."review_suggestion_snippets" ( "id" uuid DEFAULT gen_random_uuid(), "review_feedback_id" uuid NOT NULL, "filename" "text" NOT NULL, @@ -462,17 +462,17 @@ CREATE TABLE IF NOT EXISTS "public"."review_suggestion_snippet" ( ); -ALTER TABLE "public"."review_suggestion_snippet" OWNER TO "postgres"; +ALTER TABLE "public"."review_suggestion_snippets" OWNER TO "postgres"; -CREATE TABLE IF NOT EXISTS "public"."user" ( +CREATE TABLE IF NOT EXISTS "public"."users" ( "id" "uuid" NOT NULL, "name" "text" NOT NULL, "email" "text" NOT NULL ); -ALTER TABLE "public"."user" OWNER TO "postgres"; +ALTER TABLE "public"."users" OWNER TO "postgres"; @@ -511,27 +511,27 @@ ALTER TABLE "public"."user" OWNER TO "postgres"; -ALTER TABLE ONLY "public"."github_doc_file_path" +ALTER TABLE ONLY "public"."github_doc_file_paths" ADD CONSTRAINT "github_doc_file_path_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."github_schema_file_path" +ALTER TABLE ONLY "public"."github_schema_file_paths" ADD CONSTRAINT "github_schema_file_path_path_project_id_key" UNIQUE ("path", "project_id"); -ALTER TABLE ONLY "public"."github_schema_file_path" +ALTER TABLE ONLY "public"."github_schema_file_paths" ADD CONSTRAINT "github_schema_file_path_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."knowledge_suggestion_doc_mapping" +ALTER TABLE ONLY "public"."knowledge_suggestion_doc_mappings" ADD CONSTRAINT "knowledge_suggestion_doc_mapping_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."knowledge_suggestion" +ALTER TABLE ONLY "public"."knowledge_suggestions" ADD CONSTRAINT "knowledge_suggestion_pkey" PRIMARY KEY ("id"); @@ -541,118 +541,118 @@ ALTER TABLE ONLY "public"."membership_invites" -ALTER TABLE ONLY "public"."migration" +ALTER TABLE ONLY "public"."migrations" ADD CONSTRAINT "migration_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."organization_member" +ALTER TABLE ONLY "public"."organization_members" ADD CONSTRAINT "organization_member_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."organization_member" +ALTER TABLE ONLY "public"."organization_members" ADD CONSTRAINT "organization_member_user_id_organization_id_key" UNIQUE ("user_id", "organization_id"); -ALTER TABLE ONLY "public"."organization" +ALTER TABLE ONLY "public"."organizations" ADD CONSTRAINT "organization_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."overall_review_knowledge_suggestion_mapping" +ALTER TABLE ONLY "public"."overall_review_knowledge_suggestion_mappings" ADD CONSTRAINT "overall_review_knowledge_suggestion_mapping_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."overall_review" +ALTER TABLE ONLY "public"."overall_reviews" ADD CONSTRAINT "overall_review_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."project_repository_mapping" +ALTER TABLE ONLY "public"."project_repository_mappings" ADD CONSTRAINT "project_repository_mapping_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."project" +ALTER TABLE ONLY "public"."projects" ADD CONSTRAINT "project_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."pull_request" +ALTER TABLE ONLY "public"."pull_requests" ADD CONSTRAINT "pull_request_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."repository" +ALTER TABLE ONLY "public"."repositories" ADD CONSTRAINT "repository_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."review_feedback_comment" +ALTER TABLE ONLY "public"."review_feedback_comments" ADD CONSTRAINT "review_feedback_comment_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."review_feedback" +ALTER TABLE ONLY "public"."review_feedbacks" ADD CONSTRAINT "review_feedback_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."review_suggestion_snippet" +ALTER TABLE ONLY "public"."review_suggestion_snippets" ADD CONSTRAINT "review_suggestion_snippet_pkey" PRIMARY KEY ("id"); -ALTER TABLE ONLY "public"."user" +ALTER TABLE ONLY "public"."users" ADD CONSTRAINT "user_email_key" UNIQUE ("email"); -ALTER TABLE ONLY "public"."user" +ALTER TABLE ONLY "public"."users" ADD CONSTRAINT "user_pkey" PRIMARY KEY ("id"); -CREATE UNIQUE INDEX "github_doc_file_path_path_project_id_key" ON "public"."github_doc_file_path" USING "btree" ("path", "project_id"); +CREATE UNIQUE INDEX "github_doc_file_path_path_project_id_key" ON "public"."github_doc_file_paths" USING "btree" ("path", "project_id"); -CREATE UNIQUE INDEX "github_schema_file_path_project_id_key" ON "public"."github_schema_file_path" USING "btree" ("project_id"); +CREATE UNIQUE INDEX "github_schema_file_path_project_id_key" ON "public"."github_schema_file_paths" USING "btree" ("project_id"); -CREATE UNIQUE INDEX "knowledge_suggestion_doc_mapping_unique_mapping" ON "public"."knowledge_suggestion_doc_mapping" USING "btree" ("knowledge_suggestion_id", "github_doc_file_path_id"); +CREATE UNIQUE INDEX "knowledge_suggestion_doc_mapping_unique_mapping" ON "public"."knowledge_suggestion_doc_mappings" USING "btree" ("knowledge_suggestion_id", "github_doc_file_path_id"); -CREATE UNIQUE INDEX "migration_pull_request_id_key" ON "public"."migration" USING "btree" ("pull_request_id"); +CREATE UNIQUE INDEX "migration_pull_request_id_key" ON "public"."migrations" USING "btree" ("pull_request_id"); -CREATE UNIQUE INDEX "overall_review_knowledge_suggestion_mapping_unique_mapping" ON "public"."overall_review_knowledge_suggestion_mapping" USING "btree" ("overall_review_id", "knowledge_suggestion_id"); +CREATE UNIQUE INDEX "overall_review_knowledge_suggestion_mapping_unique_mapping" ON "public"."overall_review_knowledge_suggestion_mappings" USING "btree" ("overall_review_id", "knowledge_suggestion_id"); -CREATE UNIQUE INDEX "project_repository_mapping_project_id_repository_id_key" ON "public"."project_repository_mapping" USING "btree" ("project_id", "repository_id"); +CREATE UNIQUE INDEX "project_repository_mapping_project_id_repository_id_key" ON "public"."project_repository_mappings" USING "btree" ("project_id", "repository_id"); -CREATE UNIQUE INDEX "pull_request_repository_id_pull_number_key" ON "public"."pull_request" USING "btree" ("repository_id", "pull_number"); +CREATE UNIQUE INDEX "pull_request_repository_id_pull_number_key" ON "public"."pull_requests" USING "btree" ("repository_id", "pull_number"); -CREATE UNIQUE INDEX "repository_owner_name_key" ON "public"."repository" USING "btree" ("owner", "name"); +CREATE UNIQUE INDEX "repository_owner_name_key" ON "public"."repositories" USING "btree" ("owner", "name"); -CREATE INDEX "idx_project_organization_id" ON "public"."project" USING "btree" ("organization_id"); +CREATE INDEX "idx_project_organization_id" ON "public"."projects" USING "btree" ("organization_id"); -CREATE INDEX "idx_review_feedback_comment_review_feedback_id" ON "public"."review_feedback_comment" USING "btree" ("review_feedback_id"); +CREATE INDEX "idx_review_feedback_comment_review_feedback_id" ON "public"."review_feedback_comments" USING "btree" ("review_feedback_id"); @@ -664,198 +664,198 @@ CREATE INDEX "membership_invites_org_id_idx" ON "public"."membership_invites" US -CREATE INDEX "organization_member_organization_id_idx" ON "public"."organization_member" USING "btree" ("organization_id"); +CREATE INDEX "organization_member_organization_id_idx" ON "public"."organization_members" USING "btree" ("organization_id"); -CREATE INDEX "organization_member_user_id_idx" ON "public"."organization_member" USING "btree" ("user_id"); +CREATE INDEX "organization_member_user_id_idx" ON "public"."organization_members" USING "btree" ("user_id"); -ALTER TABLE ONLY "public"."github_doc_file_path" - ADD CONSTRAINT "github_doc_file_path_project_id_fkey" FOREIGN KEY ("project_id") REFERENCES "public"."project"("id") ON UPDATE CASCADE ON DELETE RESTRICT; +ALTER TABLE ONLY "public"."github_doc_file_paths" + ADD CONSTRAINT "github_doc_file_path_project_id_fkey" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON UPDATE CASCADE ON DELETE RESTRICT; -ALTER TABLE ONLY "public"."github_schema_file_path" - ADD CONSTRAINT "github_schema_file_path_project_id_fkey" FOREIGN KEY ("project_id") REFERENCES "public"."project"("id") ON UPDATE CASCADE ON DELETE RESTRICT; +ALTER TABLE ONLY "public"."github_schema_file_paths" + ADD CONSTRAINT "github_schema_file_path_project_id_fkey" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON UPDATE CASCADE ON DELETE RESTRICT; -ALTER TABLE ONLY "public"."knowledge_suggestion_doc_mapping" - ADD CONSTRAINT "knowledge_suggestion_doc_mapping_github_doc_file_path_id_fkey" FOREIGN KEY ("github_doc_file_path_id") REFERENCES "public"."github_doc_file_path"("id") ON UPDATE CASCADE ON DELETE CASCADE; +ALTER TABLE ONLY "public"."knowledge_suggestion_doc_mappings" + ADD CONSTRAINT "knowledge_suggestion_doc_mapping_github_doc_file_path_id_fkey" FOREIGN KEY ("github_doc_file_path_id") REFERENCES "public"."github_doc_file_paths"("id") ON UPDATE CASCADE ON DELETE CASCADE; -ALTER TABLE ONLY "public"."knowledge_suggestion_doc_mapping" - ADD CONSTRAINT "knowledge_suggestion_doc_mapping_knowledge_suggestion_id_fkey" FOREIGN KEY ("knowledge_suggestion_id") REFERENCES "public"."knowledge_suggestion"("id") ON UPDATE CASCADE ON DELETE CASCADE; +ALTER TABLE ONLY "public"."knowledge_suggestion_doc_mappings" + ADD CONSTRAINT "knowledge_suggestion_doc_mapping_knowledge_suggestion_id_fkey" FOREIGN KEY ("knowledge_suggestion_id") REFERENCES "public"."knowledge_suggestions"("id") ON UPDATE CASCADE ON DELETE CASCADE; -ALTER TABLE ONLY "public"."knowledge_suggestion" - ADD CONSTRAINT "knowledge_suggestion_project_id_fkey" FOREIGN KEY ("project_id") REFERENCES "public"."project"("id") ON UPDATE CASCADE ON DELETE RESTRICT; +ALTER TABLE ONLY "public"."knowledge_suggestions" + ADD CONSTRAINT "knowledge_suggestion_project_id_fkey" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON UPDATE CASCADE ON DELETE RESTRICT; ALTER TABLE ONLY "public"."membership_invites" - ADD CONSTRAINT "membership_invites_invite_by_user_id_fkey" FOREIGN KEY ("invite_by_user_id") REFERENCES "public"."user"("id") ON DELETE CASCADE; + ADD CONSTRAINT "membership_invites_invite_by_user_id_fkey" FOREIGN KEY ("invite_by_user_id") REFERENCES "public"."users"("id") ON DELETE CASCADE; ALTER TABLE ONLY "public"."membership_invites" - ADD CONSTRAINT "membership_invites_organization_id_fkey" FOREIGN KEY ("organization_id") REFERENCES "public"."organization"("id") ON DELETE CASCADE; + ADD CONSTRAINT "membership_invites_organization_id_fkey" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE CASCADE; -ALTER TABLE ONLY "public"."migration" - ADD CONSTRAINT "migration_pull_request_id_fkey" FOREIGN KEY ("pull_request_id") REFERENCES "public"."pull_request"("id") ON UPDATE CASCADE ON DELETE RESTRICT; +ALTER TABLE ONLY "public"."migrations" + ADD CONSTRAINT "migration_pull_request_id_fkey" FOREIGN KEY ("pull_request_id") REFERENCES "public"."pull_requests"("id") ON UPDATE CASCADE ON DELETE RESTRICT; -ALTER TABLE ONLY "public"."organization_member" - ADD CONSTRAINT "organization_member_organization_id_fkey" FOREIGN KEY ("organization_id") REFERENCES "public"."organization"("id") ON DELETE CASCADE; +ALTER TABLE ONLY "public"."organization_members" + ADD CONSTRAINT "organization_member_organization_id_fkey" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE CASCADE; -ALTER TABLE ONLY "public"."organization_member" - ADD CONSTRAINT "organization_member_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE CASCADE; +ALTER TABLE ONLY "public"."organization_members" + ADD CONSTRAINT "organization_member_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE CASCADE; -ALTER TABLE ONLY "public"."overall_review_knowledge_suggestion_mapping" - ADD CONSTRAINT "overall_review_knowledge_suggestion_mapping_knowledge_suggestion_id_f" FOREIGN KEY ("knowledge_suggestion_id") REFERENCES "public"."knowledge_suggestion"("id") ON UPDATE CASCADE ON DELETE CASCADE; +ALTER TABLE ONLY "public"."overall_review_knowledge_suggestion_mappings" + ADD CONSTRAINT "overall_review_knowledge_suggestion_mapping_knowledge_suggestion_id_f" FOREIGN KEY ("knowledge_suggestion_id") REFERENCES "public"."knowledge_suggestions"("id") ON UPDATE CASCADE ON DELETE CASCADE; -ALTER TABLE ONLY "public"."overall_review_knowledge_suggestion_mapping" - ADD CONSTRAINT "overall_review_knowledge_suggestion_mapping_overall_review_id_fkey" FOREIGN KEY ("overall_review_id") REFERENCES "public"."overall_review"("id") ON UPDATE CASCADE ON DELETE CASCADE; +ALTER TABLE ONLY "public"."overall_review_knowledge_suggestion_mappings" + ADD CONSTRAINT "overall_review_knowledge_suggestion_mapping_overall_review_id_fkey" FOREIGN KEY ("overall_review_id") REFERENCES "public"."overall_reviews"("id") ON UPDATE CASCADE ON DELETE CASCADE; -ALTER TABLE ONLY "public"."overall_review" - ADD CONSTRAINT "overall_review_project_id_fkey" FOREIGN KEY ("project_id") REFERENCES "public"."project"("id") ON UPDATE CASCADE ON DELETE SET NULL; +ALTER TABLE ONLY "public"."overall_reviews" + ADD CONSTRAINT "overall_review_project_id_fkey" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON UPDATE CASCADE ON DELETE SET NULL; -ALTER TABLE ONLY "public"."overall_review" - ADD CONSTRAINT "overall_review_pull_request_id_fkey" FOREIGN KEY ("pull_request_id") REFERENCES "public"."pull_request"("id") ON UPDATE CASCADE ON DELETE RESTRICT; +ALTER TABLE ONLY "public"."overall_reviews" + ADD CONSTRAINT "overall_review_pull_request_id_fkey" FOREIGN KEY ("pull_request_id") REFERENCES "public"."pull_requests"("id") ON UPDATE CASCADE ON DELETE RESTRICT; -ALTER TABLE ONLY "public"."project_repository_mapping" - ADD CONSTRAINT "project_repository_mapping_project_id_fkey" FOREIGN KEY ("project_id") REFERENCES "public"."project"("id") ON UPDATE CASCADE ON DELETE RESTRICT; +ALTER TABLE ONLY "public"."project_repository_mappings" + ADD CONSTRAINT "project_repository_mapping_project_id_fkey" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON UPDATE CASCADE ON DELETE RESTRICT; -ALTER TABLE ONLY "public"."project_repository_mapping" - ADD CONSTRAINT "project_repository_mapping_repository_id_fkey" FOREIGN KEY ("repository_id") REFERENCES "public"."repository"("id") ON UPDATE CASCADE ON DELETE RESTRICT; +ALTER TABLE ONLY "public"."project_repository_mappings" + ADD CONSTRAINT "project_repository_mapping_repository_id_fkey" FOREIGN KEY ("repository_id") REFERENCES "public"."repositories"("id") ON UPDATE CASCADE ON DELETE RESTRICT; -ALTER TABLE ONLY "public"."project" - ADD CONSTRAINT "project_organization_id_fkey" FOREIGN KEY ("organization_id") REFERENCES "public"."organization"("id") ON UPDATE CASCADE ON DELETE CASCADE; +ALTER TABLE ONLY "public"."projects" + ADD CONSTRAINT "project_organization_id_fkey" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON UPDATE CASCADE ON DELETE CASCADE; -ALTER TABLE ONLY "public"."pull_request" - ADD CONSTRAINT "pull_request_repository_id_fkey" FOREIGN KEY ("repository_id") REFERENCES "public"."repository"("id") ON UPDATE CASCADE ON DELETE RESTRICT; +ALTER TABLE ONLY "public"."pull_requests" + ADD CONSTRAINT "pull_request_repository_id_fkey" FOREIGN KEY ("repository_id") REFERENCES "public"."repositories"("id") ON UPDATE CASCADE ON DELETE RESTRICT; -ALTER TABLE ONLY "public"."review_feedback_comment" - ADD CONSTRAINT "review_feedback_comment_review_feedback_id_fkey" FOREIGN KEY ("review_feedback_id") REFERENCES "public"."review_feedback"("id") ON UPDATE CASCADE ON DELETE CASCADE; +ALTER TABLE ONLY "public"."review_feedback_comments" + ADD CONSTRAINT "review_feedback_comment_review_feedback_id_fkey" FOREIGN KEY ("review_feedback_id") REFERENCES "public"."review_feedbacks"("id") ON UPDATE CASCADE ON DELETE CASCADE; -ALTER TABLE ONLY "public"."review_feedback_comment" - ADD CONSTRAINT "review_feedback_comment_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON UPDATE CASCADE ON DELETE CASCADE; +ALTER TABLE ONLY "public"."review_feedback_comments" + ADD CONSTRAINT "review_feedback_comment_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON UPDATE CASCADE ON DELETE CASCADE; -ALTER TABLE ONLY "public"."review_feedback" - ADD CONSTRAINT "review_feedback_overall_review_id_fkey" FOREIGN KEY ("overall_review_id") REFERENCES "public"."overall_review"("id") ON UPDATE CASCADE ON DELETE RESTRICT; +ALTER TABLE ONLY "public"."review_feedbacks" + ADD CONSTRAINT "review_feedback_overall_review_id_fkey" FOREIGN KEY ("overall_review_id") REFERENCES "public"."overall_reviews"("id") ON UPDATE CASCADE ON DELETE RESTRICT; -ALTER TABLE ONLY "public"."review_suggestion_snippet" - ADD CONSTRAINT "review_suggestion_snippet_review_feedback_id_fkey" FOREIGN KEY ("review_feedback_id") REFERENCES "public"."review_feedback"("id") ON UPDATE CASCADE ON DELETE CASCADE; +ALTER TABLE ONLY "public"."review_suggestion_snippets" + ADD CONSTRAINT "review_suggestion_snippet_review_feedback_id_fkey" FOREIGN KEY ("review_feedback_id") REFERENCES "public"."review_feedbacks"("id") ON UPDATE CASCADE ON DELETE CASCADE; -ALTER TABLE "public"."project" ENABLE ROW LEVEL SECURITY; +ALTER TABLE "public"."projects" ENABLE ROW LEVEL SECURITY; -CREATE POLICY "authenticated_users_can_delete_org_projects" ON "public"."project" FOR DELETE TO "authenticated" USING (("organization_id" IN ( SELECT "organization_member"."organization_id" - FROM "public"."organization_member" - WHERE ("organization_member"."user_id" = "auth"."uid"())))); +CREATE POLICY "authenticated_users_can_delete_org_projects" ON "public"."projects" FOR DELETE TO "authenticated" USING (("organization_id" IN ( SELECT "organization_members"."organization_id" + FROM "public"."organization_members" + WHERE ("organization_members"."user_id" = "auth"."uid"())))); -COMMENT ON POLICY "authenticated_users_can_delete_org_projects" ON "public"."project" IS 'Authenticated users can only delete projects in organizations they are members of'; +COMMENT ON POLICY "authenticated_users_can_delete_org_projects" ON "public"."projects" IS 'Authenticated users can only delete projects in organizations they are members of'; -CREATE POLICY "authenticated_users_can_insert_projects" ON "public"."project" FOR INSERT TO "authenticated" WITH CHECK (("organization_id" IN ( SELECT "organization_member"."organization_id" - FROM "public"."organization_member" - WHERE ("organization_member"."user_id" = "auth"."uid"())))); +CREATE POLICY "authenticated_users_can_insert_projects" ON "public"."projects" FOR INSERT TO "authenticated" WITH CHECK (("organization_id" IN ( SELECT "organization_members"."organization_id" + FROM "public"."organization_members" + WHERE ("organization_members"."user_id" = "auth"."uid"())))); -COMMENT ON POLICY "authenticated_users_can_insert_projects" ON "public"."project" IS 'Authenticated users can create any project'; +COMMENT ON POLICY "authenticated_users_can_insert_projects" ON "public"."projects" IS 'Authenticated users can create any project'; -CREATE POLICY "authenticated_users_can_select_org_projects" ON "public"."project" FOR SELECT TO "authenticated" USING (("organization_id" IN ( SELECT "organization_member"."organization_id" - FROM "public"."organization_member" - WHERE ("organization_member"."user_id" = "auth"."uid"())))); +CREATE POLICY "authenticated_users_can_select_org_projects" ON "public"."projects" FOR SELECT TO "authenticated" USING (("organization_id" IN ( SELECT "organization_members"."organization_id" + FROM "public"."organization_members" + WHERE ("organization_members"."user_id" = "auth"."uid"())))); -COMMENT ON POLICY "authenticated_users_can_select_org_projects" ON "public"."project" IS 'Authenticated users can only view projects belonging to organizations they are members of'; +COMMENT ON POLICY "authenticated_users_can_select_org_projects" ON "public"."projects" IS 'Authenticated users can only view projects belonging to organizations they are members of'; -CREATE POLICY "authenticated_users_can_update_org_projects" ON "public"."project" FOR UPDATE TO "authenticated" USING (("organization_id" IN ( SELECT "organization_member"."organization_id" - FROM "public"."organization_member" - WHERE ("organization_member"."user_id" = "auth"."uid"())))) WITH CHECK (("organization_id" IN ( SELECT "organization_member"."organization_id" - FROM "public"."organization_member" - WHERE ("organization_member"."user_id" = "auth"."uid"())))); +CREATE POLICY "authenticated_users_can_update_org_projects" ON "public"."projects" FOR UPDATE TO "authenticated" USING (("organization_id" IN ( SELECT "organization_members"."organization_id" + FROM "public"."organization_members" + WHERE ("organization_members"."user_id" = "auth"."uid"())))) WITH CHECK (("organization_id" IN ( SELECT "organization_members"."organization_id" + FROM "public"."organization_members" + WHERE ("organization_members"."user_id" = "auth"."uid"())))); -COMMENT ON POLICY "authenticated_users_can_update_org_projects" ON "public"."project" IS 'Authenticated users can only update projects in organizations they are members of'; +COMMENT ON POLICY "authenticated_users_can_update_org_projects" ON "public"."projects" IS 'Authenticated users can only update projects in organizations they are members of'; -CREATE POLICY "service_role_can_delete_all_projects" ON "public"."project" FOR DELETE TO "service_role" USING (true); +CREATE POLICY "service_role_can_delete_all_projects" ON "public"."projects" FOR DELETE TO "service_role" USING (true); -COMMENT ON POLICY "service_role_can_delete_all_projects" ON "public"."project" IS 'Service role can delete any project (for jobs)'; +COMMENT ON POLICY "service_role_can_delete_all_projects" ON "public"."projects" IS 'Service role can delete any project (for jobs)'; -CREATE POLICY "service_role_can_insert_all_projects" ON "public"."project" FOR INSERT TO "service_role" WITH CHECK (true); +CREATE POLICY "service_role_can_insert_all_projects" ON "public"."projects" FOR INSERT TO "service_role" WITH CHECK (true); -COMMENT ON POLICY "service_role_can_insert_all_projects" ON "public"."project" IS 'Service role can create any project (for jobs)'; +COMMENT ON POLICY "service_role_can_insert_all_projects" ON "public"."projects" IS 'Service role can create any project (for jobs)'; -CREATE POLICY "service_role_can_select_all_projects" ON "public"."project" FOR SELECT TO "service_role" USING (true); +CREATE POLICY "service_role_can_select_all_projects" ON "public"."projects" FOR SELECT TO "service_role" USING (true); -COMMENT ON POLICY "service_role_can_select_all_projects" ON "public"."project" IS 'Service role can view all projects (for jobs)'; +COMMENT ON POLICY "service_role_can_select_all_projects" ON "public"."projects" IS 'Service role can view all projects (for jobs)'; -CREATE POLICY "service_role_can_update_all_projects" ON "public"."project" FOR UPDATE TO "service_role" USING (true) WITH CHECK (true); +CREATE POLICY "service_role_can_update_all_projects" ON "public"."projects" FOR UPDATE TO "service_role" USING (true) WITH CHECK (true); -COMMENT ON POLICY "service_role_can_update_all_projects" ON "public"."project" IS 'Service role can update any project (for jobs)'; +COMMENT ON POLICY "service_role_can_update_all_projects" ON "public"."projects" IS 'Service role can update any project (for jobs)'; @@ -1075,33 +1075,33 @@ GRANT ALL ON FUNCTION "public"."sync_existing_users"() TO "service_role"; -GRANT ALL ON TABLE "public"."github_doc_file_path" TO "anon"; -GRANT ALL ON TABLE "public"."github_doc_file_path" TO "authenticated"; -GRANT ALL ON TABLE "public"."github_doc_file_path" TO "service_role"; +GRANT ALL ON TABLE "public"."github_doc_file_paths" TO "anon"; +GRANT ALL ON TABLE "public"."github_doc_file_paths" TO "authenticated"; +GRANT ALL ON TABLE "public"."github_doc_file_paths" TO "service_role"; -GRANT ALL ON TABLE "public"."github_schema_file_path" TO "anon"; -GRANT ALL ON TABLE "public"."github_schema_file_path" TO "authenticated"; -GRANT ALL ON TABLE "public"."github_schema_file_path" TO "service_role"; +GRANT ALL ON TABLE "public"."github_schema_file_paths" TO "anon"; +GRANT ALL ON TABLE "public"."github_schema_file_paths" TO "authenticated"; +GRANT ALL ON TABLE "public"."github_schema_file_paths" TO "service_role"; -GRANT ALL ON TABLE "public"."knowledge_suggestion" TO "anon"; -GRANT ALL ON TABLE "public"."knowledge_suggestion" TO "authenticated"; -GRANT ALL ON TABLE "public"."knowledge_suggestion" TO "service_role"; +GRANT ALL ON TABLE "public"."knowledge_suggestions" TO "anon"; +GRANT ALL ON TABLE "public"."knowledge_suggestions" TO "authenticated"; +GRANT ALL ON TABLE "public"."knowledge_suggestions" TO "service_role"; -GRANT ALL ON TABLE "public"."knowledge_suggestion_doc_mapping" TO "anon"; -GRANT ALL ON TABLE "public"."knowledge_suggestion_doc_mapping" TO "authenticated"; -GRANT ALL ON TABLE "public"."knowledge_suggestion_doc_mapping" TO "service_role"; +GRANT ALL ON TABLE "public"."knowledge_suggestion_doc_mappings" TO "anon"; +GRANT ALL ON TABLE "public"."knowledge_suggestion_doc_mappings" TO "authenticated"; +GRANT ALL ON TABLE "public"."knowledge_suggestion_doc_mappings" TO "service_role"; @@ -1120,24 +1120,24 @@ GRANT ALL ON TABLE "public"."membership_invites" TO "service_role"; -GRANT ALL ON TABLE "public"."migration" TO "anon"; -GRANT ALL ON TABLE "public"."migration" TO "authenticated"; -GRANT ALL ON TABLE "public"."migration" TO "service_role"; +GRANT ALL ON TABLE "public"."migrations" TO "anon"; +GRANT ALL ON TABLE "public"."migrations" TO "authenticated"; +GRANT ALL ON TABLE "public"."migrations" TO "service_role"; -GRANT ALL ON TABLE "public"."organization" TO "anon"; -GRANT ALL ON TABLE "public"."organization" TO "authenticated"; -GRANT ALL ON TABLE "public"."organization" TO "service_role"; +GRANT ALL ON TABLE "public"."organizations" TO "anon"; +GRANT ALL ON TABLE "public"."organizations" TO "authenticated"; +GRANT ALL ON TABLE "public"."organizations" TO "service_role"; -GRANT ALL ON TABLE "public"."organization_member" TO "anon"; -GRANT ALL ON TABLE "public"."organization_member" TO "authenticated"; -GRANT ALL ON TABLE "public"."organization_member" TO "service_role"; +GRANT ALL ON TABLE "public"."organization_members" TO "anon"; +GRANT ALL ON TABLE "public"."organization_members" TO "authenticated"; +GRANT ALL ON TABLE "public"."organization_members" TO "service_role"; @@ -1147,15 +1147,15 @@ GRANT ALL ON TABLE "public"."organization_member" TO "service_role"; -GRANT ALL ON TABLE "public"."overall_review" TO "anon"; -GRANT ALL ON TABLE "public"."overall_review" TO "authenticated"; -GRANT ALL ON TABLE "public"."overall_review" TO "service_role"; +GRANT ALL ON TABLE "public"."overall_reviews" TO "anon"; +GRANT ALL ON TABLE "public"."overall_reviews" TO "authenticated"; +GRANT ALL ON TABLE "public"."overall_reviews" TO "service_role"; -GRANT ALL ON TABLE "public"."overall_review_knowledge_suggestion_mapping" TO "anon"; -GRANT ALL ON TABLE "public"."overall_review_knowledge_suggestion_mapping" TO "authenticated"; -GRANT ALL ON TABLE "public"."overall_review_knowledge_suggestion_mapping" TO "service_role"; +GRANT ALL ON TABLE "public"."overall_review_knowledge_suggestion_mappings" TO "anon"; +GRANT ALL ON TABLE "public"."overall_review_knowledge_suggestion_mappings" TO "authenticated"; +GRANT ALL ON TABLE "public"."overall_review_knowledge_suggestion_mappings" TO "service_role"; @@ -1165,15 +1165,15 @@ GRANT ALL ON TABLE "public"."overall_review_knowledge_suggestion_mapping" TO "se -GRANT ALL ON TABLE "public"."project" TO "anon"; -GRANT ALL ON TABLE "public"."project" TO "authenticated"; -GRANT ALL ON TABLE "public"."project" TO "service_role"; +GRANT ALL ON TABLE "public"."projects" TO "anon"; +GRANT ALL ON TABLE "public"."projects" TO "authenticated"; +GRANT ALL ON TABLE "public"."projects" TO "service_role"; -GRANT ALL ON TABLE "public"."project_repository_mapping" TO "anon"; -GRANT ALL ON TABLE "public"."project_repository_mapping" TO "authenticated"; -GRANT ALL ON TABLE "public"."project_repository_mapping" TO "service_role"; +GRANT ALL ON TABLE "public"."project_repository_mappings" TO "anon"; +GRANT ALL ON TABLE "public"."project_repository_mappings" TO "authenticated"; +GRANT ALL ON TABLE "public"."project_repository_mappings" TO "service_role"; @@ -1183,36 +1183,36 @@ GRANT ALL ON TABLE "public"."project_repository_mapping" TO "service_role"; -GRANT ALL ON TABLE "public"."pull_request" TO "anon"; -GRANT ALL ON TABLE "public"."pull_request" TO "authenticated"; -GRANT ALL ON TABLE "public"."pull_request" TO "service_role"; +GRANT ALL ON TABLE "public"."pull_requests" TO "anon"; +GRANT ALL ON TABLE "public"."pull_requests" TO "authenticated"; +GRANT ALL ON TABLE "public"."pull_requests" TO "service_role"; -GRANT ALL ON TABLE "public"."repository" TO "anon"; -GRANT ALL ON TABLE "public"."repository" TO "authenticated"; -GRANT ALL ON TABLE "public"."repository" TO "service_role"; +GRANT ALL ON TABLE "public"."repositories" TO "anon"; +GRANT ALL ON TABLE "public"."repositories" TO "authenticated"; +GRANT ALL ON TABLE "public"."repositories" TO "service_role"; -GRANT ALL ON TABLE "public"."review_feedback" TO "anon"; -GRANT ALL ON TABLE "public"."review_feedback" TO "authenticated"; -GRANT ALL ON TABLE "public"."review_feedback" TO "service_role"; +GRANT ALL ON TABLE "public"."review_feedbacks" TO "anon"; +GRANT ALL ON TABLE "public"."review_feedbacks" TO "authenticated"; +GRANT ALL ON TABLE "public"."review_feedbacks" TO "service_role"; -GRANT ALL ON TABLE "public"."review_feedback_comment" TO "anon"; -GRANT ALL ON TABLE "public"."review_feedback_comment" TO "authenticated"; -GRANT ALL ON TABLE "public"."review_feedback_comment" TO "service_role"; +GRANT ALL ON TABLE "public"."review_feedback_comments" TO "anon"; +GRANT ALL ON TABLE "public"."review_feedback_comments" TO "authenticated"; +GRANT ALL ON TABLE "public"."review_feedback_comments" TO "service_role"; @@ -1222,15 +1222,15 @@ GRANT ALL ON TABLE "public"."review_feedback_comment" TO "service_role"; -GRANT ALL ON TABLE "public"."review_suggestion_snippet" TO "anon"; -GRANT ALL ON TABLE "public"."review_suggestion_snippet" TO "authenticated"; -GRANT ALL ON TABLE "public"."review_suggestion_snippet" TO "service_role"; +GRANT ALL ON TABLE "public"."review_suggestion_snippets" TO "anon"; +GRANT ALL ON TABLE "public"."review_suggestion_snippets" TO "authenticated"; +GRANT ALL ON TABLE "public"."review_suggestion_snippets" TO "service_role"; -GRANT ALL ON TABLE "public"."user" TO "anon"; -GRANT ALL ON TABLE "public"."user" TO "authenticated"; -GRANT ALL ON TABLE "public"."user" TO "service_role"; +GRANT ALL ON TABLE "public"."users" TO "anon"; +GRANT ALL ON TABLE "public"."users" TO "authenticated"; +GRANT ALL ON TABLE "public"."users" TO "service_role"; @@ -1245,55 +1245,16 @@ ALTER DEFAULT PRIVILEGES FOR ROLE "postgres" IN SCHEMA "public" GRANT ALL ON SEQ ALTER DEFAULT PRIVILEGES FOR ROLE "postgres" IN SCHEMA "public" GRANT ALL ON SEQUENCES TO "authenticated"; ALTER DEFAULT PRIVILEGES FOR ROLE "postgres" IN SCHEMA "public" GRANT ALL ON SEQUENCES TO "service_role"; - - - - - ALTER DEFAULT PRIVILEGES FOR ROLE "postgres" IN SCHEMA "public" GRANT ALL ON FUNCTIONS TO "postgres"; ALTER DEFAULT PRIVILEGES FOR ROLE "postgres" IN SCHEMA "public" GRANT ALL ON FUNCTIONS TO "anon"; ALTER DEFAULT PRIVILEGES FOR ROLE "postgres" IN SCHEMA "public" GRANT ALL ON FUNCTIONS TO "authenticated"; ALTER DEFAULT PRIVILEGES FOR ROLE "postgres" IN SCHEMA "public" GRANT ALL ON FUNCTIONS TO "service_role"; - - - - - ALTER DEFAULT PRIVILEGES FOR ROLE "postgres" IN SCHEMA "public" GRANT ALL ON TABLES TO "postgres"; ALTER DEFAULT PRIVILEGES FOR ROLE "postgres" IN SCHEMA "public" GRANT ALL ON TABLES TO "anon"; ALTER DEFAULT PRIVILEGES FOR ROLE "postgres" IN SCHEMA "public" GRANT ALL ON TABLES TO "authenticated"; ALTER DEFAULT PRIVILEGES FOR ROLE "postgres" IN SCHEMA "public" GRANT ALL ON TABLES TO "service_role"; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - RESET ALL; -- From 93988de61f7a049cb0d3cc6cfdae2675bab323e8 Mon Sep 17 00:00:00 2001 From: hoshinotsuyoshi Date: Thu, 17 Apr 2025 14:17:52 +0900 Subject: [PATCH 3/9] Apply new table and column naming conventions across the app MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit updates the codebase and schema overrides to reflect the new naming standard: - Table names are converted to snake_case and pluralized (e.g., `Repository` → `repositories`) - Column names are converted to snake_case (e.g., `installationId` → `installation_id`) - Related Supabase queries, type references, and object property access are adjusted accordingly - `.liam/schema-override.yml` is aligned with the updated naming strategy --- .liam/schema-override.yml | 38 +++--- .../[organizationId]/projects/new/page.tsx | 2 +- .../[organizationId]/projects/page.tsx | 2 +- frontend/apps/app/app/(app)/app/page.tsx | 8 +- .../[branchOrCommit]/docs/DocsListPage.tsx | 2 +- .../[...docFilePath]/getDocumentContent.ts | 2 +- .../getProjectRepository.test.ts | 20 +-- .../[...docFilePath]/getProjectRepository.ts | 16 +-- .../docs/getGitHubDocFilePaths.test.ts | 16 +-- .../docs/getGitHubDocFilePaths.ts | 4 +- .../apps/app/app/api/projects/search/route.ts | 6 +- .../apps/app/app/api/schema/override/route.ts | 16 +-- .../apps/app/app/api/webhook/github/route.ts | 10 +- .../__tests__/checkSchemaChanges.test.ts | 14 +-- .../github/utils/checkSchemaChanges.ts | 4 +- .../apps/app/components/AppBar/AppBar.tsx | 2 +- .../components/CommonLayout/ClientAppBar.tsx | 2 +- .../actions/resolveReviewFeedback.ts | 8 +- .../migrations/actions/resolveReviewIssue.ts | 8 +- .../actions/reviewFeedbackComments.ts | 20 +-- .../CommentList/CommentList.tsx | 2 +- .../ReviewFeedbackList/ReviewFeedbackList.tsx | 26 ++-- .../contexts/ReviewFeedbackContext.tsx | 4 +- .../MigrationDetailPage.tsx | 118 +++++++++--------- .../migrations/utils/formatReviewFeedback.ts | 8 +- .../OrganizationDetailPage.tsx | 12 +- .../getOrganizationDetails.ts | 14 +-- .../OrganizationNewPage.tsx | 8 +- .../OrganizationsPage/getOrganizations.ts | 8 +- .../features/projects/actions/addProject.ts | 24 ++-- .../actions/approveKnowledgeSuggestion.ts | 42 +++---- .../updateKnowledgeSuggestionContent.ts | 2 +- .../components/ProjectItem/ProjectItem.tsx | 4 +- .../projects/hooks/useProjectSearch.ts | 4 +- .../BranchDetailPage/BranchDetailPage.tsx | 16 +-- .../ContentForDoc.tsx | 2 +- .../ContentForSchema.tsx | 15 +-- .../KnowledgeSuggestionDetailPage.tsx | 35 +++--- .../KnowledgeSuggestionsListPage.tsx | 18 +-- .../ProjectBranchesListPage.tsx | 14 +-- .../pages/ProjectDetailPage/getProject.ts | 38 +++--- .../ProjectsPage/ClientSearchWrapper.tsx | 2 +- .../ProjectsPage/getCurrentOrganization.ts | 18 +-- .../pages/ProjectsPage/getProjects.test.ts | 6 +- .../pages/ProjectsPage/getProjects.ts | 6 +- .../utils/getOriginalDocumentContent.ts | 2 +- .../schemas/pages/SchemaPage/SchemaPage.tsx | 18 +-- .../getInstallationIdFromRepositoryId.ts | 6 +- .../processCreateKnowledgeSuggestion.ts | 46 +++---- .../processGenerateDocsSuggestion.ts | 14 +-- .../processGenerateSchemaOverride.ts | 40 +++--- .../review/__tests__/postComment.test.ts | 64 +++++----- .../__tests__/processSaveReview.test.ts | 56 ++++----- .../jobs/src/tasks/review/generateReview.ts | 14 +-- .../jobs/src/tasks/review/postComment.ts | 30 ++--- .../jobs/src/tasks/review/savePullRequest.ts | 50 ++++---- .../jobs/src/tasks/review/saveReview.ts | 41 +++--- .../jobs/src/utils/githubFileUtils.ts | 2 +- 58 files changed, 524 insertions(+), 505 deletions(-) diff --git a/.liam/schema-override.yml b/.liam/schema-override.yml index ae2f19fd78..9dd3eb19ef 100644 --- a/.liam/schema-override.yml +++ b/.liam/schema-override.yml @@ -1,27 +1,27 @@ overrides: tableGroups: - Github: - name: Github + GitHub: + name: GitHub tables: - - Repository - - PullRequest - - GitHubSchemaFilePath - - GitHubDocFilePath - comment: "Tables related to Github. All tables in this group should have a GitHub prefix. External tables must not depend on these tables (e.g., no pullRequestId foreign keys in tables outside this group)." + - repositories + - pull_requests + - github_schema_file_paths + - github_doc_file_paths + comment: "Tables related to GitHub. All tables in this group should have a GitHub prefix. External tables must not depend on these tables (e.g., no pullRequestId foreign keys in tables outside this group)." Organization: name: Organization tables: - - MembershipInvites - - Organization - - OrganizationMember - - User + - membership_invites + - organizations + - organization_members + - users comment: "" tables: - Repository: - comment: "TODO: Rename to GitHubRepository to match the GitHub prefix pattern of this table group" - PullRequest: - comment: "TODO: Rename to GitHubPullRequest to match the GitHub prefix pattern of this table group. Should be updated to have migrationId instead of Migration having pullRequestId." - Migration: - comment: "Should have projectId instead of pullRequestId to remove GitHub dependency" - OverallReview: - comment: "Should have migrationId instead of pullRequestId to remove GitHub dependency" + repositories: + comment: "TODO: Rename to github_repositories to match the github_ prefix pattern of this table group" + pull_requests: + comment: "TODO: Rename to github_pull_requests to match the github_ prefix pattern of this table group. Should be updated to have migration_id instead of migrations having pull_request_id." + migrations: + comment: "Should have project_id instead of pull_request_id to remove GitHub dependency" + overall_reviews: + comment: "Should have migration_id instead of pull_request_id to remove GitHub dependency" diff --git a/frontend/apps/app/app/(app)/app/organizations/[organizationId]/projects/new/page.tsx b/frontend/apps/app/app/(app)/app/organizations/[organizationId]/projects/new/page.tsx index 829da96c9b..99dd8b1867 100644 --- a/frontend/apps/app/app/(app)/app/organizations/[organizationId]/projects/new/page.tsx +++ b/frontend/apps/app/app/(app)/app/organizations/[organizationId]/projects/new/page.tsx @@ -22,7 +22,7 @@ export default async function NewProjectPage({ params }: PageProps) { } const { data: organizationMembers, error: orgError } = await supabase - .from('OrganizationMember') + .from('organization_members') .select('id') .eq('userId', data.session.user.id) .eq('organizationId', organizationId) diff --git a/frontend/apps/app/app/(app)/app/organizations/[organizationId]/projects/page.tsx b/frontend/apps/app/app/(app)/app/organizations/[organizationId]/projects/page.tsx index fc384847f4..f41fc9cdcb 100644 --- a/frontend/apps/app/app/(app)/app/organizations/[organizationId]/projects/page.tsx +++ b/frontend/apps/app/app/(app)/app/organizations/[organizationId]/projects/page.tsx @@ -28,7 +28,7 @@ export default async function Page({ params }: PageProps) { } const { data: organizationMembers, error: orgError } = await supabase - .from('OrganizationMember') + .from('organization_members') .select('id') .eq('userId', data.session.user.id) .eq('organizationId', organizationId) diff --git a/frontend/apps/app/app/(app)/app/page.tsx b/frontend/apps/app/app/(app)/app/page.tsx index 860bf662bf..8eeac5fa04 100644 --- a/frontend/apps/app/app/(app)/app/page.tsx +++ b/frontend/apps/app/app/(app)/app/page.tsx @@ -11,8 +11,8 @@ export default async function Page() { } const { data: organizationMembers, error: orgError } = await supabase - .from('OrganizationMember') - .select('organizationId') + .from('organization_members') + .select('organization_id') .eq('userId', data.user.id) .limit(1) @@ -24,10 +24,10 @@ export default async function Page() { redirect(urlgen('organizations/new')) } - const organizationId = organizationMembers[0].organizationId + const organizationId = organizationMembers[0].organization_id const { data: projects, error: projectsError } = await supabase - .from('Project') + .from('projects') .select('id') .eq('organizationId', organizationId) .limit(1) diff --git a/frontend/apps/app/app/(app)/app/projects/[projectId]/ref/[branchOrCommit]/docs/DocsListPage.tsx b/frontend/apps/app/app/(app)/app/projects/[projectId]/ref/[branchOrCommit]/docs/DocsListPage.tsx index e996fc9181..2b658b9f02 100644 --- a/frontend/apps/app/app/(app)/app/projects/[projectId]/ref/[branchOrCommit]/docs/DocsListPage.tsx +++ b/frontend/apps/app/app/(app)/app/projects/[projectId]/ref/[branchOrCommit]/docs/DocsListPage.tsx @@ -40,7 +40,7 @@ export const DocsListPage = async ({ > {docFilePath.path} - {!docFilePath.isReviewEnabled && (Review disabled)} + {!docFilePath.is_review_enabled && (Review disabled)} ))} diff --git a/frontend/apps/app/app/(app)/app/projects/[projectId]/ref/[branchOrCommit]/docs/[...docFilePath]/getDocumentContent.ts b/frontend/apps/app/app/(app)/app/projects/[projectId]/ref/[branchOrCommit]/docs/[...docFilePath]/getDocumentContent.ts index 0c9cc79fbb..7f40ac1716 100644 --- a/frontend/apps/app/app/(app)/app/projects/[projectId]/ref/[branchOrCommit]/docs/[...docFilePath]/getDocumentContent.ts +++ b/frontend/apps/app/app/(app)/app/projects/[projectId]/ref/[branchOrCommit]/docs/[...docFilePath]/getDocumentContent.ts @@ -27,7 +27,7 @@ export const getDocumentContent = async ({ repositoryFullName, filePath, branchOrCommit, - repository.installationId, + repository.installation_id, ) return fileData.content diff --git a/frontend/apps/app/app/(app)/app/projects/[projectId]/ref/[branchOrCommit]/docs/[...docFilePath]/getProjectRepository.test.ts b/frontend/apps/app/app/(app)/app/projects/[projectId]/ref/[branchOrCommit]/docs/[...docFilePath]/getProjectRepository.test.ts index 4f04ba6eb0..d84f5b7625 100644 --- a/frontend/apps/app/app/(app)/app/projects/[projectId]/ref/[branchOrCommit]/docs/[...docFilePath]/getProjectRepository.test.ts +++ b/frontend/apps/app/app/(app)/app/projects/[projectId]/ref/[branchOrCommit]/docs/[...docFilePath]/getProjectRepository.test.ts @@ -8,22 +8,22 @@ describe('getProjectRepository', () => { // Create test repository const { data: repository } = await supabase - .from('Repository') + .from('repositories') .insert({ name: 'test-repo', owner: 'test-owner', - installationId: 12345, - updatedAt: new Date().toISOString(), + installation_id: 12345, + updated_at: new Date().toISOString(), }) .select() .single() // Create test project const { data: project } = await supabase - .from('Project') + .from('projects') .insert({ name: 'Test Project', - updatedAt: new Date().toISOString(), + updated_at: new Date().toISOString(), }) .select() .single() @@ -37,10 +37,10 @@ describe('getProjectRepository', () => { } // Create mapping between project and repository - await supabase.from('ProjectRepositoryMapping').insert({ - projectId: project.id, - repositoryId: repository.id, - updatedAt: new Date().toISOString(), + await supabase.from('project_repository_mappings').insert({ + project_id: project.id, + repository_id: repository.id, + updated_at: new Date().toISOString(), }) const result = await getProjectRepository(project.id.toString()) @@ -48,7 +48,7 @@ describe('getProjectRepository', () => { expect(result).not.toBeNull() expect(result?.repository).toHaveProperty('name', 'test-repo') expect(result?.repository).toHaveProperty('owner', 'test-owner') - expect(result?.repository).toHaveProperty('installationId', '12345') + expect(result?.repository).toHaveProperty('installation_id', '12345') }) it('should return null when project does not exist', async () => { diff --git a/frontend/apps/app/app/(app)/app/projects/[projectId]/ref/[branchOrCommit]/docs/[...docFilePath]/getProjectRepository.ts b/frontend/apps/app/app/(app)/app/projects/[projectId]/ref/[branchOrCommit]/docs/[...docFilePath]/getProjectRepository.ts index ef21b1dc49..e7ec701834 100644 --- a/frontend/apps/app/app/(app)/app/projects/[projectId]/ref/[branchOrCommit]/docs/[...docFilePath]/getProjectRepository.ts +++ b/frontend/apps/app/app/(app)/app/projects/[projectId]/ref/[branchOrCommit]/docs/[...docFilePath]/getProjectRepository.ts @@ -4,7 +4,7 @@ export interface ProjectRepository { repository: { name: string owner: string - installationId: number + installation_id: number } } @@ -14,13 +14,13 @@ export const getProjectRepository = async ( try { const supabase = await createClient() const { data: project, error } = await supabase - .from('Project') + .from('projects') .select(` *, - ProjectRepositoryMapping:ProjectRepositoryMapping( + project_repository_mappings( *, - Repository:Repository( - name, owner, installationId + repositories( + name, owner, installation_id ) ) `) @@ -31,8 +31,8 @@ export const getProjectRepository = async ( return null } - const repository = project?.ProjectRepositoryMapping[0]?.Repository - if (!repository?.installationId || !repository.owner || !repository.name) { + const repository = project?.project_repository_mappings[0]?.repositories + if (!repository?.installation_id || !repository.owner || !repository.name) { console.error('Repository information not found') return null } @@ -41,7 +41,7 @@ export const getProjectRepository = async ( repository: { name: repository.name, owner: repository.owner, - installationId: repository.installationId, + installation_id: repository.installation_id, }, } } catch (error) { diff --git a/frontend/apps/app/app/(app)/app/projects/[projectId]/ref/[branchOrCommit]/docs/getGitHubDocFilePaths.test.ts b/frontend/apps/app/app/(app)/app/projects/[projectId]/ref/[branchOrCommit]/docs/getGitHubDocFilePaths.test.ts index 7c42f73183..ca3bca7b62 100644 --- a/frontend/apps/app/app/(app)/app/projects/[projectId]/ref/[branchOrCommit]/docs/getGitHubDocFilePaths.test.ts +++ b/frontend/apps/app/app/(app)/app/projects/[projectId]/ref/[branchOrCommit]/docs/getGitHubDocFilePaths.test.ts @@ -8,10 +8,10 @@ describe('getGitHubDocFilePaths', () => { // Create test project const { data: project } = await supabase - .from('Project') + .from('projects') .insert({ name: 'Test Project', - updatedAt: new Date().toISOString(), + updated_at: new Date().toISOString(), }) .select() .single() @@ -25,12 +25,12 @@ describe('getGitHubDocFilePaths', () => { // Create test doc file path const { data: docFilePath } = await supabase - .from('GitHubDocFilePath') + .from('github_doc_file_paths') .insert({ path: 'test/path.md', - projectId: project.id, - isReviewEnabled: true, - updatedAt: new Date().toISOString(), + project_id: project.id, + is_review_enabled: true, + updated_at: new Date().toISOString(), }) .select() .single() @@ -42,8 +42,8 @@ describe('getGitHubDocFilePaths', () => { expect(paths).not.toBeNull() expect(paths.length).toBeGreaterThan(0) expect(paths[0]).toHaveProperty('path', 'test/path.md') - expect(paths[0]).toHaveProperty('isReviewEnabled', true) - expect(paths[0]).toHaveProperty('projectId', project.id) + expect(paths[0]).toHaveProperty('is_review_enabled', true) + expect(paths[0]).toHaveProperty('project_id', project.id) }) it('should return empty array when no paths exist', async () => { diff --git a/frontend/apps/app/app/(app)/app/projects/[projectId]/ref/[branchOrCommit]/docs/getGitHubDocFilePaths.ts b/frontend/apps/app/app/(app)/app/projects/[projectId]/ref/[branchOrCommit]/docs/getGitHubDocFilePaths.ts index 8efa026564..98d4206181 100644 --- a/frontend/apps/app/app/(app)/app/projects/[projectId]/ref/[branchOrCommit]/docs/getGitHubDocFilePaths.ts +++ b/frontend/apps/app/app/(app)/app/projects/[projectId]/ref/[branchOrCommit]/docs/getGitHubDocFilePaths.ts @@ -4,9 +4,9 @@ export const getGitHubDocFilePaths = async (projectId: string) => { try { const supabase = await createClient() const { data } = await supabase - .from('GitHubDocFilePath') + .from('github_doc_file_paths') .select('*') - .eq('projectId', projectId) + .eq('project_id', projectId) return data || [] } catch (error) { diff --git a/frontend/apps/app/app/api/projects/search/route.ts b/frontend/apps/app/app/api/projects/search/route.ts index f4053f3393..8c2c42501c 100644 --- a/frontend/apps/app/app/api/projects/search/route.ts +++ b/frontend/apps/app/app/api/projects/search/route.ts @@ -9,8 +9,8 @@ export async function GET(request: Request) { const supabase = await createClient() let dbQuery = supabase - .from('Project') - .select('id, name, createdAt, updatedAt, organizationId') + .from('projects') + .select('id, name, created_at, updated_at, organization_id') .order('id', { ascending: false }) if (query) { @@ -18,7 +18,7 @@ export async function GET(request: Request) { } if (organizationId) { - dbQuery = dbQuery.eq('organizationId', organizationId) + dbQuery = dbQuery.eq('organization_id', organizationId) } const { data: projects, error } = await dbQuery diff --git a/frontend/apps/app/app/api/schema/override/route.ts b/frontend/apps/app/app/api/schema/override/route.ts index e7a4ca4d94..8843f9d7eb 100644 --- a/frontend/apps/app/app/api/schema/override/route.ts +++ b/frontend/apps/app/app/api/schema/override/route.ts @@ -29,21 +29,21 @@ export async function POST(request: NextRequest) { const supabase = await createClient() const { data: project } = await supabase - .from('Project') + .from('projects') .select(` *, - ProjectRepositoryMapping:ProjectRepositoryMapping( + project_repository_mappings( *, - Repository:Repository( - name, owner, installationId + repositories( + name, owner, installation_id ) ) `) .eq('id', projectId) .single() - const repository = project?.ProjectRepositoryMapping[0].Repository - if (!repository?.installationId || !repository.owner || !repository.name) { + const repository = project?.project_repository_mappings[0].repositories + if (!repository?.installation_id || !repository.owner || !repository.name) { return NextResponse.json( { error: 'Repository information not found' }, { status: 404 }, @@ -55,7 +55,7 @@ export async function POST(request: NextRequest) { repositoryFullName, SCHEMA_OVERRIDE_FILE_PATH, branchOrCommit, - Number(repository.installationId), + Number(repository.installation_id), ) const rawSchemaOverride = content @@ -82,7 +82,7 @@ export async function POST(request: NextRequest) { SCHEMA_OVERRIDE_FILE_PATH, JSON.stringify(schemaOverride, null, 2), `Update ${SCHEMA_OVERRIDE_FILE_PATH}`, - Number(repository.installationId), + Number(repository.installation_id), branchOrCommit, sha || undefined, ) diff --git a/frontend/apps/app/app/api/webhook/github/route.ts b/frontend/apps/app/app/api/webhook/github/route.ts index 1680526fab..f7e74ae635 100644 --- a/frontend/apps/app/app/api/webhook/github/route.ts +++ b/frontend/apps/app/app/api/webhook/github/route.ts @@ -45,9 +45,9 @@ const getProjectInfo = async ( const supabase = await createClient() const { data: repository, error: repositoryError } = await supabase - .from('Repository') + .from('repositories') .select('*') - .eq('installationId', installationId) + .eq('installation_id', installationId) .limit(1) .single() @@ -56,9 +56,9 @@ const getProjectInfo = async ( } const { data: projectRepositoryMapping, error: mappingError } = await supabase - .from('ProjectRepositoryMapping') + .from('project_repository_mappings') .select('*') - .eq('repositoryId', repository.id) + .eq('repository_id', repository.id) .limit(1) .single() @@ -66,7 +66,7 @@ const getProjectInfo = async ( return null } - return { projectId: projectRepositoryMapping.projectId } + return { projectId: projectRepositoryMapping.project_id } } // Handle pull request events diff --git a/frontend/apps/app/app/api/webhook/github/utils/__tests__/checkSchemaChanges.test.ts b/frontend/apps/app/app/api/webhook/github/utils/__tests__/checkSchemaChanges.test.ts index 178645256b..ee84b45d3b 100644 --- a/frontend/apps/app/app/api/webhook/github/utils/__tests__/checkSchemaChanges.test.ts +++ b/frontend/apps/app/app/api/webhook/github/utils/__tests__/checkSchemaChanges.test.ts @@ -78,10 +78,10 @@ describe('checkSchemaChanges', () => { // Create a test project const now = new Date().toISOString() const { data: project, error: projectError } = await supabase - .from('Project') + .from('projects') .insert({ name: 'Test Project for Schema Changes Test', - updatedAt: now, + updated_at: now, }) .select() .single() @@ -94,12 +94,12 @@ describe('checkSchemaChanges', () => { try { // Create a test schema path for the project const { data: schemaPath, error: schemaPathError } = await supabase - .from('GitHubSchemaFilePath') + .from('github_schema_file_paths') .insert({ path: 'migrations/2024_update.sql', - projectId: project.id, + project_id: project.id, format: 'postgres', - updatedAt: now, + updated_at: now, }) .select() .single() @@ -143,12 +143,12 @@ describe('checkSchemaChanges', () => { // Clean up the schema path await supabase - .from('GitHubSchemaFilePath') + .from('github_schema_file_paths') .delete() .eq('id', schemaPath.id) } finally { // Clean up the project - await supabase.from('Project').delete().eq('id', project.id) + await supabase.from('projects').delete().eq('id', project.id) } }) }) diff --git a/frontend/apps/app/app/api/webhook/github/utils/checkSchemaChanges.ts b/frontend/apps/app/app/api/webhook/github/utils/checkSchemaChanges.ts index a8dd5f3d2d..66280b7de7 100644 --- a/frontend/apps/app/app/api/webhook/github/utils/checkSchemaChanges.ts +++ b/frontend/apps/app/app/api/webhook/github/utils/checkSchemaChanges.ts @@ -26,9 +26,9 @@ export const checkSchemaChanges = async ( const supabase = await createClient() const { data: schemaPath, error } = await supabase - .from('GitHubSchemaFilePath') + .from('github_schema_file_paths') .select('path') - .eq('projectId', projectId) + .eq('project_id', projectId) .single() if (error) { diff --git a/frontend/apps/app/components/AppBar/AppBar.tsx b/frontend/apps/app/components/AppBar/AppBar.tsx index 1e7945cfee..4aa5264b9d 100644 --- a/frontend/apps/app/components/AppBar/AppBar.tsx +++ b/frontend/apps/app/components/AppBar/AppBar.tsx @@ -16,7 +16,7 @@ type BreadcrumbItemProps = { } // Using the database type for Project -type Project = Tables<'Project'> +type Project = Tables<'projects'> type AppBarProps = { project?: Project diff --git a/frontend/apps/app/components/CommonLayout/ClientAppBar.tsx b/frontend/apps/app/components/CommonLayout/ClientAppBar.tsx index 76fab74724..7d18f621bf 100644 --- a/frontend/apps/app/components/CommonLayout/ClientAppBar.tsx +++ b/frontend/apps/app/components/CommonLayout/ClientAppBar.tsx @@ -5,7 +5,7 @@ import { usePathname } from 'next/navigation' import { useEffect, useState } from 'react' import { AppBar } from '../AppBar/AppBar' -type Project = Tables<'Project'> +type Project = Tables<'projects'> type ClientAppBarProps = { project?: Project | null diff --git a/frontend/apps/app/features/migrations/actions/resolveReviewFeedback.ts b/frontend/apps/app/features/migrations/actions/resolveReviewFeedback.ts index 6d09ee8603..589b1031d3 100644 --- a/frontend/apps/app/features/migrations/actions/resolveReviewFeedback.ts +++ b/frontend/apps/app/features/migrations/actions/resolveReviewFeedback.ts @@ -24,11 +24,11 @@ export const resolveReviewFeedback = async (data: { const supabase = await createClient() const { data: updatedFeedback, error } = await supabase - .from('ReviewFeedback') + .from('review_feedbacks') .update({ - resolvedAt: new Date().toISOString(), - resolutionComment: resolutionComment || null, - updatedAt: new Date().toISOString(), + resolved_at: new Date().toISOString(), + resolution_comment: resolutionComment || null, + updated_at: new Date().toISOString(), }) .eq('id', feedbackId) .select() diff --git a/frontend/apps/app/features/migrations/actions/resolveReviewIssue.ts b/frontend/apps/app/features/migrations/actions/resolveReviewIssue.ts index c923a53eac..f494fb37c4 100644 --- a/frontend/apps/app/features/migrations/actions/resolveReviewIssue.ts +++ b/frontend/apps/app/features/migrations/actions/resolveReviewIssue.ts @@ -24,11 +24,11 @@ export const resolveReviewFeedback = async (data: { const supabase = await createClient() const { data: updatedIssue, error } = await supabase - .from('ReviewFeedback') + .from('review_feedbacks') .update({ - resolvedAt: new Date().toISOString(), - resolutionComment: resolutionComment || null, - updatedAt: new Date().toISOString(), + resolved_at: new Date().toISOString(), + resolution_comment: resolutionComment || null, + updated_at: new Date().toISOString(), }) .eq('id', issueId) .select() diff --git a/frontend/apps/app/features/migrations/actions/reviewFeedbackComments.ts b/frontend/apps/app/features/migrations/actions/reviewFeedbackComments.ts index 872314677d..3f629f79bd 100644 --- a/frontend/apps/app/features/migrations/actions/reviewFeedbackComments.ts +++ b/frontend/apps/app/features/migrations/actions/reviewFeedbackComments.ts @@ -16,8 +16,8 @@ const getCommentsSchema = v.object({ }) // Type for a comment with user information -export type CommentWithUser = Tables<'ReviewFeedbackComment'> & { - user: Tables<'User'> +export type CommentWithUser = Tables<'review_feedback_comments'> & { + user: Tables<'users'> } /** @@ -47,12 +47,12 @@ export async function addReviewFeedbackComment(data: { try { // Insert the comment const { data: comment, error } = await supabase - .from('ReviewFeedbackComment') + .from('review_feedback_comments') .insert({ - reviewFeedbackId: feedbackId, - userId: userData.user.id, + review_feedback_id: feedbackId, + user_id: userData.user.id, content, - updatedAt: now, + updated_at: now, }) .select('*') .single() @@ -87,15 +87,15 @@ export async function getReviewFeedbackComments(data: { // Get comments with user information const { data: comments, error } = await supabase - .from('ReviewFeedbackComment') + .from('review_feedback_comments') .select(` *, - user:userId ( + users ( name ) `) - .eq('reviewFeedbackId', feedbackId) - .order('createdAt', { ascending: true }) + .eq('review_feedback_id', feedbackId) + .order('created_at', { ascending: true }) if (error) { throw new Error(`Failed to get comments: ${error.message}`) diff --git a/frontend/apps/app/features/migrations/components/ReviewFeedbackComments/CommentList/CommentList.tsx b/frontend/apps/app/features/migrations/components/ReviewFeedbackComments/CommentList/CommentList.tsx index 80c46c60b4..9cf17e1251 100644 --- a/frontend/apps/app/features/migrations/components/ReviewFeedbackComments/CommentList/CommentList.tsx +++ b/frontend/apps/app/features/migrations/components/ReviewFeedbackComments/CommentList/CommentList.tsx @@ -79,7 +79,7 @@ export const CommentList = ({ 👤 {comment.user.name}
- {new Date(comment.createdAt).toLocaleString('en-US', { + {new Date(comment.created_at).toLocaleString('en-US', { dateStyle: 'medium', timeStyle: 'short', hour12: false, diff --git a/frontend/apps/app/features/migrations/components/ReviewFeedbackList/ReviewFeedbackList.tsx b/frontend/apps/app/features/migrations/components/ReviewFeedbackList/ReviewFeedbackList.tsx index 2d96096a80..0e26b0c439 100644 --- a/frontend/apps/app/features/migrations/components/ReviewFeedbackList/ReviewFeedbackList.tsx +++ b/frontend/apps/app/features/migrations/components/ReviewFeedbackList/ReviewFeedbackList.tsx @@ -30,8 +30,8 @@ export const ReviewFeedbackList: React.FC = ({ // Update the feedback in the shared context for immediate UI update updateFeedback(feedbackId, { - resolvedAt: new Date().toISOString(), - resolutionComment: comment, + resolved_at: new Date().toISOString(), + resolution_comment: comment, }) } catch (err) { console.error('Error resolving feedback:', err) @@ -40,8 +40,8 @@ export const ReviewFeedbackList: React.FC = ({ const sortedFeedbacks = [...feedbacks].sort((a, b) => { // First sort by resolved status (unresolved first) - if (a.resolvedAt && !b.resolvedAt) return 1 - if (!a.resolvedAt && b.resolvedAt) return -1 + if (a.resolved_at && !b.resolved_at) return 1 + if (!a.resolved_at && b.resolved_at) return -1 // Then sort by severity const severityOrder = { @@ -64,7 +64,7 @@ export const ReviewFeedbackList: React.FC = ({ className={clsx( styles.reviewFeedback, styles[`severity${feedback.severity}`], - feedback.resolvedAt && styles.resolved, + feedback.resolved_at && styles.resolved, )} >
@@ -82,7 +82,7 @@ export const ReviewFeedbackList: React.FC = ({ description: feedback.description || '', suggestion: feedback.suggestion || '', snippets: - feedback.suggestionSnippets?.map( + feedback.review_suggestion_snippets?.map( (snippet: { filename: string; snippet: string }) => ({ filename: snippet.filename, snippet: snippet.snippet, @@ -93,8 +93,8 @@ export const ReviewFeedbackList: React.FC = ({ /> handleResolve(feedback.id, comment)} />
@@ -106,7 +106,7 @@ export const ReviewFeedbackList: React.FC = ({

{feedback.suggestion}

)} - {feedback.suggestionSnippets?.map( + {feedback.review_suggestion_snippets?.map( (snippet: { filename: string; snippet: string; id: string }) => (
@@ -119,24 +119,24 @@ export const ReviewFeedbackList: React.FC = ({
), )} - {feedback.resolvedAt && ( + {feedback.resolved_at && (
✓ Resolved on{' '} - {new Date(feedback.resolvedAt).toLocaleString('en-US', { + {new Date(feedback.resolved_at).toLocaleString('en-US', { dateStyle: 'medium', timeStyle: 'short', hour12: false, })} - {feedback.resolutionComment && ( + {feedback.resolution_comment && (

Resolution Comment:

- {feedback.resolutionComment} + {feedback.resolution_comment}

)} diff --git a/frontend/apps/app/features/migrations/contexts/ReviewFeedbackContext.tsx b/frontend/apps/app/features/migrations/contexts/ReviewFeedbackContext.tsx index 4e099268dd..f67783127b 100644 --- a/frontend/apps/app/features/migrations/contexts/ReviewFeedbackContext.tsx +++ b/frontend/apps/app/features/migrations/contexts/ReviewFeedbackContext.tsx @@ -9,8 +9,8 @@ import { useState, } from 'react' -type ReviewFeedback = Tables<'ReviewFeedback'> & { - suggestionSnippets: Array<{ +type ReviewFeedback = Tables<'review_feedbacks'> & { + review_suggestion_snippets: Array<{ id: string filename: string snippet: string diff --git a/frontend/apps/app/features/migrations/pages/MigrationDetailPage/MigrationDetailPage.tsx b/frontend/apps/app/features/migrations/pages/MigrationDetailPage/MigrationDetailPage.tsx index f4140e95b2..c73fcf714d 100644 --- a/frontend/apps/app/features/migrations/pages/MigrationDetailPage/MigrationDetailPage.tsx +++ b/frontend/apps/app/features/migrations/pages/MigrationDetailPage/MigrationDetailPage.tsx @@ -22,19 +22,19 @@ async function getMigrationContents(migrationId: string) { const supabase = await createClient() const { data: migration, error: migrationError } = await supabase - .from('Migration') + .from('migrations') .select(` id, title, - createdAt, - pullRequestId, - PullRequest:pullRequestId ( + created_at, + pull_request_id, + pull_requests ( id, - pullNumber, - repositoryId, - Repository:repositoryId ( + pull_number, + repository_id, + repositories ( id, - installationId, + installation_id, name, owner ) @@ -48,48 +48,48 @@ async function getMigrationContents(migrationId: string) { return notFound() } - const pullRequest = migration.PullRequest - const repository = pullRequest.Repository + const pullRequest = migration.pull_requests + const repository = pullRequest.repositories const { data: overallReview, error: reviewError } = await supabase - .from('OverallReview') + .from('overall_reviews') .select(` *, - reviewFeedbacks:ReviewFeedback ( + review_feedbacks ( id, category, severity, description, suggestion, - resolvedAt, - resolutionComment, - createdAt, - updatedAt, - overallReviewId, - suggestionSnippets:ReviewSuggestionSnippet ( + resolved_at, + resolution_comment, + created_at, + updated_at, + overall_review_id, + review_suggestion_snippets ( id, filename, snippet ) ) `) - .eq('pullRequestId', pullRequest.id) - .order('createdAt', { ascending: false }) + .eq('pull_request_id', pullRequest.id) + .order('created_at', { ascending: false }) .limit(1) .single() const prDetails = await getPullRequestDetails( - repository.installationId, + repository.installation_id, repository.owner, repository.name, - pullRequest.pullNumber, + pullRequest.pull_number, ) const files = await getPullRequestFiles( - repository.installationId, + repository.installation_id, repository.owner, repository.name, - pullRequest.pullNumber, + pullRequest.pull_number, ) // If there's no overallReview, return with empty review data @@ -99,10 +99,10 @@ async function getMigrationContents(migrationId: string) { migration, overallReview: { id: null, - projectId: null, - reviewComment: null, - reviewedAt: null, - reviewFeedbacks: [], + project_id: null, + review_comment: null, + reviewed_at: null, + review_feedbacks: [], }, erdLinks: [], knowledgeSuggestions: [], @@ -110,14 +110,14 @@ async function getMigrationContents(migrationId: string) { } const { data: schemaPath, error: pathError } = await supabase - .from('GitHubSchemaFilePath') + .from('github_schema_file_paths') .select('path') - .eq('projectId', overallReview.projectId || '') + .eq('project_id', overallReview.project_id || '') .single() if (pathError) { console.warn( - `No schema path found for project ${overallReview.projectId}: ${JSON.stringify(pathError)}`, + `No schema path found for project ${overallReview.project_id}: ${JSON.stringify(pathError)}`, ) return { migration, @@ -135,7 +135,7 @@ async function getMigrationContents(migrationId: string) { path: urlgen( 'projects/[projectId]/ref/[branchOrCommit]/schema/[...schemaFilePath]', { - projectId: `${overallReview.projectId}`, + projectId: `${overallReview.project_id}`, branchOrCommit: prDetails.head.ref, schemaFilePath: filename, }, @@ -145,30 +145,30 @@ async function getMigrationContents(migrationId: string) { // Fetch related KnowledgeSuggestions through the mapping table const { data: knowledgeSuggestions = [] } = await supabase - .from('OverallReviewKnowledgeSuggestionMapping') + .from('overall_review_knowledge_suggestion_mappings') .select(` - knowledgeSuggestionId, - knowledgeSuggestion:knowledgeSuggestionId ( + knowledge_suggestion_id, + knowledge_suggestions ( id, type, title, path, content, - projectId, - branchName, - createdAt, - updatedAt, - approvedAt, - fileSha, - traceId + project_id, + branch_name, + created_at, + updated_at, + approved_at, + file_sha, + trace_id ) `) - .eq('overallReviewId', overallReview.id) - .order('createdAt', { ascending: false }) + .eq('overall_review_id', overallReview.id) + .order('created_at', { ascending: false }) // Map the result to extract the knowledgeSuggestion property from each item const mappedKnowledgeSuggestions = (knowledgeSuggestions || []) - .map((item) => item.knowledgeSuggestion) + .map((item) => item.knowledge_suggestions) .filter((suggestion) => !!suggestion) return { @@ -191,8 +191,8 @@ export const MigrationDetailPage: FC = async ({ knowledgeSuggestions = [], } = await getMigrationContents(migrationId) - const formattedReviewDate = overallReview.reviewedAt - ? new Date(overallReview.reviewedAt).toLocaleDateString('en-US') + const formattedReviewDate = overallReview.reviewed_at + ? new Date(overallReview.reviewed_at).toLocaleDateString('en-US') : 'Not reviewed yet' return ( @@ -209,11 +209,13 @@ export const MigrationDetailPage: FC = async ({

{migration.title}

-

#{migration.PullRequest.pullNumber}

+

+ #{migration.pull_requests.pull_number} +

Migration Health

@@ -233,14 +235,14 @@ export const MigrationDetailPage: FC = async ({

Review Content

- {overallReview.reviewComment ? ( + {overallReview.review_comment ? ( <>
-                  {overallReview.reviewComment}
+                  {overallReview.review_comment}
                 
- {overallReview.traceId && ( + {overallReview.trace_id && (
- +
)} @@ -251,12 +253,14 @@ export const MigrationDetailPage: FC = async ({

Review Feedbacks

- {overallReview.reviewFeedbacks.filter( + {overallReview.review_feedbacks.filter( (feedback) => - feedback.severity === 'CRITICAL' && !feedback.resolvedAt, + feedback.severity === 'CRITICAL' && !feedback.resolved_at, ).length > 0 && ( )} @@ -290,7 +294,7 @@ export const MigrationDetailPage: FC = async ({ 'projects/[projectId]/ref/[branchOrCommit]/knowledge-suggestions/[id]', { projectId: `${projectId}`, - branchOrCommit: suggestion.branchName || 'main', + branchOrCommit: suggestion.branch_name || 'main', id: `${suggestion.id}`, }, )} diff --git a/frontend/apps/app/features/migrations/utils/formatReviewFeedback.ts b/frontend/apps/app/features/migrations/utils/formatReviewFeedback.ts index 7c30d0876d..513e061b2e 100644 --- a/frontend/apps/app/features/migrations/utils/formatReviewFeedback.ts +++ b/frontend/apps/app/features/migrations/utils/formatReviewFeedback.ts @@ -52,8 +52,8 @@ export function formatAllReviewFeedbacks( severity: string description: string suggestion: string - resolvedAt?: string | null - suggestionSnippets: Array<{ + resolved_at?: string | null + review_suggestion_snippets: Array<{ id: string filename: string snippet: string @@ -62,7 +62,7 @@ export function formatAllReviewFeedbacks( ): string { // Filter feedbacks to only include critical severity and unresolved feedbacks const filteredFeedbacks = feedbacks.filter( - (feedback) => feedback.severity === 'CRITICAL' && !feedback.resolvedAt, + (feedback) => feedback.severity === 'CRITICAL' && !feedback.resolved_at, ) if (filteredFeedbacks.length === 0) { @@ -76,7 +76,7 @@ export function formatAllReviewFeedbacks( severity: feedback.severity, description: feedback.description, suggestion: feedback.suggestion, - snippets: feedback.suggestionSnippets.map((snippet) => ({ + snippets: feedback.review_suggestion_snippets.map((snippet) => ({ filename: snippet.filename, snippet: snippet.snippet, })), diff --git a/frontend/apps/app/features/organizations/pages/OrganizationDetailPage/OrganizationDetailPage.tsx b/frontend/apps/app/features/organizations/pages/OrganizationDetailPage/OrganizationDetailPage.tsx index c5e38ca073..9b5bc15271 100644 --- a/frontend/apps/app/features/organizations/pages/OrganizationDetailPage/OrganizationDetailPage.tsx +++ b/frontend/apps/app/features/organizations/pages/OrganizationDetailPage/OrganizationDetailPage.tsx @@ -15,7 +15,7 @@ interface OrganizationDetailPageProps { } members: Array<{ id: string - user: { + users: { id: string name: string email: string @@ -24,7 +24,7 @@ interface OrganizationDetailPageProps { invites: Array<{ id: string email: string - inviteBy: { + invite_by_user_id: { id: string name: string email: string @@ -58,7 +58,7 @@ export const OrganizationDetailPage: FC = ({ const supabase = await createClient() const { error: updateError } = await supabase - .from('Organization') + .from('organizations') .update({ name }) .eq('id', organization.id) @@ -141,8 +141,8 @@ export const OrganizationDetailPage: FC = ({ {members && members.length > 0 ? ( members.map((member) => ( - {member.user.name} - {member.user.email} + {member.users.name} + {member.users.email} ACTIVE - @@ -171,7 +171,7 @@ export const OrganizationDetailPage: FC = ({ invites.map((invite) => ( {invite.email} - {invite.inviteBy.name} + {invite.invite_by_user_id.name} - )) diff --git a/frontend/apps/app/features/organizations/pages/OrganizationDetailPage/getOrganizationDetails.ts b/frontend/apps/app/features/organizations/pages/OrganizationDetailPage/getOrganizationDetails.ts index fa6e180a05..0f98e2ba4b 100644 --- a/frontend/apps/app/features/organizations/pages/OrganizationDetailPage/getOrganizationDetails.ts +++ b/frontend/apps/app/features/organizations/pages/OrganizationDetailPage/getOrganizationDetails.ts @@ -4,7 +4,7 @@ export const getOrganizationDetails = async (organizationId: string) => { const supabase = await createClient() const { data: organization, error } = await supabase - .from('Organization') + .from('organizations') .select('*') .eq('id', organizationId) .single() @@ -21,17 +21,17 @@ export const getOrganizationMembers = async (organizationId: string) => { const supabase = await createClient() const { data: members, error } = await supabase - .from('OrganizationMember') + .from('organization_members') .select(` id, - user:userId( + users( id, name, email ) `) - .eq('organizationId', organizationId) + .eq('organization_id', organizationId) if (error) { console.error('Error fetching organization members:', error) @@ -45,18 +45,18 @@ export const getOrganizationInvites = async (organizationId: string) => { const supabase = await createClient() const { data: invites, error } = await supabase - .from('MembershipInvites') + .from('membership_invites') .select(` id, email, - inviteBy:inviteByUserId( + invite_by_user_id( id, name, email ) `) - .eq('organizationId', organizationId) + .eq('organization_id', organizationId) if (error) { console.error('Error fetching organization invites:', error) diff --git a/frontend/apps/app/features/organizations/pages/OrganizationNewPage/OrganizationNewPage.tsx b/frontend/apps/app/features/organizations/pages/OrganizationNewPage/OrganizationNewPage.tsx index e4567b858c..c694f754d6 100644 --- a/frontend/apps/app/features/organizations/pages/OrganizationNewPage/OrganizationNewPage.tsx +++ b/frontend/apps/app/features/organizations/pages/OrganizationNewPage/OrganizationNewPage.tsx @@ -16,7 +16,7 @@ export const OrganizationNewPage: FC = () => { const createOrg = async (supabase: SupabaseClient) => { const { data, error } = await supabase - .from('Organization') + .from('organizations') .insert({ name }) .select('id') .single() @@ -30,9 +30,9 @@ export const OrganizationNewPage: FC = () => { userId: string, organizationId: string, ) => { - const { error } = await supabase.from('OrganizationMember').insert({ - userId, - organizationId, + const { error } = await supabase.from('organization_members').insert({ + user_id: userId, + organization_id: organizationId, }) if (error) throw error diff --git a/frontend/apps/app/features/organizations/pages/OrganizationsPage/getOrganizations.ts b/frontend/apps/app/features/organizations/pages/OrganizationsPage/getOrganizations.ts index bf154bbb2b..704a888ea8 100644 --- a/frontend/apps/app/features/organizations/pages/OrganizationsPage/getOrganizations.ts +++ b/frontend/apps/app/features/organizations/pages/OrganizationsPage/getOrganizations.ts @@ -10,19 +10,19 @@ export const getOrganizations = async () => { } const { data: organizations, error } = await supabase - .from('OrganizationMember') + .from('organization_members') .select(` - organization:organizationId( + organizations( id, name ) `) - .eq('userId', userData.user.id) + .eq('user_id', userData.user.id) if (error) { console.error('Error fetching organizations:', error) return null } - return organizations.map((item) => item.organization) + return organizations.map((item) => item.organizations) } diff --git a/frontend/apps/app/features/projects/actions/addProject.ts b/frontend/apps/app/features/projects/actions/addProject.ts index c352558eb5..a643fdd485 100644 --- a/frontend/apps/app/features/projects/actions/addProject.ts +++ b/frontend/apps/app/features/projects/actions/addProject.ts @@ -17,12 +17,12 @@ export const addProject = async (formData: FormData) => { // Create project const { data: project, error: projectError } = await supabase - .from('Project') + .from('projects') .insert({ name: projectName, - createdAt: now, - updatedAt: now, - ...(organizationId ? { organizationId } : {}), + created_at: now, + updated_at: now, + ...(organizationId ? { organization_id: organizationId } : {}), }) .select() .single() @@ -33,13 +33,13 @@ export const addProject = async (formData: FormData) => { // Create repository const { data: repository, error: repositoryError } = await supabase - .from('Repository') + .from('repositories') .insert({ name: repositoryName, owner: repositoryOwner, - installationId: Number(installationId), - isActive: true, - updatedAt: now, + installation_id: Number(installationId), + is_active: true, + updated_at: now, }) .select() .single() @@ -50,11 +50,11 @@ export const addProject = async (formData: FormData) => { // Create project-repository mapping const { error: mappingError } = await supabase - .from('ProjectRepositoryMapping') + .from('project_repository_mappings') .insert({ - projectId: project.id, - repositoryId: repository.id, - updatedAt: now, + project_id: project.id, + repository_id: repository.id, + updated_at: now, }) if (mappingError) { diff --git a/frontend/apps/app/features/projects/actions/approveKnowledgeSuggestion.ts b/frontend/apps/app/features/projects/actions/approveKnowledgeSuggestion.ts index 8c2dcc8e96..224b0c667a 100644 --- a/frontend/apps/app/features/projects/actions/approveKnowledgeSuggestion.ts +++ b/frontend/apps/app/features/projects/actions/approveKnowledgeSuggestion.ts @@ -28,11 +28,11 @@ const createMapping = async ( updatedAt: string, ) => { const { error: mappingError } = await supabase - .from('KnowledgeSuggestionDocMapping') + .from('knowledge_suggestion_doc_mappings') .insert({ - knowledgeSuggestionId, - gitHubDocFilePathId, - updatedAt, + knowledge_suggestion_id: knowledgeSuggestionId, + github_doc_file_path_id: gitHubDocFilePathId, + updated_at: updatedAt, }) if (mappingError) { @@ -45,14 +45,14 @@ const createMapping = async ( */ const handleDocFilePath = async ( supabase: SupabaseClient, - suggestion: { projectId: string; path: string; type: string }, + suggestion: { project_id: string; path: string; type: string }, suggestionId: string, ) => { // Check if there's a GitHubDocFilePath entry for this path const { data: docFilePath } = await supabase - .from('GitHubDocFilePath') + .from('github_doc_file_paths') .select('id') - .eq('projectId', suggestion.projectId) + .eq('project_id', suggestion.project_id) .eq('path', suggestion.path) .maybeSingle() @@ -60,12 +60,12 @@ const handleDocFilePath = async ( // Create a new GitHubDocFilePath entry const now = new Date().toISOString() const { data: newDocFilePath, error: createDocError } = await supabase - .from('GitHubDocFilePath') + .from('github_doc_file_paths') .insert({ path: suggestion.path, - isReviewEnabled: true, - projectId: suggestion.projectId, - updatedAt: now, + is_review_enabled: true, + project_id: suggestion.project_id, + updated_at: now, }) .select() .single() @@ -79,10 +79,10 @@ const handleDocFilePath = async ( } else { // Create a mapping if it doesn't exist const { data: existingMapping } = await supabase - .from('KnowledgeSuggestionDocMapping') + .from('knowledge_suggestion_doc_mappings') .select('id') - .eq('knowledgeSuggestionId', suggestionId) - .eq('gitHubDocFilePathId', docFilePath.id) + .eq('knowledge_suggestion_id', suggestionId) + .eq('github_doc_file_path_id', docFilePath.id) .maybeSingle() if (!existingMapping) { @@ -119,7 +119,7 @@ export const approveKnowledgeSuggestion = async (formData: FormData) => { // Get the knowledge suggestion const { data: suggestion, error: findError } = await supabase - .from('KnowledgeSuggestion') + .from('knowledge_suggestions') .select('*') .eq('id', suggestionId) .single() @@ -136,8 +136,8 @@ export const approveKnowledgeSuggestion = async (formData: FormData) => { suggestion.content, suggestion.title, // Use title as commit message installationId, - suggestion.branchName, - suggestion.fileSha || undefined, + suggestion.branch_name, + suggestion.file_sha || undefined, ) if (!result.success) { @@ -146,8 +146,8 @@ export const approveKnowledgeSuggestion = async (formData: FormData) => { // Update the knowledge suggestion with approvedAt const { error: updateError } = await supabase - .from('KnowledgeSuggestion') - .update({ approvedAt: new Date().toISOString() }) + .from('knowledge_suggestions') + .update({ approved_at: new Date().toISOString() }) .eq('id', suggestionId) if (updateError) { @@ -164,8 +164,8 @@ export const approveKnowledgeSuggestion = async (formData: FormData) => { urlgen( 'projects/[projectId]/ref/[branchOrCommit]/knowledge-suggestions/[id]', { - projectId: `${suggestion.projectId}`, - branchOrCommit: suggestion.branchName, + projectId: `${suggestion.project_id}`, + branchOrCommit: suggestion.branch_name, id: `${suggestionId}`, }, ), diff --git a/frontend/apps/app/features/projects/actions/updateKnowledgeSuggestionContent.ts b/frontend/apps/app/features/projects/actions/updateKnowledgeSuggestionContent.ts index 72b7a3053d..a2c773be37 100644 --- a/frontend/apps/app/features/projects/actions/updateKnowledgeSuggestionContent.ts +++ b/frontend/apps/app/features/projects/actions/updateKnowledgeSuggestionContent.ts @@ -26,7 +26,7 @@ export const updateKnowledgeSuggestionContent = async (formData: FormData) => { const supabase = await createClient() const { error: updateError } = await supabase - .from('KnowledgeSuggestion') + .from('knowledge_suggestions') .update({ content, updatedAt: new Date().toISOString() }) .eq('id', suggestionId) diff --git a/frontend/apps/app/features/projects/components/ProjectItem/ProjectItem.tsx b/frontend/apps/app/features/projects/components/ProjectItem/ProjectItem.tsx index b05e65ed0b..01f3f1b9b5 100644 --- a/frontend/apps/app/features/projects/components/ProjectItem/ProjectItem.tsx +++ b/frontend/apps/app/features/projects/components/ProjectItem/ProjectItem.tsx @@ -8,7 +8,7 @@ import styles from './ProjectItem.module.css' interface Project { id: string name: string - createdAt: string + created_at: string } interface ProjectItemProps { @@ -51,7 +51,7 @@ export const ProjectItem: FC = ({ project }) => {
User committed - on {formatDate(project.createdAt)} + on {formatDate(project.created_at)}
diff --git a/frontend/apps/app/features/projects/hooks/useProjectSearch.ts b/frontend/apps/app/features/projects/hooks/useProjectSearch.ts index 80a8503321..e75d0646c0 100644 --- a/frontend/apps/app/features/projects/hooks/useProjectSearch.ts +++ b/frontend/apps/app/features/projects/hooks/useProjectSearch.ts @@ -4,14 +4,14 @@ import type { Tables } from '@liam-hq/db/supabase/database.types' import { useState } from 'react' type SearchResult = { - projects: Tables<'Project'>[] | null + projects: Tables<'projects'>[] | null loading: boolean error: Error | null } export const useProjectSearch = ( organizationId?: string, - initialProjects?: Tables<'Project'>[] | null, + initialProjects?: Tables<'projects'>[] | null, ) => { const [searchResult, setSearchResult] = useState({ projects: initialProjects || null, diff --git a/frontend/apps/app/features/projects/pages/BranchDetailPage/BranchDetailPage.tsx b/frontend/apps/app/features/projects/pages/BranchDetailPage/BranchDetailPage.tsx index 42eb3ad082..2bd2fd5c9b 100644 --- a/frontend/apps/app/features/projects/pages/BranchDetailPage/BranchDetailPage.tsx +++ b/frontend/apps/app/features/projects/pages/BranchDetailPage/BranchDetailPage.tsx @@ -12,11 +12,11 @@ type Props = { async function getBranchDetails(projectId: string) { const supabase = await createClient() const { data: project, error } = await supabase - .from('Project') + .from('projects') .select(` *, - ProjectRepositoryMapping!inner ( - Repository ( + project_repository_mappings!inner ( + repositories ( id, name, owner @@ -32,9 +32,9 @@ async function getBranchDetails(projectId: string) { } const { data: schemaPath, error: schemaPathError } = await supabase - .from('GitHubSchemaFilePath') + .from('github_schema_file_paths') .select('path') - .eq('projectId', projectId) + .eq('project_id', projectId) .single() if (schemaPathError) { @@ -44,9 +44,9 @@ async function getBranchDetails(projectId: string) { } const { data: docPaths, error: docPathsError } = await supabase - .from('GitHubDocFilePath') + .from('github_doc_file_paths') .select('path') - .eq('projectId', projectId) + .eq('project_id', projectId) if (docPathsError) { console.error('Error fetching doc paths:', docPathsError) @@ -61,7 +61,7 @@ async function getBranchDetails(projectId: string) { return { ...project, - repository: project.ProjectRepositoryMapping[0].Repository, + repository: project.project_repository_mappings[0].repositories, schemaPath: transformedSchemaPath, docPaths: transformedDocPaths, } diff --git a/frontend/apps/app/features/projects/pages/KnowledgeSuggestionDetailPage/ContentForDoc.tsx b/frontend/apps/app/features/projects/pages/KnowledgeSuggestionDetailPage/ContentForDoc.tsx index 355a462178..7238e150e9 100644 --- a/frontend/apps/app/features/projects/pages/KnowledgeSuggestionDetailPage/ContentForDoc.tsx +++ b/frontend/apps/app/features/projects/pages/KnowledgeSuggestionDetailPage/ContentForDoc.tsx @@ -29,7 +29,7 @@ export const ContentForDoc: FC = ({ suggestion, originalContent }) => { suggestionId={suggestion.id} className={styles.codeContent} originalContent={originalContent} - isApproved={!!suggestion.approvedAt} + isApproved={!!suggestion.approved_at} onContentSaved={handleContentSaved} />
diff --git a/frontend/apps/app/features/projects/pages/KnowledgeSuggestionDetailPage/ContentForSchema.tsx b/frontend/apps/app/features/projects/pages/KnowledgeSuggestionDetailPage/ContentForSchema.tsx index 500eb8fe30..30bcf0c38b 100644 --- a/frontend/apps/app/features/projects/pages/KnowledgeSuggestionDetailPage/ContentForSchema.tsx +++ b/frontend/apps/app/features/projects/pages/KnowledgeSuggestionDetailPage/ContentForSchema.tsx @@ -13,9 +13,9 @@ async function getGithubSchemaFilePath(projectId: string) { const projectId_num = projectId const supabase = await createClient() const { data: gitHubSchemaFilePath, error } = await supabase - .from('GitHubSchemaFilePath') + .from('github_schema_file_paths') .select('*') - .eq('projectId', projectId_num) + .eq('project_id', projectId_num) .single() if (error || !gitHubSchemaFilePath) { @@ -41,7 +41,8 @@ export const ContentForSchema: FC = async ({ projectId, branchOrCommit, }) => { - const repository = suggestion.project.repositoryMappings[0]?.repository + const repository = + suggestion.projects.project_repository_mappings[0]?.repositories const repositoryFullName = `${repository.owner}/${repository.name}` const githubSchemaFilePath = await getGithubSchemaFilePath(projectId) @@ -52,7 +53,7 @@ export const ContentForSchema: FC = async ({ repositoryFullName, filePath, branchOrCommit, - Number(repository.installationId), + Number(repository.installation_id), ) const { value: schema, errors } = @@ -69,15 +70,15 @@ export const ContentForSchema: FC = async ({ suggestionContent={suggestion.content} suggestionId={suggestion.id} originalContent={ - !suggestion.approvedAt + !suggestion.approved_at ? await getOriginalDocumentContent( projectId, - suggestion.branchName, + suggestion.branch_name, suggestion.path, ) : null } - isApproved={!!suggestion.approvedAt} + isApproved={!!suggestion.approved_at} schema={schema} content={content} errors={errors || []} diff --git a/frontend/apps/app/features/projects/pages/KnowledgeSuggestionDetailPage/KnowledgeSuggestionDetailPage.tsx b/frontend/apps/app/features/projects/pages/KnowledgeSuggestionDetailPage/KnowledgeSuggestionDetailPage.tsx index 0f8029c211..8d2b5e65c6 100644 --- a/frontend/apps/app/features/projects/pages/KnowledgeSuggestionDetailPage/KnowledgeSuggestionDetailPage.tsx +++ b/frontend/apps/app/features/projects/pages/KnowledgeSuggestionDetailPage/KnowledgeSuggestionDetailPage.tsx @@ -17,19 +17,19 @@ async function getSuggestionWithProject( const supabase = await createClient() const { data, error } = await supabase - .from('KnowledgeSuggestion') + .from('knowledge_suggestions') .select(` *, - project:Project( + projects( id, name, - repositoryMappings:ProjectRepositoryMapping( - repository:Repository(*) + project_repository_mappings( + repositories(*) ) ) `) .eq('id', suggestionId) - .eq('projectId', projectId) + .eq('project_id', projectId) .single() if (error) throw error @@ -73,7 +73,8 @@ export const KnowledgeSuggestionDetailPage: FC = async ({ branchOrCommit, }) => { const suggestion = await getKnowledgeSuggestionDetail(projectId, suggestionId) - const repository = suggestion.project.repositoryMappings[0]?.repository + const repository = + suggestion.projects.project_repository_mappings[0]?.repositories return (
@@ -84,7 +85,7 @@ export const KnowledgeSuggestionDetailPage: FC = async ({ 'projects/[projectId]/ref/[branchOrCommit]/knowledge-suggestions', { projectId, - branchOrCommit: suggestion.branchName, + branchOrCommit: suggestion.branch_name, }, )} className={styles.backLink} @@ -101,22 +102,24 @@ export const KnowledgeSuggestionDetailPage: FC = async ({ Type: {suggestion.type} Path: {suggestion.path} - Status: {suggestion.approvedAt ? 'Approved' : 'Pending'} + Status: {suggestion.approved_at ? 'Approved' : 'Pending'} Created:{' '} - {new Date(suggestion.createdAt).toLocaleString('en-US', { + {new Date(suggestion.created_at).toLocaleString('en-US', { dateStyle: 'medium', timeStyle: 'short', hour12: false, })} - {suggestion.approvedAt && ( + {suggestion.approved_at && ( Approved:{' '} - {new Date(suggestion.createdAt).toLocaleString('en-US', { + {new Date(suggestion.created_at).toLocaleString('en-US', { dateStyle: 'medium', timeStyle: 'short', hour12: false, @@ -146,10 +149,10 @@ export const KnowledgeSuggestionDetailPage: FC = async ({ = async ({ )) .exhaustive()} - {!suggestion.approvedAt && repository && ( + {!suggestion.approved_at && repository && (
@@ -175,7 +178,7 @@ export const KnowledgeSuggestionDetailPage: FC = async ({