forked from Merit-Systems/echo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-db.sh
More file actions
executable file
Β·52 lines (42 loc) Β· 1.48 KB
/
setup-db.sh
File metadata and controls
executable file
Β·52 lines (42 loc) Β· 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash
echo "π Setting up Echo Control PostgreSQL Database..."
# Create .env file if it doesn't exist
if [ ! -f .env ]; then
echo "π Creating .env file..."
cat > .env << 'EOF'
# Database - Docker PostgreSQL
DATABASE_URL="postgresql://echo_user:echo_password@localhost:5469/echo_control?schema=public"
# Stripe (Mocked for now)
STRIPE_SECRET_KEY="mock_stripe_secret_key"
STRIPE_PUBLISHABLE_KEY="mock_stripe_publishable_key"
STRIPE_WEBHOOK_SECRET="mock_webhook_secret"
# Application
ECHO_CONTROL_APP_BASE_URL="http://localhost:3000"
API_KEY_PREFIX="echo_"
EOF
echo "β
.env file created"
else
echo "βΉοΈ .env file already exists"
fi
# Start PostgreSQL container
echo "π³ Starting PostgreSQL container..."
docker-compose -f docker-local-db.yml up -d postgres
# Wait for PostgreSQL to be ready
# No need for manual health check since docker-local-db.yml already has healthcheck configured
echo "β
PostgreSQL is ready!"
# Check if .env file exists and show DATABASE_URL
if [ -f .env ]; then
echo "π Checking DATABASE_URL..."
grep "DATABASE_URL" .env
fi
# Run Prisma migrations
echo "π Running Prisma migrations..."
pnpm exec prisma generate
pnpm exec prisma db push
echo "π Database setup complete!"
echo ""
echo "π You can now run:"
echo " npm run dev # Start the application"
echo " pnpm exec prisma studio # View the database"
echo " docker logs local-postgres # View database logs"
echo " docker stop local-postgres # Stop the database"