Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 24 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,21 +182,40 @@ uvicorn main:app --reload

To populate the database with initial data, follow these steps:

1. **Open Supabase Dashboard**

- Go to [Supabase](https://supabase.com/) and log in.
1. **Open Supabase Dashboard**
- Go to Supabase Dashboard (https://supabase.com/) and log in.
- Select your created project.

2. **Access the SQL Editor**

- In the left sidebar, click on **SQL Editor**.

3. **Run the SQL Script**
3. **Create Required Tables**
- Run the following SQL in the Supabase SQL Editor:
```sql
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
-- Enable pgcrypto extension for gen_random_uuid() support
CREATE EXTENSION IF NOT EXISTS "pgcrypto";

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

username TEXT UNIQUE NOT NULL,
email TEXT UNIQUE NOT NULL,
role TEXT NOT NULL,
profile_image TEXT,
bio TEXT,
is_online BOOLEAN DEFAULT FALSE,
last_seen TIMESTAMP WITH TIME ZONE,
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);
```

4. **Run the SQL Script**
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
- Open the `sql.txt` file in your project.
- Copy the SQL queries from the file.
- Paste the queries into the SQL Editor and click **Run**.

This will populate the database with the required initial data for the platform. πŸš€
- The script includes conflict handling to avoid duplicate entries based on unique constraints.
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated

---

Expand Down