# 🗄️ Database Setup Guide

## Option 1: Neon (Recommended - Free & Easy)

### Step 1: Create Account
1. Go to [neon.tech](https://neon.tech)
2. Click "Sign Up" (use GitHub for fastest setup)
3. Create a new project called "mypowerpost"

### Step 2: Get Connection String
1. After project creation, you'll see the connection string
2. It looks like: `postgresql://username:password@ep-xxx.region.aws.neon.tech/neondb?sslmode=require`
3. Copy this string

### Step 3: Update .env
Add to your `.env` file:
```env
DATABASE_URL="postgresql://username:password@ep-xxx.region.aws.neon.tech/neondb?sslmode=require"
```

---

## Option 2: Supabase (Also Free)

### Step 1: Create Account
1. Go to [supabase.com](https://supabase.com)
2. Click "Start your project"
3. Sign up with GitHub

### Step 2: Create Project
1. Click "New Project"
2. Name it "mypowerpost"
3. Set a strong database password (save this!)
4. Choose a region close to you
5. Wait for project to be ready (~2 minutes)

### Step 3: Get Connection String
1. Go to Settings → Database
2. Find "Connection string" section
3. Copy the URI (starts with `postgresql://`)
4. Replace `[YOUR-PASSWORD]` with your database password

### Step 4: Update .env
```env
DATABASE_URL="postgresql://postgres:[YOUR-PASSWORD]@db.xxx.supabase.co:5432/postgres"
```

---

## Option 3: Local PostgreSQL

### Windows
1. Download from: https://www.postgresql.org/download/windows/
2. Run installer, remember your password
3. Use connection string:
```env
DATABASE_URL="postgresql://postgres:yourpassword@localhost:5432/mypowerpost"
```
4. Create database:
```bash
psql -U postgres
CREATE DATABASE mypowerpost;
\q
```

### Mac (with Homebrew)
```bash
brew install postgresql@15
brew services start postgresql@15
createdb mypowerpost
```
Connection string:
```env
DATABASE_URL="postgresql://localhost:5432/mypowerpost"
```

---

## After Setting DATABASE_URL

Run these commands:
```bash
npx prisma generate
npx prisma db push
```

You should see:
```
✔ Generated Prisma Client
✔ The database is now in sync with your Prisma schema
```

Then verify with:
```bash
npx prisma studio
```

This opens a database GUI at http://localhost:5555



