docs: add Supabase schema and seed instructions#309
docs: add Supabase schema and seed instructions#309shrav784 wants to merge 5 commits intoAOSSIE-Org:mainfrom
Conversation
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 14 minutes and 57 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughREADME "Data Population" updated: Supabase link changed to a plain URL; added inline SQL to enable Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@README.md`:
- Around line 210-215: The README currently seeds users in Step 3 and then runs
sql.txt in Step 4 which re-inserts the same rows without conflict handling;
update the instructions so either Step 4 runs before Step 3 or (preferably)
modify sql.txt to make the INSERT into the users table idempotent by adding ON
CONFLICT handling for the unique keys (username and email) so repeated runs
won’t fail; reference the users table and its username/email unique constraints
and the files/steps named "Step 3", "Step 4", and "sql.txt" when making the
change.
- Around line 199-207: The README CREATE TABLE public.users is missing the
is_online and last_seen columns and marks role as nullable; update the SQL in
the README to match the backend User model in Backend/app/models/models.py by
adding is_online BOOLEAN NOT NULL DEFAULT FALSE and last_seen TIMESTAMP WITH
TIME ZONE (nullable or with the same default as the model) and make role TEXT
NOT NULL (or include the same DEFAULT used in the User model), ensuring column
names, types, nullability, and defaults mirror the User model so ORM queries
won’t fail.
- Line 200: The README's SQL example uses gen_random_uuid() but doesn't mention
the pgcrypto prerequisite; update the SQL block to include a one-liner note (or
SQL command) that pgcrypto must be enabled (e.g., CREATE EXTENSION IF NOT EXISTS
pgcrypto;) before using gen_random_uuid(), and add a brief comment mentioning
pgcrypto so readers know to enable it to avoid function-not-found errors.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 95d4c02c-7111-4079-87c0-240d19986cf4
📒 Files selected for processing (1)
README.md
README.md
Outdated
| INSERT INTO public.users (username, email, role, bio) | ||
| VALUES | ||
| ('creator1', 'creator1@example.com', 'creator', 'Bio of creator1'), | ||
| ('brand1', 'brand1@example.com', 'brand', 'Bio of brand1') | ||
| ON CONFLICT (username) DO NOTHING; | ||
| ``` |
There was a problem hiding this comment.
Current step order reintroduces duplicate-key failures during onboarding.
Step 3 seeds creator1/brand1, then Step 4 runs sql.txt, which inserts the same users without conflict handling. That can fail on unique constraints (username/email) and block setup.
Proposed doc fix
-3. **Create Required Tables**
+3. **Create Required Tables**
- Run the following SQL in the Supabase SQL Editor:
@@
- -- Seed Initial Data
- INSERT INTO public.users (username, email, role, bio)
- VALUES
- ('creator1', 'creator1@example.com', 'creator', 'Bio of creator1'),
- ('brand1', 'brand1@example.com', 'brand', 'Bio of brand1')
- ON CONFLICT (username) DO NOTHING;
+ -- Create schema only (no seed here)
@@
-4. **Run the SQL Script**
+4. **Run the SQL Script (initial data)**Alternative: keep Step 3 seed, but then sql.txt must also be made idempotent (ON CONFLICT on both unique keys strategy).
Also applies to: 218-221
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@README.md` around lines 210 - 215, The README currently seeds users in Step 3
and then runs sql.txt in Step 4 which re-inserts the same rows without conflict
handling; update the instructions so either Step 4 runs before Step 3 or
(preferably) modify sql.txt to make the INSERT into the users table idempotent
by adding ON CONFLICT handling for the unique keys (username and email) so
repeated runs won’t fail; reference the users table and its username/email
unique constraints and the files/steps named "Step 3", "Step 4", and "sql.txt"
when making the change.
There was a problem hiding this comment.
Actionable comments posted: 4
♻️ Duplicate comments (1)
README.md (1)
209-209:⚠️ Potential issue | 🟡 MinorAdd DEFAULT to
last_seento match the backend model.The backend
Usermodel inBackend/app/models/models.pydefineslast_seenwithdefault=datetime.utcnow, but the documented schema omits the DEFAULT clause. This mismatch can cause inconsistency when the ORM creates records expecting a default timestamp.🔧 Proposed fix to align with backend model
- last_seen TIMESTAMP WITH TIME ZONE, + last_seen TIMESTAMP WITH TIME ZONE DEFAULT NOW(),🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@README.md` at line 209, The README schema is missing a DEFAULT for the last_seen column; update the CREATE TABLE/column definition for last_seen (referencing the User model's last_seen default=datetime.utcnow in Backend/app/models/models.py) to include a DEFAULT timestamp so the documented SQL matches the backend model (e.g., add a DEFAULT CURRENT_TIMESTAMP / equivalent to the last_seen TIMESTAMP WITH TIME ZONE definition).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@README.md`:
- Around line 195-196: Add a blank line immediately before the SQL fenced code
block (the ```sql fence) in the README so the fence is preceded by an empty line
per Markdown MD031; locate the section that currently reads "Run the following
SQL in the Supabase SQL Editor:" and insert a single blank line before the
opening ```sql fence to correct the formatting.
- Line 202: The README and DB use PostgreSQL native UUIDs but the ORM defines
id/foreign keys as Column(String, ...) with client-side uuid.uuid4(); update
models.py and chat.py to use SQLAlchemy's PostgreSQL UUID type (e.g.
UUID(as_uuid=True) from sqlalchemy.dialects.postgresql) for all primary key and
FK columns, remove client-side uuid.uuid4() defaults, and instead set
server_default to gen_random_uuid() (using sa.text or equivalent) so generation
and types match the documented schema; update any ForeignKey definitions to
reference UUID columns and ensure imports (UUID, sa.text) are added where
needed.
- Line 214: The ordered list item "4. **Run the SQL Script**" should use the
Markdown auto-numbering convention to satisfy MD029; update this list item (and
any other numbered list entries in the same sequence) to use "1." instead of
"4." so the renderer auto-numbers the steps and makes reordering easier while
keeping the visible text identical.
- Line 218: The README falsely claims the SQL initialization script includes
conflict handling; either update Backend/sql.txt to add ON CONFLICT clauses to
the INSERT statements for the unique fields (username, email) so the script
performs upserts, or edit README.md to remove/revise the sentence "The script
includes conflict handling to avoid duplicate entries" and reference that
upserts are handled only in the frontend (Onboarding.tsx) rather than in the
SQL; update whichever you choose and run a quick sanity check by re-running the
SQL to ensure repeated runs no longer error on unique constraint violations.
---
Duplicate comments:
In `@README.md`:
- Line 209: The README schema is missing a DEFAULT for the last_seen column;
update the CREATE TABLE/column definition for last_seen (referencing the User
model's last_seen default=datetime.utcnow in Backend/app/models/models.py) to
include a DEFAULT timestamp so the documented SQL matches the backend model
(e.g., add a DEFAULT CURRENT_TIMESTAMP / equivalent to the last_seen TIMESTAMP
WITH TIME ZONE definition).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: bc1a4b4f-cb33-4940-85f9-c42dcd8a9125
📒 Files selected for processing (1)
README.md
README.md
Outdated
|
|
||
| -- Create Tables (Schema) | ||
| CREATE TABLE IF NOT EXISTS public.users ( | ||
| id UUID PRIMARY KEY DEFAULT gen_random_uuid(), |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Description: Check how the backend model interacts with the id column type
# Search for UUID type handling in models and database interactions
rg -n -C3 'Column\(String.*id|UUID|gen_random_uuid' Backend/app/models/
# Check if there are any explicit type casts or UUID handling
rg -n -C3 'uuid|UUID' Backend/app/ --type pyRepository: AOSSIE-Org/InPactAI
Length of output: 16595
🏁 Script executed:
# Check the README.md file around line 202 to see the schema documentation
sed -n '190,215p' README.md | cat -nRepository: AOSSIE-Org/InPactAI
Length of output: 1006
Align backend UUID type with documented PostgreSQL schema.
The README.md documents the database schema using PostgreSQL's native UUID type with gen_random_uuid() for the id column, but the backend SQLAlchemy models use Column(String, ...) with Python's uuid.uuid4() instead. This type mismatch between the documented schema (PostgreSQL UUID) and the ORM implementation (String) causes inconsistency in UUID generation (server-side vs client-side) and can lead to type coercion issues during queries and serialization. All id fields and foreign keys across models.py and chat.py need to use the same type as the actual database schema.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@README.md` at line 202, The README and DB use PostgreSQL native UUIDs but the
ORM defines id/foreign keys as Column(String, ...) with client-side
uuid.uuid4(); update models.py and chat.py to use SQLAlchemy's PostgreSQL UUID
type (e.g. UUID(as_uuid=True) from sqlalchemy.dialects.postgresql) for all
primary key and FK columns, remove client-side uuid.uuid4() defaults, and
instead set server_default to gen_random_uuid() (using sa.text or equivalent) so
generation and types match the documented schema; update any ForeignKey
definitions to reference UUID columns and ensure imports (UUID, sa.text) are
added where needed.
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
README.md (1)
213-213:⚠️ Potential issue | 🟡 MinorUse markdown auto-numbering style for ordered lists.
4.triggers MD029 in this repo’s linting style; use1.for this item to keep numbering lint-clean and easier to maintain.📝 Proposed fix
-4. **Run the SQL Script** +1. **Run the SQL Script**🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@README.md` at line 213, The ordered list item currently uses an explicit "4." which triggers MD029; replace the numeric prefix with markdown auto-numbering (use "1." for the "Run the SQL Script" list item) so the list uses auto-numbering and stays lint-clean—update the line containing "4. **Run the SQL Script**" to begin with "1." (or switch the entire ordered list to use "1." for each entry).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@README.md`:
- Around line 214-216: Update the README instructions to point to the exact
location of sql.txt so contributors know where to find it (e.g., replace "Open
the `sql.txt` file in your project" with a concrete path like "Open
`Backend/sql.txt`"). Edit the README.md text around the SQL execution steps (the
block that currently lists opening, copying, and pasting `sql.txt`) to reference
the precise file path and ensure casing and relative location are correct for
the repository layout.
---
Duplicate comments:
In `@README.md`:
- Line 213: The ordered list item currently uses an explicit "4." which triggers
MD029; replace the numeric prefix with markdown auto-numbering (use "1." for the
"Run the SQL Script" list item) so the list uses auto-numbering and stays
lint-clean—update the line containing "4. **Run the SQL Script**" to begin with
"1." (or switch the entire ordered list to use "1." for each entry).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: b4c155c8-8d84-46b0-998b-724188e5a316
📒 Files selected for processing (1)
README.md
There was a problem hiding this comment.
♻️ Duplicate comments (1)
README.md (1)
213-216: 🧹 Nitpick | 🔵 TrivialConsider adding idempotency guidance for the SQL script.
The
Backend/sql.txtfile contains INSERT statements withoutON CONFLICThandling (as seen in the context). Running this step multiple times will fail with unique constraint violations onusernameandsql.txtto includeON CONFLICT DO NOTHINGclauses for idempotency.📝 Suggested addition to README
1. **Run the SQL Script** - Open `Backend/sql.txt` in your project. - Copy the SQL queries from the file. - - Paste into the SQL Editor and click **Run**. + - Paste into the SQL Editor and click **Run**. + - **Note:** Run this step only once during initial setup. Re-running will cause duplicate key errors.Alternatively, update
Backend/sql.txtto make INSERTs idempotent by addingON CONFLICT (username) DO NOTHINGorON CONFLICT (email) DO NOTHINGto each INSERT statement.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@README.md` around lines 213 - 216, Update the README guidance to warn that Backend/sql.txt contains plain INSERTs that will violate unique constraints if run multiple times, and either mark this step as “run once during initial setup” or instruct users to make the script idempotent; alternatively modify Backend/sql.txt so each INSERT uses PostgreSQL conflict handling (e.g., ON CONFLICT (username) DO NOTHING or ON CONFLICT (email) DO NOTHING / ON CONFLICT (username, email) DO NOTHING) to avoid duplicate key errors when re-running the script.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@README.md`:
- Around line 213-216: Update the README guidance to warn that Backend/sql.txt
contains plain INSERTs that will violate unique constraints if run multiple
times, and either mark this step as “run once during initial setup” or instruct
users to make the script idempotent; alternatively modify Backend/sql.txt so
each INSERT uses PostgreSQL conflict handling (e.g., ON CONFLICT (username) DO
NOTHING or ON CONFLICT (email) DO NOTHING / ON CONFLICT (username, email) DO
NOTHING) to avoid duplicate key errors when re-running the script.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 6629f1dc-0fb0-4038-a0f5-e1aab513dbcb
📒 Files selected for processing (1)
README.md
Closes #285
📝 Description
Added SQL schema and seed data instructions to the README to prevent "relation does not exist" errors during initial setup.
This ensures that required tables are created before running the existing SQL script, improving onboarding for new contributors.
🔧 Changes Made
userstable📷 Screenshots or Visual Changes (if applicable)
N/A
🤝 Collaboration
Collaborated with: N/A
✅ Checklist
Summary by CodeRabbit