Repository: liam-hq/liam
Pull request #1489: feat: add organization_id to overall_review_knowledge_suggestion_mappings
Author: login: devin-ai-integration[bot]
Labels: name: Review effort 2/5
Created: 2025-04-24T10:34:11Z | Merged: 2025-04-25T11:14:05Z

<img width="826" alt="スクリーンショット 2025-04-25 18 21 49" src="https://github.com/user-attachments/assets/dae7d244-f912-4f5c-bac7-1ca076b85c97" />

<img width="1312" alt="スクリーンショット_2025-04-25_18_22_20" src="https://github.com/user-attachments/assets/c4b9051c-411d-4d2b-8e30-642263838638" />

## Why is this change needed?
This change is necessary to implement row-level security (RLS) for the overall_review_knowledge_suggestion_mappings table, ensuring that users can only access data from organizations they belong to.

## What would you like reviewers to focus on?
- The migration script for adding organization_id
- The trigger function implementation for automatically setting organization_id
- The RLS policy implementation
- The type override implementation

## Testing Verification
This PR is submitted as a draft for review. The implementation follows the organization_id implementation pattern used in other tables.

## What was done
<!-- This section will be filled by PR-Agent when the Pull Request is opened -->

### 🤖 Generated by PR Agent at ec4ef860d61098ebefad3ca4d169ee0226da8760

- Add `organization_id` column to `overall_review_knowledge_suggestion_mappings`
  - Populate existing rows from `knowledge_suggestions`
  - Enforce NOT NULL and foreign key constraint
- Implement trigger to auto-set `organization_id` on insert/update
- Enable row-level security (RLS) and add RLS policies for organization-based access
- Update TypeScript types and overrides for new column and RLS support


## Detailed Changes
<!-- This section will be filled by PR-Agent when the Pull Request is opened -->

<table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table>
<tr>
  <td>
    <details>
      <summary><strong>20250424102300_add_organization_id_to_overall_review_knowledge_suggestion_mappings.sql</strong><dd><code>Migration for organization_id and RLS on mappings table</code>&nbsp; &nbsp; </dd></summary>
<hr>

frontend/packages/db/supabase/migrations/20250424102300_add_organization_id_to_overall_review_knowledge_suggestion_mappings.sql

<li>Adds <code>organization_id</code> column to the table<br> <li> Populates column from <code>knowledge_suggestions</code><br> <li> Adds foreign key, trigger, and RLS policies<br> <li> Enables RLS and inserts service/authenticated policies


</details>


  </td>
  <td><a href="https://github.com/liam-hq/liam/pull/1489/files#diff-8cd3727af1b92e18c657a888ab2689e60803886843156b056543a52d35673dc4">+59/-0</a>&nbsp; &nbsp; </td>

</tr>

<tr>
  <td>
    <details>
      <summary><strong>schema.sql</strong><dd><code>Schema changes for organization_id and RLS policies</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

frontend/packages/db/schema/schema.sql

<li>Adds <code>organization_id</code> column and foreign key to schema<br> <li> Defines trigger function for auto-setting organization_id<br> <li> Adds RLS policies and enables RLS for the table<br> <li> Grants function permissions for new trigger


</details>


  </td>
  <td><a href="https://github.com/liam-hq/liam/pull/1489/files#diff-8b2c9777e5e6614148282316dd37f3a4e9d4f6f4f2ad15b5247aea65a7bd010d">+51/-1</a>&nbsp; &nbsp; </td>

</tr>

<tr>
  <td>
    <details>
      <summary><strong>database.types.ts</strong><dd><code>Update TypeScript types for organization_id column</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

frontend/packages/db/supabase/database.types.ts

<li>Adds <code>organization_id</code> to Row/Insert/Update types for the table<br> <li> Updates Relationships with new foreign key


</details>


  </td>
  <td><a href="https://github.com/liam-hq/liam/pull/1489/files#diff-9790acb5594a7a7ed6d0d917ca1ae8f549dd984aa7f3e96b549b6939f84a7f01">+10/-0</a>&nbsp; &nbsp; </td>

</tr>

<tr>
  <td>
    <details>
      <summary><strong>index.ts</strong><dd><code>Add override for mappings table to type overrides</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

frontend/packages/db/src/types/supabase-overrides/index.ts

- Adds override import and merge for new table


</details>


  </td>
  <td><a href="https://github.com/liam-hq/liam/pull/1489/files#diff-dd044929bd93690f2f4db6fc0345f1fe1eac4ac94ba319a4483ed33412604656">+3/-1</a>&nbsp; &nbsp; &nbsp; </td>

</tr>

<tr>
  <td>
    <details>
      <summary><strong>overall_review_knowledge_suggestion_mappings.ts</strong><dd><code>Type override for organization_id in mappings table</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

frontend/packages/db/src/types/supabase-overrides/overall_review_knowledge_suggestion_mappings.ts

<li>Adds override interface for Insert/Update with optional <br>organization_id


</details>


  </td>
  <td><a href="https://github.com/liam-hq/liam/pull/1489/files#diff-fbdee5e1c7936fc618dacd0a0f5155b6e868ee7ad5b3be6ab22dc93eca55dd57">+14/-0</a>&nbsp; &nbsp; </td>

</tr>

<tr>
  <td>
    <details>
      <summary><strong>knowledge_suggestions.ts</strong><dd><code>Allow organization_id in knowledge_suggestions Update type</code></dd></summary>
<hr>

frontend/packages/db/src/types/supabase-overrides/knowledge_suggestions.ts

- Adds optional organization_id to Update type


</details>


  </td>
  <td><a href="https://github.com/liam-hq/liam/pull/1489/files#diff-6cb2cc54b0160ddece69f1af782dcd196afd00bb9515cb292a6a32928590cf9a">+3/-0</a>&nbsp; &nbsp; &nbsp; </td>

</tr>
</table></td></tr></tr></tbody></table>

## Additional Notes
- This PR adds organization_id to the overall_review_knowledge_suggestion_mappings table
- Creates a trigger function to automatically set organization_id from the knowledge_suggestions table
- Implements RLS policies for authenticated users and service role
- Adds type overrides to make organization_id optional in Insert/Update operations
- Follows the same pattern as the knowledge_suggestions table implementation

___

> <details> <summary>  Need help?</summary><li>Type <code>/help how to ...</code> in the comments thread for any questions about Qodo Merge usage.</li><li>Check out the <a href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a> for more information.</li></details>


Diff:
diff --git a/frontend/packages/db/schema/schema.sql b/frontend/packages/db/schema/schema.sql
index 67289d3214..73e1df11d9 100644
--- a/frontend/packages/db/schema/schema.sql
+++ b/frontend/packages/db/schema/schema.sql
@@ -353,6 +353,23 @@ $$;
 ALTER FUNCTION "public"."set_knowledge_suggestions_organization_id"() OWNER TO "postgres";
 
 
+CREATE OR REPLACE FUNCTION "public"."set_overall_review_knowledge_suggestion_mappings_organization_i"() RETURNS "trigger"
+    LANGUAGE "plpgsql" SECURITY DEFINER
+    AS $$
+BEGIN
+  NEW.organization_id := (
+    SELECT "organization_id" 
+    FROM "public"."knowledge_suggestions" 
+    WHERE "id" = NEW.knowledge_suggestion_id
+  );
+  RETURN NEW;
+END;
+$$;
+
+
+ALTER FUNCTION "public"."set_overall_review_knowledge_suggestion_mappings_organization_i"() OWNER TO "postgres";
+
+
 CREATE OR REPLACE FUNCTION "public"."sync_existing_users"() RETURNS "void"
     LANGUAGE "plpgsql" SECURITY DEFINER
     AS $$
@@ -524,7 +541,8 @@ CREATE TABLE IF NOT EXISTS "public"."overall_review_knowledge_suggestion_mapping
     "overall_review_id" "uuid" NOT NULL,
     "knowledge_suggestion_id" "uuid" NOT NULL,
     "created_at" timestamp(3) with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
-    "updated_at" timestamp(3) with time zone NOT NULL
+    "updated_at" timestamp(3) with time zone NOT NULL,
+    "organization_id" "uuid" NOT NULL
 );
 
 
@@ -843,6 +861,10 @@ CREATE OR REPLACE TRIGGER "set_knowledge_suggestions_organization_id_trigger" BE
 
 
 
+CREATE OR REPLACE TRIGGER "set_overall_review_knowledge_suggestion_mappings_organization_i" BEFORE INSERT OR UPDATE ON "public"."overall_review_knowledge_suggestion_mappings" FOR EACH ROW EXECUTE FUNCTION "public"."set_overall_review_knowledge_suggestion_mappings_organization_i"();
+
+
+
 ALTER TABLE ONLY "public"."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;
 
