Skip to content

docs: add Supabase schema and seed instructions#309

Open
shrav784 wants to merge 5 commits intoAOSSIE-Org:mainfrom
shrav784:docs-supabase-update
Open

docs: add Supabase schema and seed instructions#309
shrav784 wants to merge 5 commits intoAOSSIE-Org:mainfrom
shrav784:docs-supabase-update

Conversation

@shrav784
Copy link
Copy Markdown

@shrav784 shrav784 commented Mar 26, 2026

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

  • Added SQL table creation query for users table
  • Added seed data with conflict handling
  • Updated Data Population section in README for clarity

📷 Screenshots or Visual Changes (if applicable)

N/A

🤝 Collaboration

Collaborated with: N/A

✅ Checklist

  • I have read the contributing guidelines.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added necessary documentation (if applicable).
  • Any dependent changes have been merged and published in downstream modules.

Summary by CodeRabbit

  • Documentation
    • Expanded database setup instructions: added an explicit inline SQL step to create required database objects and seed initial data, replaced a Markdown dashboard link with a plain URL, renumbered the setup steps for clarity, and simplified the final step for applying the provided SQL script.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 26, 2026

Warning

Rate limit exceeded

@shrav784 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 14 minutes and 57 seconds before requesting another review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 1af2816c-a9fc-404a-8baa-0e1411dca3f4

📥 Commits

Reviewing files that changed from the base of the PR and between db913a6 and 8dd5227.

📒 Files selected for processing (1)
  • README.md

Walkthrough

README "Data Population" updated: Supabase link changed to a plain URL; added inline SQL to enable pgcrypto, create public.users with id default gen_random_uuid(), username/email UNIQUE, timestamps, and seed INSERT statements using ON CONFLICT; step numbering adjusted and SQL-file step moved.

Changes

Cohort / File(s) Summary
Documentation Updates
README.md
Replaced Supabase Markdown link with a plain URL; added inline SQL to enable pgcrypto, create public.users (UUID id defaulting to gen_random_uuid(), username/email UNIQUE, additional columns and defaults), included seed INSERT statements with ON CONFLICT, renumbered data population steps and moved the SQL-file instruction.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

Documentation

Poem

🐇 I hopped into README, nibbling lines so neat,
I planted UUID seeds and made conflicts meet,
Tables sprout in public schema, tidy and true—
A little hop, and setup’s ready for you. ✨

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'docs: add Supabase schema and seed instructions' directly summarizes the main change—adding schema and seed data instructions to documentation.
Linked Issues check ✅ Passed The PR addresses issue #285 by adding CREATE TABLE statement for public.users with required schema fields and seed data with ON CONFLICT handling as specified.
Out of Scope Changes check ✅ Passed The README.md changes are focused solely on documenting the Supabase schema and data population instructions, directly aligned with issue #285 objectives.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between a61c801 and f72a2bb.

📒 Files selected for processing (1)
  • README.md

README.md Outdated
Comment on lines +210 to +215
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;
```
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

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.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

♻️ Duplicate comments (1)
README.md (1)

209-209: ⚠️ Potential issue | 🟡 Minor

Add DEFAULT to last_seen to match the backend model.

The backend User model in Backend/app/models/models.py defines last_seen with default=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

📥 Commits

Reviewing files that changed from the base of the PR and between f72a2bb and 630bcf7.

📒 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(),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 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 py

Repository: 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 -n

Repository: 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.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (1)
README.md (1)

213-213: ⚠️ Potential issue | 🟡 Minor

Use markdown auto-numbering style for ordered lists.

4. triggers MD029 in this repo’s linting style; use 1. 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

📥 Commits

Reviewing files that changed from the base of the PR and between 630bcf7 and 0d9e42f.

📒 Files selected for processing (1)
  • README.md

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
README.md (1)

213-216: 🧹 Nitpick | 🔵 Trivial

Consider adding idempotency guidance for the SQL script.

The Backend/sql.txt file contains INSERT statements without ON CONFLICT handling (as seen in the context). Running this step multiple times will fail with unique constraint violations on username and email. Consider adding a note that this step should only be run once during initial setup, or update sql.txt to include ON CONFLICT DO NOTHING clauses 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.txt to make INSERTs idempotent by adding ON CONFLICT (username) DO NOTHING or ON CONFLICT (email) DO NOTHING to 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

📥 Commits

Reviewing files that changed from the base of the PR and between 0d9e42f and db913a6.

📒 Files selected for processing (1)
  • README.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DOCS UPDATE: Insert Table Instructions on supabase

1 participant