-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathsetup_postgres.sh
More file actions
executable file
·39 lines (32 loc) · 1.05 KB
/
setup_postgres.sh
File metadata and controls
executable file
·39 lines (32 loc) · 1.05 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
#!/bin/bash
# Setup script for PostgreSQL authentication migration
echo "Setting up PostgreSQL authentication..."
# Install dependencies
echo "Installing Python dependencies..."
pip install -r requirements.txt
# Start PostgreSQL (if using Docker)
if command -v docker &> /dev/null; then
echo "Starting PostgreSQL with Docker..."
docker-compose -f docker-compose-postgres.yml up -d db
sleep 5
fi
# Create database and run migrations
echo "Setting up database..."
python -c "
from questions.db_models_postgres import create_tables
create_tables()
print('Database tables created successfully!')
"
# Run migrations if alembic is available
if command -v alembic &> /dev/null; then
echo "Running database migrations..."
alembic upgrade head
fi
echo "Setup complete!"
echo "You can now start the application with PostgreSQL authentication."
echo ""
echo "Environment variables:"
echo "DATABASE_URL=postgresql://postgres:password@localhost:5432/textgen"
echo ""
echo "To start the application:"
echo "uvicorn main:app --reload --host 0.0.0.0 --port 8080"