@@ -928,6 +950,11 @@ ALTER TABLE ONLY "public"."overall_review_knowledge_suggestion_mappings"
 
 
 
+ALTER TABLE ONLY "public"."overall_review_knowledge_suggestion_mappings"
+    ADD CONSTRAINT "overall_review_knowledge_suggestion_mappings_organization_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON UPDATE CASCADE ON DELETE RESTRICT;
+
+
+
 ALTER TABLE ONLY "public"."overall_reviews"
     ADD CONSTRAINT "overall_review_migration_id_fkey" FOREIGN KEY ("migration_id") REFERENCES "public"."migrations"("id") ON UPDATE CASCADE ON DELETE RESTRICT;
 
@@ -1023,6 +1050,16 @@ COMMENT ON POLICY "authenticated_users_can_select_org_knowledge_suggestions" ON
 
 
 
+CREATE POLICY "authenticated_users_can_select_org_overall_review_knowledge_sug" ON "public"."overall_review_knowledge_suggestion_mappings" 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_overall_review_knowledge_sug" ON "public"."overall_review_knowledge_suggestion_mappings" IS 'Authenticated users can only view mappings belonging to organizations they are members of';
+
+
+
 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"()))));
@@ -1060,6 +1097,9 @@ COMMENT ON POLICY "authenticated_users_can_update_org_projects" ON "public"."pro
 ALTER TABLE "public"."knowledge_suggestions" ENABLE ROW LEVEL SECURITY;
 
 
+ALTER TABLE "public"."overall_review_knowledge_suggestion_mappings" ENABLE ROW LEVEL SECURITY;
+
+
 ALTER TABLE "public"."projects" ENABLE ROW LEVEL SECURITY;
 
 
@@ -1079,6 +1119,10 @@ CREATE POLICY "service_role_can_insert_all_knowledge_suggestions" ON "public"."k
 
 
 
+CREATE POLICY "service_role_can_insert_all_overall_review_knowledge_suggestion" ON "public"."overall_review_knowledge_suggestion_mappings" 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);
 
 
@@ -1337,6 +1381,12 @@ GRANT ALL ON FUNCTION "public"."set_knowledge_suggestions_organization_id"() TO
 
 
 
+GRANT ALL ON FUNCTION "public"."set_overall_review_knowledge_suggestion_mappings_organization_i"() TO "anon";
+GRANT ALL ON FUNCTION "public"."set_overall_review_knowledge_suggestion_mappings_organization_i"() TO "authenticated";
+GRANT ALL ON FUNCTION "public"."set_overall_review_knowledge_suggestion_mappings_organization_i"() TO "service_role";
+
+
+
 GRANT ALL ON FUNCTION "public"."sync_existing_users"() TO "anon";
 GRANT ALL ON FUNCTION "public"."sync_existing_users"() TO "authenticated";
 GRANT ALL ON FUNCTION "public"."sync_existing_users"() TO "service_role";
diff --git a/frontend/packages/db/src/types/supabase-overrides/index.ts b/frontend/packages/db/src/types/supabase-overrides/index.ts
index 0c3e042ee6..cc16e70f2a 100644
--- a/frontend/packages/db/src/types/supabase-overrides/index.ts
+++ b/frontend/packages/db/src/types/supabase-overrides/index.ts
@@ -1,8 +1,10 @@
 import type { MergeDeep } from 'type-fest'
 import type { Database as DatabaseGenerated } from '../../../supabase/database.types'
 import type { KnowledgeSuggestionsOverride } from './knowledge_suggestions'
+import type { OverallReviewKnowledgeSuggestionMappingsOverride } from './overall_review_knowledge_suggestion_mappings'
 
 export type AppDatabaseOverrides = MergeDeep<
   DatabaseGenerated,
-  KnowledgeSuggestionsOverride
+  KnowledgeSuggestionsOverride &
+    OverallReviewKnowledgeSuggestionMappingsOverride
 >
diff --git a/frontend/packages/db/src/types/supabase-overrides/knowledge_suggestions.ts b/frontend/packages/db/src/types/supabase-overrides/knowledge_suggestions.ts
index c60e3be1d6..2c00551f09 100644
--- a/frontend/packages/db/src/types/supabase-overrides/knowledge_suggestions.ts
+++ b/frontend/packages/db/src/types/supabase-overrides/knowledge_suggestions.ts
@@ -5,6 +5,9 @@ export interface KnowledgeSuggestionsOverride {
         Insert: {
           organization_id?: string | null
         }
+        Update: {
+          organization_id?: string | null
+        }
       }
     }
   }
diff --git a/frontend/packages/db/src/types/supabase-overrides/overall_review_knowledge_suggestion_mappings.ts b/frontend/packages/db/src/types/supabase-overrides/overall_review_knowledge_suggestion_mappings.ts
new file mode 100644
index 0000000000..2f59e8ef5f
--- /dev/null
+++ b/frontend/packages/db/src/types/supabase-overrides/overall_review_knowledge_suggestion_mappings.ts
@@ -0,0 +1,14 @@
+export interface OverallReviewKnowledgeSuggestionMappingsOverride {
+  public: {
+    Tables: {
+      overall_review_knowledge_suggestion_mappings: {
+        Insert: {
+          organization_id?: string | null
+        }
+        Update: {
+          organization_id?: string | null
+        }
+      }
+    }
+  }
+}
diff --git a/frontend/packages/db/supabase/database.types.ts b/frontend/packages/db/supabase/database.types.ts
index 27d7f3f28c..b5772e8694 100644
--- a/frontend/packages/db/supabase/database.types.ts
+++ b/frontend/packages/db/supabase/database.types.ts
@@ -451,6 +451,7 @@ export type Database = {
           created_at: string
           id: string
           knowledge_suggestion_id: string
+          organization_id: string
           overall_review_id: string
           updated_at: string
         }
@@ -458,6 +459,7 @@ export type Database = {
           created_at?: string
           id?: string
           knowledge_suggestion_id: string
+          organization_id: string
           overall_review_id: string
           updated_at: string
         }
@@ -465,6 +467,7 @@ export type Database = {
           created_at?: string
           id?: string
           knowledge_suggestion_id?: string
+          organization_id?: string
           overall_review_id?: string
           updated_at?: string
         }
@@ -483,6 +486,13 @@ export type Database = {
             referencedRelation: 'overall_reviews'
             referencedColumns: ['id']
           },
