first
This commit is contained in:
30
setup_db.sh
Executable file
30
setup_db.sh
Executable file
@@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Настройки
|
||||
DB_NAME="formbuilder"
|
||||
DB_USER="postgres"
|
||||
DB_PASSWORD="postgres"
|
||||
|
||||
echo "Setting up PostgreSQL database..."
|
||||
|
||||
# Проверяем, запущен ли PostgreSQL
|
||||
if ! pg_isready -U $DB_USER -h localhost -p 5432; then
|
||||
echo "PostgreSQL is not running. Starting..."
|
||||
sudo systemctl start postgresql
|
||||
sleep 3
|
||||
fi
|
||||
|
||||
# Создаем базу данных если не существует
|
||||
if ! psql -U $DB_USER -h localhost -lqt | cut -d \| -f 1 | grep -qw $DB_NAME; then
|
||||
echo "Creating database $DB_NAME..."
|
||||
sudo -u postgres createdb $DB_NAME
|
||||
echo "Database created successfully!"
|
||||
else
|
||||
echo "Database $DB_NAME already exists"
|
||||
fi
|
||||
|
||||
# Запускаем инициализацию Python
|
||||
echo "Running database initialization..."
|
||||
python scripts/init_db.py
|
||||
|
||||
echo "Setup complete!"
|
||||
Reference in New Issue
Block a user