From 50d5e6534f5e593297a09323e683c7c8b850117b Mon Sep 17 00:00:00 2001 From: Biswa Kalyan Bhuyan Date: Thu, 24 Apr 2025 08:18:27 +0530 Subject: feat: added basic backend features to it - Set up API framework (Gin Gonic) - Set up ORM/DB library (GORM) - Design database schema (Users, Accounts, Transactions, Loans, Goals) - Set up database connection and migrations --- backend/scripts/setup_db.sh | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 backend/scripts/setup_db.sh (limited to 'backend/scripts/setup_db.sh') diff --git a/backend/scripts/setup_db.sh b/backend/scripts/setup_db.sh new file mode 100755 index 0000000..7388015 --- /dev/null +++ b/backend/scripts/setup_db.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +# Script to set up the PostgreSQL database for the finance application + +# Prompt for PostgreSQL user to use +read -p "Enter PostgreSQL admin username [postgres]: " PG_USER +PG_USER=${PG_USER:-postgres} + +# Prompt for PostgreSQL password +read -s -p "Enter PostgreSQL password for $PG_USER: " PG_PASSWORD +echo + +# Check if database exists +echo "Checking if database exists..." +if PGPASSWORD="$PG_PASSWORD" psql -U "$PG_USER" -h localhost -lqt | cut -d \| -f 1 | grep -qw finance; then + echo "Database 'finance' already exists" +else + echo "Creating database 'finance'..." + PGPASSWORD="$PG_PASSWORD" createdb -U "$PG_USER" -h localhost finance + if [ $? -ne 0 ]; then + echo "Failed to create database. Please check your credentials." + exit 1 + fi + echo "Database 'finance' created successfully" +fi + +# Create .env file with database connection details +echo "Creating .env file with database connection info..." +cat > .env <