+          {
+            foreignKeyName: 'overall_review_knowledge_suggestion_mappings_organization_id_fk'
+            columns: ['organization_id']
+            isOneToOne: false
+            referencedRelation: 'organizations'
+            referencedColumns: ['id']
+          },
         ]
       }
       overall_reviews: {
diff --git a/frontend/packages/db/supabase/migrations/20250424102300_add_organization_id_to_overall_review_knowledge_suggestion_mappings.sql b/frontend/packages/db/supabase/migrations/20250424102300_add_organization_id_to_overall_review_knowledge_suggestion_mappings.sql
new file mode 100644
index 0000000000..aaa6a0cac2
--- /dev/null
+++ b/frontend/packages/db/supabase/migrations/20250424102300_add_organization_id_to_overall_review_knowledge_suggestion_mappings.sql
@@ -0,0 +1,59 @@
+BEGIN;
+
+ALTER TABLE "public"."overall_review_knowledge_suggestion_mappings" ADD COLUMN "organization_id" UUID;
+
+UPDATE "public"."overall_review_knowledge_suggestion_mappings" orkm
+SET "organization_id" = (
+  SELECT ks."organization_id"
+  FROM "public"."knowledge_suggestions" ks
+  WHERE ks."id" = orkm."knowledge_suggestion_id"
+  LIMIT 1
+);
+
+ALTER TABLE "public"."overall_review_knowledge_suggestion_mappings" 
+  ALTER COLUMN "organization_id" SET NOT NULL;
+
+ALTER TABLE "public"."overall_review_knowledge_suggestion_mappings" 
+  ADD CONSTRAINT "overall_review_knowledge_suggestion_mappings_organization_id_fkey" 
+  FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") 
+  ON UPDATE CASCADE ON DELETE RESTRICT;
+
+CREATE OR REPLACE FUNCTION "public"."set_overall_review_knowledge_suggestion_mappings_organization_id"() RETURNS "trigger"
+    LANGUAGE "plpgsql" SECURITY DEFINER
+    AS $$
+BEGIN
+  NEW.organization_id := (
+    SELECT "organization_id" 
+    FROM "public"."knowledge_suggestions" 
+    WHERE "id" = NEW.knowledge_suggestion_id
+  );
+  RETURN NEW;
+END;
+$$;
+
+CREATE TRIGGER "set_overall_review_knowledge_suggestion_mappings_organization_id_trigger"
+  BEFORE INSERT OR UPDATE ON "public"."overall_review_knowledge_suggestion_mappings"
+  FOR EACH ROW
+  EXECUTE FUNCTION "public"."set_overall_review_knowledge_suggestion_mappings_organization_id"();
+
+ALTER TABLE "public"."overall_review_knowledge_suggestion_mappings" ENABLE ROW LEVEL SECURITY;
+
+CREATE POLICY "authenticated_users_can_select_org_overall_review_knowledge_suggestion_mappings" 
+  ON "public"."overall_review_knowledge_suggestion_mappings" 
+  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_overall_review_knowledge_suggestion_mappings" 
+  ON "public"."overall_review_knowledge_suggestion_mappings" 
+  IS 'Authenticated users can only view mappings belonging to organizations they are members of';
+
+CREATE POLICY "service_role_can_insert_all_overall_review_knowledge_suggestion_mappings" 
+  ON "public"."overall_review_knowledge_suggestion_mappings" 
+  FOR INSERT TO "service_role" 
+  WITH CHECK (true);
+
+COMMIT;


Reviews:
user: login: NoritakaIkeda
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-04-25T09:23:07Z
user: login: hoshinotsuyoshi
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-04-25T11:02:11Z
user: login: hoshinotsuyoshi
state: APPROVED
author_association: MEMBER
submitted_at: 2025-04-25T11:05:57Z

Review comments:
path: frontend/packages/db/supabase/migrations/20250424102300_add_organization_id_to_overall_review_knowledge_suggestion_mappings.sql
user: login: NoritakaIkeda
body: 📝
- Anonymous users can only read data from their organizations (useful for safe, read-only frontend access).
  - https://github.com/liam-hq/liam/blob/b0fd1edaedd86c86f4738ea7c3ea6bbf2bba094f/frontend/apps/app/features/migrations/pages/MigrationDetailPage/MigrationDetailPage.tsx#L178
- Service role can only insert data, useful for webhook-like operations or background tasks that don't require read access.
  - https://github.com/liam-hq/liam/blob/b0fd1edaedd86c86f4738ea7c3ea6bbf2bba094f/frontend/packages/jobs/src/functions/processCreateKnowledgeSuggestion.ts#L131
  
If you'd like to confirm where this table is used, you can search for:

```js
.from('overall_review_knowledge_suggestion_mappings')
```
created_at: 2025-04-25T09:15:08Z
author_association: MEMBER
path: frontend/packages/db/src/types/supabase-overrides/overall_review_knowledge_suggestion_mappings.ts
user: login: hoshinotsuyoshi
body: 👀  👍  ref. https://github.com/liam-hq/liam/blob/ec4ef860d61098ebefad3ca4d169ee0226da8760/frontend/packages/db/src/types/supabase-overrides/knowledge_suggestions.ts 
created_at: 2025-04-25T11:02:11Z
author_association: MEMBER

PR comments:
user: login: changeset-bot[bot]
created_at: 2025-04-24T10:34:16Z
body: ###  ⚠️  No Changeset found

Latest commit: ec4ef860d61098ebefad3ca4d169ee0226da8760

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. **If these changes should result in a version bump, you need to add a changeset.**

<details><summary>This PR includes no changesets</summary>

  When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

</details>

[Click here to learn what changesets are, and how to add one](https://github.com/changesets/changesets/blob/main/docs/adding-a-changeset.md).

[Click here if you're a maintainer who wants to add a changeset to this PR](https://github.com/liam-hq/liam/new/devin/1745490715-add-organization-id-overall-review-knowledge-suggestion-mappings?filename=.changeset/clever-moons-look.md&value=---%0A%22%40liam-hq%2Fdb%22%3A%20patch%0A---%0A%0Afeat%3A%20add%20organization_id%20to%20overall_review_knowledge_suggestion_mappings%0A)


author_association: NONE
user: login: vercel[bot]
created_at: 2025-04-24T10:34:16Z
body: [vc]: #cL48T1EJZdBejKM+I3hLc9sqRmbyvaRwGIJflD1o9TQ=:eyJpc01vbm9yZXBvIjp0cnVlLCJ0eXBlIjoiZ2l0aHViIiwicHJvamVjdHMiOlt7Im5hbWUiOiJsaWFtLWRvY3MiLCJyb290RGlyZWN0b3J5IjoiZnJvbnRlbmQvYXBwcy9kb2NzIiwiaW5zcGVjdG9yVXJsIjoiaHR0cHM6Ly92ZXJjZWwuY29tL3JvdXRlLTA2LWNvcmUvbGlhbS1kb2NzL0NuVmE2emFvVUdON2hCcHQ3UHlnNjhCRERlY1QiLCJwcmV2aWV3VXJsIjoibGlhbS1kb2NzLWdpdC1kZXZpbi0xNzQ1NDkwNzE1LWFkZC1vcmdhbml6LWNmNzQ2ZS1yb3V0ZS0wNi1jb3JlLnZlcmNlbC5hcHAiLCJuZXh0Q29tbWl0U3RhdHVzIjoiSUdOT1JFRCIsImxpdmVGZWVkYmFjayI6eyJyZXNvbHZlZCI6MCwidW5yZXNvbHZlZCI6MCwidG90YWwiOjAsImxpbmsiOiIifX0seyJuYW1lIjoibGlhbS1lcmQtc2FtcGxlIiwicm9vdERpcmVjdG9yeSI6ImZyb250ZW5kL2FwcHMvZXJkLXNhbXBsZSIsImluc3BlY3RvclVybCI6Imh0dHBzOi8vdmVyY2VsLmNvbS9yb3V0ZS0wNi1jb3JlL2xpYW0tZXJkLXNhbXBsZS82Y2hvWnNjdnJxSnJRV0o3TW5XQ0ZjNTRNUlBYIiwicHJldmlld1VybCI6ImxpYW0tZXJkLXNhbXBsZS1naXQtZGV2aW4tMTc0NTQ5MDcxNS1hZGQtby1hMjk1MmQtcm91dGUtMDYtY29yZS52ZXJjZWwuYXBwIiwibmV4dENvbW1pdFN0YXR1cyI6IkRFUExPWUVEIiwibGl2ZUZlZWRiYWNrIjp7InJlc29sdmVkIjowLCJ1bnJlc29sdmVkIjowLCJ0b3RhbCI6MCwibGluayI6ImxpYW0tZXJkLXNhbXBsZS1naXQtZGV2aW4tMTc0NTQ5MDcxNS1hZGQtby1hMjk1MmQtcm91dGUtMDYtY29yZS52ZXJjZWwuYXBwIn19LHsibmFtZSI6ImxpYW0tYXBwIiwicm9vdERpcmVjdG9yeSI6ImZyb250ZW5kL2FwcHMvYXBwIiwiaW5zcGVjdG9yVXJsIjoiaHR0cHM6Ly92ZXJjZWwuY29tL3JvdXRlLTA2LWNvcmUvbGlhbS1hcHAvNG5UQUZnN0pYQzRmQXRUUjdjNGF4dDN5YjVOcyIsInByZXZpZXdVcmwiOiJsaWFtLWFwcC1naXQtZGV2aW4tMTc0NTQ5MDcxNS1hZGQtb3JnYW5pemEtN2MyZjQwLXJvdXRlLTA2LWNvcmUudmVyY2VsLmFwcCIsIm5leHRDb21taXRTdGF0dXMiOiJERVBMT1lFRCIsImxpdmVGZWVkYmFjayI6eyJyZXNvbHZlZCI6MCwidW5yZXNvbHZlZCI6MCwidG90YWwiOjAsImxpbmsiOiJsaWFtLWFwcC1naXQtZGV2aW4tMTc0NTQ5MDcxNS1hZGQtb3JnYW5pemEtN2MyZjQwLXJvdXRlLTA2LWNvcmUudmVyY2VsLmFwcCJ9fV19
**The latest updates on your projects**. Learn more about [Vercel for Git ↗︎](https://vercel.link/github-learn-more)

| Name | Status | Preview | Comments | Updated (UTC) |
| :--- | :----- | :------ | :------- | :------ |
| **liam-app** | ✅ Ready ([Inspect](https://vercel.com/route-06-core/liam-app/4nTAFg7JXC4fAtTR7c4axt3yb5Ns)) | [Visit Preview](https://liam-app-git-devin-1745490715-add-organiza-7c2f40-route-06-core.vercel.app) | 💬 [**Add feedback**](https://vercel.live/open-feedback/liam-app-git-devin-1745490715-add-organiza-7c2f40-route-06-core.vercel.app?via=pr-comment-feedback-link) | Apr 25, 2025 9:29am |
| **liam-erd-sample** | ✅ Ready ([Inspect](https://vercel.com/route-06-core/liam-erd-sample/6choZscvrqJrQWJ7MnWCFc54MRPX)) | [Visit Preview](https://liam-erd-sample-git-devin-1745490715-add-o-a2952d-route-06-core.vercel.app) | 💬 [**Add feedback**](https://vercel.live/open-feedback/liam-erd-sample-git-devin-1745490715-add-o-a2952d-route-06-core.vercel.app?via=pr-comment-feedback-link) | Apr 25, 2025 9:29am |

<details><summary>1 Skipped Deployment</summary>

| Name | Status | Preview | Comments | Updated (UTC) |
| :--- | :----- | :------ | :------- | :------ |
| **liam-docs** | ⬜️ Ignored ([Inspect](https://vercel.com/route-06-core/liam-docs/CnVa6zaoUGN7hBpt7Pyg68BDDecT)) | [Visit Preview](https://liam-docs-git-devin-1745490715-add-organiz-cf746e-route-06-core.vercel.app) |  | Apr 25, 2025 9:29am |
</details>




author_association: NONE
user: login: devin-ai-integration[bot]
created_at: 2025-04-24T10:34:17Z
body: ### 🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:
- Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
- Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:
- [ ] Disable automatic comment and CI monitoring

author_association: CONTRIBUTOR
user: login: liam-migration-preview[bot]
created_at: 2025-04-24T10:35:06Z
body: This change adds organization_id to overall_review_knowledge_suggestion_mappings and introduces a trigger and updated RLS policies, as well as an invite_organization_member function. A key concern is ensuring atomicity and data consistency during the migration and avoiding performance degradation when updating large tables. The changes adhere to project naming conventions and improve row-level security, enhancing overall system security.

Migration URL: https://liam-app-git-staging-route-06-core.vercel.app/app/projects/9d777f64-400a-42f3-a60e-98a59fc97279/ref/devin%2F1745490715-add-organization-id-overall-review-knowledge-suggestion-mappings/migrations/70ac7e5e-4802-4b14-bf29-1d3456b00b17

ER Diagram:
- View ERD for frontend/packages/db/schema/schema.sql: https://liam-app-git-staging-route-06-core.vercel.app/app/projects/9d777f64-400a-42f3-a60e-98a59fc97279/ref/devin%2F1745490715-add-organization-id-overall-review-knowledge-suggestion-mappings/schema/frontend/packages/db/schema/schema.sql
author_association: NONE
user: login: liam-migration[bot]
created_at: 2025-04-24T10:35:20Z
body: This migration adds an organization_id column with a new trigger and updated RLS policies to overall_review_knowledge_suggestion_mappings. The use of LIMIT 1 in the update and inconsistent trigger naming raise concerns about migration safety, data integrity, and performance. Overall, the change adheres to project conventions and enhances security, though clarifications on update expectations would strengthen confidence in the implementation.

Migration URL: https://liam-erd-web.vercel.app/app/projects/284f1bca-2633-4a93-9567-7bc98ab298f7/ref/devin%2F1745490715-add-organization-id-overall-review-knowledge-suggestion-mappings/migrations/af54f6ea-d435-4fac-87fd-d401ad870595

ER Diagram:
- View ERD for frontend/packages/db/schema/schema.sql: https://liam-erd-web.vercel.app/app/projects/284f1bca-2633-4a93-9567-7bc98ab298f7/ref/devin%2F1745490715-add-organization-id-overall-review-knowledge-suggestion-mappings/schema/frontend/packages/db/schema/schema.sql
author_association: CONTRIBUTOR
user: login: liam-migration-preview[bot]
created_at: 2025-04-25T08:48:23Z
body: This migration adds an organization_id column along with a trigger and updated RLS policies for the overall_review_knowledge_suggestion_mappings table. Naming inconsistencies in the trigger function and potential performance overhead from the update query raise some concerns. Overall, the change enhances security and consistency, and addressing these questions will further strengthen the implementation.

Migration URL: https://liam-app-git-staging-route-06-core.vercel.app/app/projects/9d777f64-400a-42f3-a60e-98a59fc97279/ref/devin%2F1745490715-add-organization-id-overall-review-knowledge-suggestion-mappings/migrations/278e6269-f207-45e8-99ab-9136d00fac93

ER Diagram:
- View ERD for frontend/packages/db/schema/schema.sql: https://liam-app-git-staging-route-06-core.vercel.app/app/projects/9d777f64-400a-42f3-a60e-98a59fc97279/ref/devin%2F1745490715-add-organization-id-overall-review-knowledge-suggestion-mappings/schema/frontend/packages/db/schema/schema.sql
author_association: NONE
user: login: supabase[bot]
created_at: 2025-04-25T08:55:41Z
body: [supa]:eofbhnhvaszctkuatfja
**Updates to [Preview Branch (devin/1745490715-add-organization-id-overall-review-knowledge-suggestion-mappings) ↗︎](https://supabase.com/dashboard/project/eofbhnhvaszctkuatfja)**

| Deployments | Status                      | Updated                   |
| ----------- | --------------------------- | ------------------------- |
| Database    | ✅ | Fri, 25 Apr 2025 09:21:22 UTC |
| Services    | ✅  | Fri, 25 Apr 2025 09:21:22 UTC  |
| APIs        | ✅      | Fri, 25 Apr 2025 09:21:22 UTC      |

Tasks are run on every commit but only new migration files are pushed.
Close and reopen this PR if you want to apply changes from existing seed or migration files.

| Tasks          | Status                       | Updated                    |
| -------------- | ---------------------------- | -------------------------- |
| Configurations | ✅ | Fri, 25 Apr 2025 09:21:22 UTC |
| Migrations     | ✅ | Fri, 25 Apr 2025 09:21:22 UTC |
| Seeding        | ✅   | Fri, 25 Apr 2025 09:21:22 UTC   |
| Edge Functions | ✅  | Fri, 25 Apr 2025 09:21:22 UTC  |

<hr/>




View logs for this [Workflow Run ↗︎](https://supabase.com/dashboard/project/eofbhnhvaszctkuatfja/branches).
Learn more about [Supabase for Git ↗︎](https://supabase.com/docs/guides/platform/branching).

author_association: NONE
user: login: qodo-free-for-open-source-projects[bot]
created_at: 2025-04-25T09:18:43Z
body: ## CI Feedback 🧐

A test triggered by this PR failed. Here is an AI-generated analysis of the failure:

<table><tr><td>

**Action:** frontend-ci</td></tr>
<tr><td>

**Failed stage:** [Check for diff in generated types and schema.sql](https://github.com/liam-hq/liam/actions/runs/14661164520/job/41145773758) [❌]

</td></tr>
<tr><td>

**Failure summary:**

The action failed because the generated types and schema.sql files differ from the committed files, <br>as indicated in line 1763: "Generated types and schema.sql differ from committed files."<br> <br> The log shows differences in SQL policies related to overall_review_knowledge_suggestion_mappings <br>table. Specifically, lines 1751-1755 and 1757-1761 show that several service_role policies for this <br>table are being removed in the generated schema compared to the committed version.<br>

</td></tr>
<tr><td>

<details><summary>Relevant error logs:</summary>


```yaml
1:  ##[group]Operating System
2:  Ubuntu
...

155:  ##[group]Run pnpm install --frozen-lockfile --prefer-offline
156:  [36;1mpnpm install --frozen-lockfile --prefer-offline[0m
157:  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
158:  env:
159:  PNPM_HOME: /home/runner/setup-pnpm/node_modules/.bin
160:  ##[endgroup]
161:  Scope: all 17 workspace projects
162:  Lockfile is up to date, resolution step is skipped
163:  Progress: resolved 1, reused 0, downloaded 0, added 0
164:  Packages: +1566
165:  ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
166:  Progress: resolved 1566, reused 1342, downloaded 0, added 0
167:  Progress: resolved 1566, reused 1561, downloaded 0, added 579
168:  Progress: resolved 1566, reused 1561, downloaded 0, added 1445
169:  Progress: resolved 1566, reused 1561, downloaded 0, added 1566, done
170:  WARN  Failed to create bin at /home/runner/work/liam/liam/frontend/apps/erd-sample/node_modules/.bin/liam. ENOENT: no such file or directory, open '/home/runner/work/liam/liam/frontend/packages/cli/dist-cli/bin/cli.js'
171:  devDependencies:
...

184:  │                                                                              │
185:  │   Ignored build scripts: @biomejs/biome, @bundled-es-modules/glob,           │
186:  │   @depot/cli, @prisma/client, @prisma/engines, @sentry/cli, core-js-pure,    │
187:  │   esbuild, protobufjs, sharp, style-dictionary.                              │
188:  │   Run "pnpm approve-builds" to pick which dependencies should be allowed     │
189:  │   to run scripts.                                                            │
190:  │                                                                              │
191:  ╰──────────────────────────────────────────────────────────────────────────────╯
192:  frontend/apps/docs postinstall$ fumadocs-mdx
193:  frontend/packages/jobs postinstall$ cp ../db-structure/node_modules/@ruby/prism/src/prism.wasm prism.wasm
194:  frontend/packages/jobs postinstall: Done
195:  frontend/apps/docs postinstall: [MDX] types generated
196:  frontend/apps/docs postinstall: Done
197:  frontend/apps/app postinstall$ cp ../../packages/db-structure/node_modules/@ruby/prism/src/prism.wasm prism.wasm
198:  frontend/apps/app postinstall: Done
199:  WARN  Failed to create bin at /home/runner/work/liam/liam/frontend/apps/erd-sample/node_modules/.bin/liam. ENOENT: no such file or directory, open '/home/runner/work/liam/liam/frontend/apps/erd-sample/node_modules/@liam-hq/cli/dist-cli/bin/cli.js'
200:  Done in 5.5s using pnpm v10.8.1
...

616:  36466221e163: Verifying Checksum
617:  36466221e163: Download complete
618:  6dce3b49cfe6: Pull complete
619:  3cd949345fce: Pull complete
620:  0355fee61241: Pull complete
621:  0c0938cbe80b: Pull complete
622:  6ee86da401ed: Pull complete
623:  67383e6273a2: Pull complete
624:  e75a1d4ede51: Pull complete
625:  e0a5f96a9640: Pull complete
626:  4f4fb700ef54: Pull complete
627:  36466221e163: Pull complete
628:  Digest: sha256:84d0cda731e1fe43c24531003660c7f5e82c460b80b48493041701381ec0eeee
629:  Status: Downloaded newer image for public.ecr.aws/supabase/logflare:1.12.0
630:  0.28.1-alpine: Pulling from supabase/vector
631:  failed to display json stream: toomanyrequests: Rate exceeded
632:  Retrying after 4s: public.ecr.aws/supabase/vector:0.28.1-alpine
...

948:  ##[endgroup]
949:  ##[group]@liam-hq/erd-core:gen
950:  cache miss, executing 13b77f17012f2d10
951:  > @liam-hq/erd-core@0.1.7 gen /home/runner/work/liam/liam/frontend/packages/erd-core
952:  > concurrently "pnpm:gen:*"
953:  [css] 
954:  [css] > @liam-hq/erd-core@0.1.7 gen:css /home/runner/work/liam/liam/frontend/packages/erd-core
955:  [css] > tcm src
956:  [css] 
957:  [css] Wrote /home/runner/work/liam/liam/frontend/packages/erd-core/src/styles/variables.css.d.ts
958:  [css] Wrote /home/runner/work/liam/liam/frontend/packages/erd-core/src/features/erd/components/ERDContent/ERDContent.module.css.d.ts
959:  [css] Wrote /home/runner/work/liam/liam/frontend/packages/erd-core/src/features/erd/components/ERDRenderer/ERDRenderer.module.css.d.ts
960:  [css] Wrote /home/runner/work/liam/liam/frontend/packages/erd-core/src/features/erd/components/ERDRenderer/Toolbar/DesktopToolbar.module.css.d.ts
961:  [css] Wrote /home/runner/work/liam/liam/frontend/packages/erd-core/src/features/erd/components/ERDRenderer/TableDetailDrawer/TableDetailDrawer.module.css.d.ts
962:  [css] Wrote /home/runner/work/liam/liam/frontend/packages/erd-core/src/features/erd/components/ERDRenderer/RelationshipEdgeParticleMarker/RelationshipEdgeParticleMarker.module.css.d.ts
963:  [css] Wrote /home/runner/work/liam/liam/frontend/packages/erd-core/src/features/erd/components/ERDRenderer/ErrorDisplay/NetworkErrorDisplay.module.css.d.ts
964:  [css] Wrote /home/runner/work/liam/liam/frontend/packages/erd-core/src/features/erd/components/ERDRenderer/ErrorDisplay/ParseErrorDisplay.module.css.d.ts
965:  [css] Wrote /home/runner/work/liam/liam/frontend/packages/erd-core/src/features/erd/components/ERDRenderer/LeftPane/LeftPane.module.css.d.ts
966:  [css] Wrote /home/runner/work/liam/liam/frontend/packages/erd-core/src/features/erd/components/ERDRenderer/ErrorDisplay/ErrorDisplay.module.css.d.ts
967:  [css] Wrote /home/runner/work/liam/liam/frontend/packages/erd-core/src/features/erd/components/ERDRenderer/AppBar/AppBar.module.css.d.ts
...

1134:  [22m[39mNo schema path found for project 100: {"code":"22P02","details":null,"hint":null,"message":"invalid input syntax for type uuid: \"100\""}
1135:  [32m✓[39m app/api/webhook/github/utils/__tests__/checkSchemaChanges.test.ts [2m([22m[2m3 tests[22m[2m | [22m[33m1 skipped[39m[2m)[22m[32m 150[2mms[22m[39m
1136:  [32m✓[39m app/(app)/app/projects/[projectId]/ref/[branchOrCommit]/docs/[...docFilePath]/getProjectRepository.test.ts [2m([22m[2m2 tests[22m[2m | [22m[33m1 skipped[39m[2m)[22m[32m 94[2mms[22m[39m
1137:  [32m✓[39m app/(app)/app/projects/[projectId]/ref/[branchOrCommit]/docs/getDocFilePaths.test.ts [2m([22m[2m2 tests[22m[2m | [22m[33m1 skipped[39m[2m)[22m[32m 98[2mms[22m[39m
1138:  [2m[90m↓[39m[22m features/projects/pages/ProjectsPage/getProjects.test.ts [2m([22m[2m1 test[22m[2m | [22m[33m1 skipped[39m[2m)[22m
1139:  [2m Test Files [22m [1m[32m3 passed[39m[22m[2m | [22m[33m1 skipped[39m[90m (4)[39m
1140:  [2m      Tests [22m [1m[32m4 passed[39m[22m[2m | [22m[33m4 skipped[39m[90m (8)[39m
1141:  [2m   Start at [22m 09:17:40
1142:  [2m   Duration [22m 2.56s[2m (transform 662ms, setup 223ms, collect 2.17s, tests 342ms, environment 1ms, prepare 1.25s)[22m
1143:  ##[endgroup]
1144:  ##[group]@liam-hq/prompt-test:test
1145:  cache miss, executing c87e38af0bbe06e8
1146:  > @liam-hq/prompt-test@0.1.0 test /home/runner/work/liam/liam/frontend/packages/prompt-test
1147:  > tsx src/index.ts
1148:  Langfuse secret key was not passed to constructor or not set as 'LANGFUSE_SECRET_KEY' environment variable. No observability data will be sent to Langfuse.
1149:  [Langfuse SDK] 401: Unauthorized. Please check your public/private host settings. Refer to our installation and setup guide: https://langfuse.com/docs/sdk/typescript/guide for details on SDK configuration. Make sure to keep your SDK updated, refer to https://www.npmjs.com/package/langfuse for details. Error details: LangfuseFetchHttpError: HTTP error while fetching Langfuse: 401 and body: {"message":"Invalid authorization header"}
1150:  [Langfuse SDK] 401: Unauthorized. Please check your public/private host settings. Refer to our installation and setup guide: https://langfuse.com/docs/sdk/typescript/guide for details on SDK configuration. Make sure to keep your SDK updated, refer to https://www.npmjs.com/package/langfuse for details. Error details: LangfuseFetchHttpError: HTTP error while fetching Langfuse: 401 and body: {"message":"Invalid authorization header"}
1151:  TypeError: itemsResponse.data is not iterable (cannot read property undefined)
1152:  at Langfuse.getDataset (/home/runner/work/liam/liam/node_modules/.pnpm/langfuse-core@3.37.2/node_modules/langfuse-core/src/index.ts:1432:13)
...

1160:  [1m[46m RUN [49m[22m [36mv3.1.2 [39m[90m/home/runner/work/liam/liam/frontend/packages/db-structure[39m
1161:  [32m✓[39m src/parser/tbls/index.test.ts [2m([22m[2m20 tests[22m[2m)[22m[32m 59[2mms[22m[39m
1162:  (node:7713) ExperimentalWarning: WASI is an experimental feature and might change at any time
1163:  (Use `node --trace-warnings ...` to show where the warning was created)
1164:  [32m✓[39m src/parser/prisma/index.test.ts [2m([22m[2m21 tests[22m[2m)[22m[33m 481[2mms[22m[39m
1165:  [32m✓[39m src/parser/schemarb/index.test.ts [2m([22m[2m18 tests[22m[2m)[22m[33m 589[2mms[22m[39m
1166:  [32m✓[39m src/schema/overrideSchema.test.ts [2m([22m[2m6 tests[22m[2m)[22m[32m 23[2mms[22m[39m
1167:  [32m✓[39m src/parser/sql/postgresql/processSQLInChunks.test.ts [2m([22m[2m6 tests[22m[2m)[22m[32m 20[2mms[22m[39m
1168:  [32m✓[39m src/parser/tbls/schema.generated.test.ts [2m([22m[2m5 tests[22m[2m)[22m[32m 62[2mms[22m[39m
1169:  [32m✓[39m src/parser/schemarb/singularize.test.ts [2m([22m[2m18 tests[22m[2m)[22m[32m 17[2mms[22m[39m
1170:  [32m✓[39m src/parser/supportedFormat/detectFormat.test.ts [2m([22m[2m10 tests[22m[2m)[22m[32m 16[2mms[22m[39m
1171:  (node:7980) ExperimentalWarning: WASI is an experimental feature and might change at any time
1172:  (Use `node --trace-warnings ...` to show where the warning was created)
1173:  [32m✓[39m src/parser/index.test.ts [2m([22m[2m2 tests[22m[2m)[22m[33m 352[2mms[22m[39m
1174:  [32m✓[39m src/parser/sql/postgresql/index.test.ts [2m([22m[2m19 tests[22m[2m | [22m[33m1 skipped[39m[2m)[22m[33m 43649[2mms[22m[39m
1175:  [33m[2m✓[22m[39m processor[2m > [22mLong "create table" statement (exceeds 500 lines, surpassing CHUNK_SIZE)[2m > [22mparses without errors [33m 21584[2mms[22m[39m
1176:  [33m[2m✓[22m[39m processor[2m > [22mLong "create function" statement (exceeds 500 lines, surpassing CHUNK_SIZE)[2m > [22mparses without errors [33m 21259[2mms[22m[39m
1177:  [2m Test Files [22m [1m[32m10 passed[39m[22m[90m (10)[39m
...

1207:  [vite]  * [new branch]        add-playwright           -> origin/add-playwright
1208:  [vite]  * [new branch]        add-schema-meta          -> origin/add-schema-meta
1209:  [vite]  * [new branch]        add_script_to_gen_schema -> origin/add_script_to_gen_schema
1210:  [vite]  * [new branch]        add_script_to_gen_schema_json -> origin/add_script_to_gen_schema_json
1211:  [vite]  * [new branch]        add_test_table           -> origin/add_test_table
1212:  [vite]  * [new branch]        avoid-cp-for-windows-actions -> origin/avoid-cp-for-windows-actions
1213:  [vite]  * [new branch]        avoid-semicolon-logic-2  -> origin/avoid-semicolon-logic-2
1214:  [vite]  * [new branch]        avoid-semicolon-logic-test -> origin/avoid-semicolon-logic-test
1215:  [vite]  * [new branch]        before-promptfoo-experiment -> origin/before-promptfoo-experiment
1216:  [vite]  * [new branch]        changeset-invest1        -> origin/changeset-invest1
1217:  [vite]  * [new branch]        changeset-invest3        -> origin/changeset-invest3
1218:  [vite]  * [new branch]        changeset-release/changeset-invest1 -> origin/changeset-release/changeset-invest1
1219:  [vite]  * [new branch]        check-github-action      -> origin/check-github-action
1220:  [vite]  * [new branch]        chore/install-renovate   -> origin/chore/install-renovate
1221:  [vite]  * [new branch]        cli-schema-json-for-local -> origin/cli-schema-json-for-local
1222:  [vite]  * [new branch]        console-error-1-draft    -> origin/console-error-1-draft
1223:  [vite]  * [new branch]        delete-docs-vercel-deploy-erd-yml -> origin/delete-docs-vercel-deploy-erd-yml
1224:  [vite]  * [new branch]        devin/1738820244-add-init-command-tests -> origin/devin/1738820244-add-init-command-tests
1225:  [vite]  * [new branch]        devin/1738828298-add-multiline-comment-support -> origin/devin/1738828298-add-multiline-comment-support
1226:  [vite]  * [new branch]        devin/1739501885-improve-navigation-test-waits -> origin/devin/1739501885-improve-navigation-test-waits
1227:  [vite]  * [new branch]        devin/1740113652-update-changeset-docs -> origin/devin/1740113652-update-changeset-docs
1228:  [vite]  * [new branch]        devin/1741661851-optimize-github-config-validation -> origin/devin/1741661851-optimize-github-config-validation
1229:  [vite]  * [new branch]        devin/1741663537-github-env-validation-at-boot -> origin/devin/1741663537-github-env-validation-at-boot
1230:  [vite]  * [new branch]        devin/1741825670-postgresql-parser-test -> origin/devin/1741825670-postgresql-parser-test
1231:  [vite]  * [new branch]        devin/1743062004-investigate-issue-1005 -> origin/devin/1743062004-investigate-issue-1005
1232:  [vite]  * [new branch]        devin/1744202861-add-organization-ui -> origin/devin/1744202861-add-organization-ui
1233:  [vite]  * [new branch]        devin/1745381489-fix-supabase-auth-security -> origin/devin/1745381489-fix-supabase-auth-security
1234:  [vite]  * [new branch]        devin/1745404272-fix-appbar-hydration-error -> origin/devin/1745404272-fix-appbar-hydration-error
1235:  [vite]  * [new branch]        devin/1745490715-add-organization-id-overall-review-knowledge-suggestion-mappings -> origin/devin/1745490715-add-organization-id-overall-review-knowledge-suggestion-mappings
...

1238:  [vite]  * [new branch]        devin/1745494685-add-organization-id-to-migrations -> origin/devin/1745494685-add-organization-id-to-migrations
1239:  [vite]  * [new branch]        devin/1745494737-add-organization-id-schema-file-paths -> origin/devin/1745494737-add-organization-id-schema-file-paths
1240:  [vite]  * [new branch]        devin/1745497726-decouple-overall-reviews-from-github -> origin/devin/1745497726-decouple-overall-reviews-from-github
1241:  [vite]  * [new branch]        devin/1745498739-add-organization-id-migration-pull-request-mappings -> origin/devin/1745498739-add-organization-id-migration-pull-request-mappings
1242:  [vite]  * [new branch]        devin/1745498835-add-organization-id -> origin/devin/1745498835-add-organization-id
1243:  [vite]  * [new branch]        devin/1745498969-add-organization-id-mapping -> origin/devin/1745498969-add-organization-id-mapping
1244:  [vite]  * [new branch]        devin/1745499053-add-organization-id-review-feedback-knowledge-suggestion-mappings -> origin/devin/1745499053-add-organization-id-review-feedback-knowledge-suggestion-mappings
1245:  [vite]  * [new branch]        devin/1745548711-remove-try-catch -> origin/devin/1745548711-remove-try-catch
1246:  [vite]  * [new branch]        devin/1745550064-remove-jobs-knip-ignores -> origin/devin/1745550064-remove-jobs-knip-ignores
1247:  [vite]  * [new branch]        emu-pr-1033-base         -> origin/emu-pr-1033-base
1248:  [vite]  * [new branch]        emu-pr-1033-feature      -> origin/emu-pr-1033-feature
1249:  [vite]  * [new branch]        emu-pr-1081-base         -> origin/emu-pr-1081-base
1250:  [vite]  * [new branch]        emu-pr-1081-feature      -> origin/emu-pr-1081-feature
1251:  [vite]  * [new branch]        enhance-login-with-return-to -> origin/enhance-login-with-return-to
1252:  [vite]  * [new branch]        enhance-the-highlighting-of-related-table-nodes-when-hovering-usememo-1 -> origin/enhance-the-highlighting-of-related-table-nodes-when-hovering-usememo-1
1253:  [vite]  * [new branch]        error-message-erd-network-error -> origin/error-message-erd-network-error
1254:  [vite]  * [new branch]        feat-related-posts       -> origin/feat-related-posts
...

1286:  [vite]  * [new branch]        primary-key-icon-2       -> origin/primary-key-icon-2
1287:  [vite]  * [new branch]        prompt-test-package      -> origin/prompt-test-package
1288:  [vite]  * [new branch]        promptfoo-go-1           -> origin/promptfoo-go-1
1289:  [vite]  * [new branch]        reduce-set-node-calling-chance-3 -> origin/reduce-set-node-calling-chance-3
1290:  [vite]  * [new branch]        refactor-installation-selector -> origin/refactor-installation-selector
1291:  [vite]  * [new branch]        refactor-to-testcases    -> origin/refactor-to-testcases
1292:  [vite]  * [new branch]        refactor_edge_cardinality_by_using_custom_mark -> origin/refactor_edge_cardinality_by_using_custom_mark
1293:  [vite]  * [new branch]        refactor_hidden_node_handle -> origin/refactor_hidden_node_handle
1294:  [vite]  * [new branch]        release-debug-branch     -> origin/release-debug-branch
1295:  [vite]  * [new branch]        ren-a-table              -> origin/ren-a-table
1296:  [vite]  * [new branch]        renovate-pnpm-10.x-2     -> origin/renovate-pnpm-10.x-2
1297:  [vite]  * [new branch]        renovate/major-react-monorepo -> origin/renovate/major-react-monorepo
1298:  [vite]  * [new branch]        renovate/node-22.x       -> origin/renovate/node-22.x
1299:  [vite]  * [new branch]        renovate/playwright-monorepo -> origin/renovate/playwright-monorepo
1300:  [vite]  * [new branch]        renovate/pnpm-10.x       -> origin/renovate/pnpm-10.x
1301:  [vite]  * [new branch]        revert-435-error-message-erd -> origin/revert-435-error-message-erd
1302:  [vite]  * [new branch]        review-suggestion-patch-suggestion-2 -> origin/review-suggestion-patch-suggestion-2
...

1438:  * [new branch]        add-playwright           -> origin/add-playwright
1439:  * [new branch]        add-schema-meta          -> origin/add-schema-meta
1440:  * [new branch]        add_script_to_gen_schema -> origin/add_script_to_gen_schema
1441:  * [new branch]        add_script_to_gen_schema_json -> origin/add_script_to_gen_schema_json
1442:  * [new branch]        add_test_table           -> origin/add_test_table
1443:  * [new branch]        avoid-cp-for-windows-actions -> origin/avoid-cp-for-windows-actions
1444:  * [new branch]        avoid-semicolon-logic-2  -> origin/avoid-semicolon-logic-2
1445:  * [new branch]        avoid-semicolon-logic-test -> origin/avoid-semicolon-logic-test
1446:  * [new branch]        before-promptfoo-experiment -> origin/before-promptfoo-experiment
1447:  * [new branch]        changeset-invest1        -> origin/changeset-invest1
1448:  * [new branch]        changeset-invest3        -> origin/changeset-invest3
1449:  * [new branch]        changeset-release/changeset-invest1 -> origin/changeset-release/changeset-invest1
1450:  * [new branch]        check-github-action      -> origin/check-github-action
1451:  * [new branch]        chore/install-renovate   -> origin/chore/install-renovate
1452:  * [new branch]        cli-schema-json-for-local -> origin/cli-schema-json-for-local
1453:  * [new branch]        console-error-1-draft    -> origin/console-error-1-draft
1454:  * [new branch]        delete-docs-vercel-deploy-erd-yml -> origin/delete-docs-vercel-deploy-erd-yml
1455:  * [new branch]        devin/1738820244-add-init-command-tests -> origin/devin/1738820244-add-init-command-tests
1456:  * [new branch]        devin/1738828298-add-multiline-comment-support -> origin/devin/1738828298-add-multiline-comment-support
1457:  * [new branch]        devin/1739501885-improve-navigation-test-waits -> origin/devin/1739501885-improve-navigation-test-waits
1458:  * [new branch]        devin/1740113652-update-changeset-docs -> origin/devin/1740113652-update-changeset-docs
1459:  * [new branch]        devin/1741661851-optimize-github-config-validation -> origin/devin/1741661851-optimize-github-config-validation
1460:  * [new branch]        devin/1741663537-github-env-validation-at-boot -> origin/devin/1741663537-github-env-validation-at-boot
1461:  * [new branch]        devin/1741825670-postgresql-parser-test -> origin/devin/1741825670-postgresql-parser-test
1462:  * [new branch]        devin/1743062004-investigate-issue-1005 -> origin/devin/1743062004-investigate-issue-1005
1463:  * [new branch]        devin/1744202861-add-organization-ui -> origin/devin/1744202861-add-organization-ui
1464:  * [new branch]        devin/1745381489-fix-supabase-auth-security -> origin/devin/1745381489-fix-supabase-auth-security
1465:  * [new branch]        devin/1745404272-fix-appbar-hydration-error -> origin/devin/1745404272-fix-appbar-hydration-error
1466:  * [new branch]        devin/1745490715-add-organization-id-overall-review-knowledge-suggestion-mappings -> origin/devin/1745490715-add-organization-id-overall-review-knowledge-suggestion-mappings
...

1469:  * [new branch]        devin/1745494685-add-organization-id-to-migrations -> origin/devin/1745494685-add-organization-id-to-migrations
1470:  * [new branch]        devin/1745494737-add-organization-id-schema-file-paths -> origin/devin/1745494737-add-organization-id-schema-file-paths
1471:  * [new branch]        devin/1745497726-decouple-overall-reviews-from-github -> origin/devin/1745497726-decouple-overall-reviews-from-github
1472:  * [new branch]        devin/1745498739-add-organization-id-migration-pull-request-mappings -> origin/devin/1745498739-add-organization-id-migration-pull-request-mappings
1473:  * [new branch]        devin/1745498835-add-organization-id -> origin/devin/1745498835-add-organization-id
1474:  * [new branch]        devin/1745498969-add-organization-id-mapping -> origin/devin/1745498969-add-organization-id-mapping
1475:  * [new branch]        devin/1745499053-add-organization-id-review-feedback-knowledge-suggestion-mappings -> origin/devin/1745499053-add-organization-id-review-feedback-knowledge-suggestion-mappings
1476:  * [new branch]        devin/1745548711-remove-try-catch -> origin/devin/1745548711-remove-try-catch
1477:  * [new branch]        devin/1745550064-remove-jobs-knip-ignores -> origin/devin/1745550064-remove-jobs-knip-ignores
1478:  * [new branch]        emu-pr-1033-base         -> origin/emu-pr-1033-base
1479:  * [new branch]        emu-pr-1033-feature      -> origin/emu-pr-1033-feature
1480:  * [new branch]        emu-pr-1081-base         -> origin/emu-pr-1081-base
1481:  * [new branch]        emu-pr-1081-feature      -> origin/emu-pr-1081-feature
1482:  * [new branch]        enhance-login-with-return-to -> origin/enhance-login-with-return-to
1483:  * [new branch]        enhance-the-highlighting-of-related-table-nodes-when-hovering-usememo-1 -> origin/enhance-the-highlighting-of-related-table-nodes-when-hovering-usememo-1
1484:  * [new branch]        error-message-erd-network-error -> origin/error-message-erd-network-error
1485:  * [new branch]        feat-related-posts       -> origin/feat-related-posts
...

1517:  * [new branch]        primary-key-icon-2       -> origin/primary-key-icon-2
1518:  * [new branch]        prompt-test-package      -> origin/prompt-test-package
1519:  * [new branch]        promptfoo-go-1           -> origin/promptfoo-go-1
1520:  * [new branch]        reduce-set-node-calling-chance-3 -> origin/reduce-set-node-calling-chance-3
1521:  * [new branch]        refactor-installation-selector -> origin/refactor-installation-selector
1522:  * [new branch]        refactor-to-testcases    -> origin/refactor-to-testcases
1523:  * [new branch]        refactor_edge_cardinality_by_using_custom_mark -> origin/refactor_edge_cardinality_by_using_custom_mark
1524:  * [new branch]        refactor_hidden_node_handle -> origin/refactor_hidden_node_handle
1525:  * [new branch]        release-debug-branch     -> origin/release-debug-branch
1526:  * [new branch]        ren-a-table              -> origin/ren-a-table
1527:  * [new branch]        renovate-pnpm-10.x-2     -> origin/renovate-pnpm-10.x-2
1528:  * [new branch]        renovate/major-react-monorepo -> origin/renovate/major-react-monorepo
1529:  * [new branch]        renovate/node-22.x       -> origin/renovate/node-22.x
1530:  * [new branch]        renovate/playwright-monorepo -> origin/renovate/playwright-monorepo
1531:  * [new branch]        renovate/pnpm-10.x       -> origin/renovate/pnpm-10.x
1532:  * [new branch]        revert-435-error-message-erd -> origin/revert-435-error-message-erd
1533:  * [new branch]        review-suggestion-patch-suggestion-2 -> origin/review-suggestion-patch-suggestion-2
...

1630:  * [new tag]           @liam-hq/ui@0.0.15       -> @liam-hq/ui@0.0.15
1631:  * [new tag]           @liam-hq/ui@0.0.16       -> @liam-hq/ui@0.0.16
1632:  [1m[46m RUN [49m[22m [36mv3.1.2 [39m[90m/home/runner/work/liam/liam/frontend/packages/cli[39m
1633:  [32m✓[39m src/cli/erdCommand/getInputContent.test.ts [2m([22m[2m8 tests[22m[2m)[22m[32m 137[2mms[22m[39m
1634:  (node:9020) ExperimentalWarning: WASI is an experimental feature and might change at any time
1635:  (Use `node --trace-warnings ...` to show where the warning was created)
1636:  (node:9106) ExperimentalWarning: WASI is an experimental feature and might change at any time
1637:  (Use `node --trace-warnings ...` to show where the warning was created)
1638:  [32m✓[39m src/cli/erdCommand/runPreprocess.test.ts [2m([22m[2m4 tests[22m[2m)[22m[33m 572[2mms[22m[39m
1639:  [33m[2m✓[22m[39m runPreprocess[2m > [22mshould create schema.json with the content in 'postgres' format [33m 319[2mms[22m[39m
1640:  [32m✓[39m src/cli/index.test.ts [2m([22m[2m3 tests[22m[2m)[22m[32m 12[2mms[22m[39m
1641:  (node:9275) ExperimentalWarning: WASI is an experimental feature and might change at any time
1642:  (Use `node --trace-warnings ...` to show where the warning was created)
1643:  [32m✓[39m src/cli/erdCommand/index.test.ts [2m([22m[2m3 tests[22m[2m)[22m[32m 19[2mms[22m[39m
1644:  [32m✓[39m src/cli/smoke.test.ts [2m([22m[2m2 tests[22m[2m)[22m[33m 40845[2mms[22m[39m
1645:  [33m[2m✓[22m[39m CLI Smoke Test[2m > [22mshould run the CLI command without errors: `erd` [33m 2986[2mms[22m[39m
1646:  [33m[2m✓[22m[39m CLI Smoke Test[2m > [22mshould run the CLI command without errors: `erd build` [33m 4525[2mms[22m[39m
1647:  [2m Test Files [22m [1m[32m5 passed[39m[22m[90m (5)[39m
...

1749:  -
1750:  CREATE POLICY "service_role_can_delete_all_projects" ON "public"."projects" FOR DELETE TO "service_role" USING (true);
1751:  @@ -1171,10 +1135,6 @@ CREATE POLICY "service_role_can_select_all_knowledge_suggestions" ON "public"."k
1752:  -CREATE POLICY "service_role_can_select_all_overall_review_knowledge_suggestion" ON "public"."overall_review_knowledge_suggestion_mappings" FOR SELECT TO "service_role" USING (true);
1753:  -
1754:  -
1755:  -
1756:  CREATE POLICY "service_role_can_select_all_projects" ON "public"."projects" FOR SELECT TO "service_role" USING (true);
1757:  @@ -1187,10 +1147,6 @@ CREATE POLICY "service_role_can_update_all_knowledge_suggestions" ON "public"."k
1758:  -CREATE POLICY "service_role_can_update_all_overall_review_knowledge_suggestion" ON "public"."overall_review_knowledge_suggestion_mappings" FOR UPDATE TO "service_role" USING (true) WITH CHECK (true);
1759:  -
1760:  -
1761:  -
1762:  CREATE POLICY "service_role_can_update_all_projects" ON "public"."projects" FOR UPDATE TO "service_role" USING (true) WITH CHECK (true);
1763:  Generated types and schema.sql differ from committed files.
1764:  ##[error]Process completed with exit code 1.
1765:  Post job cleanup.

```
</details></td></tr></table>
author_association: CONTRIBUTOR
user: login: qodo-free-for-open-source-projects[bot]
created_at: 2025-04-25T09:23:25Z
body: ## PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

<table>
<tr><td>⏱️&nbsp;<strong>Estimated effort to review</strong>: 2 🔵🔵⚪⚪⚪</td></tr>
<tr><td>🧪&nbsp;<strong>No relevant tests</strong></td></tr>
<tr><td>🔒&nbsp;<strong>No security concerns identified</strong></td></tr>
<tr><td>⚡&nbsp;<strong>Recommended focus areas for review</strong><br><br>

<details><summary><a href='https://github.com/liam-hq/liam/pull/1489/files#diff-8cd3727af1b92e18c657a888ab2689e60803886843156b056543a52d35673dc4R21-R32'><strong>Function Name Mismatch</strong></a>

The trigger function name in the migration file doesn't match the one in schema.sql. The migration uses 'set_overall_review_knowledge_suggestion_mappings_organization_id' while schema.sql uses the truncated 'set_overall_review_knowledge_suggestion_mappings_organization_i'.
</summary>

```sql
CREATE OR REPLACE FUNCTION "public"."set_overall_review_knowledge_suggestion_mappings_organization_id"() RETURNS "trigger"
    LANGUAGE "plpgsql" SECURITY DEFINER
    AS $$
BEGIN
  NEW.organization_id := (
    SELECT "organization_id" 
    FROM "public"."knowledge_suggestions" 
    WHERE "id" = NEW.knowledge_suggestion_id
  );
  RETURN NEW;
END;
$$;
```

</details>

<details><summary><a href='https://github.com/liam-hq/liam/pull/1489/files#diff-8cd3727af1b92e18c657a888ab2689e60803886843156b056543a52d35673dc4R34-R37'><strong>Trigger Name Mismatch</strong></a>

The trigger name in the migration file doesn't match the one in schema.sql. The migration uses 'set_overall_review_knowledge_suggestion_mappings_organization_id_trigger' while schema.sql uses 'set_overall_review_knowledge_suggestion_mappings_organization_i'.
</summary>

```sql
CREATE TRIGGER "set_overall_review_knowledge_suggestion_mappings_organization_id_trigger"
  BEFORE INSERT OR UPDATE ON "public"."overall_review_knowledge_suggestion_mappings"
  FOR EACH ROW
  EXECUTE FUNCTION "public"."set_overall_review_knowledge_suggestion_mappings_organization_id"();
```

</details>

</td></tr>
</table>

author_association: CONTRIBUTOR
user: login: qodo-free-for-open-source-projects[bot]
created_at: 2025-04-25T09:23:40Z
body: ## PR Code Suggestions ✨

<!-- ec4ef86 -->

Explore these optional code suggestions:

<table><thead><tr><td><strong>Category</strong></td><td align=left><strong>Suggestion&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </strong></td><td align=center><strong>Impact</strong></td></tr><tbody><tr><td rowspan=1>Possible issue</td>
<td>



<details><summary>Add error handling</summary>

___


**The function should handle the case where no matching knowledge suggestion is <br>found, which could lead to NULL values for organization_id. Add error handling <br>to ensure organization_id is always set.**

[frontend/packages/db/supabase/migrations/20250424102300_add_organization_id_to_overall_review_knowledge_suggestion_mappings.sql [21-32]](https://github.com/liam-hq/liam/pull/1489/files#diff-8cd3727af1b92e18c657a888ab2689e60803886843156b056543a52d35673dc4R21-R32)

```diff
 CREATE OR REPLACE FUNCTION "public"."set_overall_review_knowledge_suggestion_mappings_organization_id"() RETURNS "trigger"
     LANGUAGE "plpgsql" SECURITY DEFINER
     AS $$
+DECLARE
+  org_id UUID;
 BEGIN
-  NEW.organization_id := (
-    SELECT "organization_id" 
-    FROM "public"."knowledge_suggestions" 
-    WHERE "id" = NEW.knowledge_suggestion_id
-  );
+  SELECT "organization_id" INTO org_id
+  FROM "public"."knowledge_suggestions" 
+  WHERE "id" = NEW.knowledge_suggestion_id;
+  
+  IF org_id IS NULL THEN
+    RAISE EXCEPTION 'No organization_id found for knowledge_suggestion_id %', NEW.knowledge_suggestion_id;
+  END IF;
+  
+  NEW.organization_id := org_id;
   RETURN NEW;
 END;
 $$;
```

- [ ] **Apply this suggestion** <!-- /improve --apply_suggestion=0 -->

<details><summary>Suggestion importance[1-10]: 7</summary>

__

Why: The suggestion adds important error handling to prevent NULL values for organization_id when no matching knowledge suggestion is found. This improves data integrity and helps with debugging by raising a specific exception with the problematic ID.


</details></details></td><td align=center>Medium

</td></tr>
<tr><td align="center" colspan="2">

- [ ] More <!-- /improve --more_suggestions=true -->

</td><td></td></tr></tbody></table>


author_association: CONTRIBUTOR
user: login: hoshinotsuyoshi
created_at: 2025-04-25T10:48:39Z
body: I'll check now
author_association: MEMBER