Skip to content
Open
Changes from 1 commit
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
35 changes: 31 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,21 +182,48 @@ 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 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
-- Create Tables (Schema)
CREATE TABLE public.users (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
username TEXT UNIQUE NOT NULL,
email TEXT UNIQUE NOT NULL,
role TEXT,
profile_image TEXT,
bio TEXT,
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated

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



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





---

Expand Down