Deploy rule, CRM enhancements, Company Employee category, bilingual, contacts module completion

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Talal Sharabi
2026-02-19 14:59:34 +04:00
parent 0b126cb676
commit 680ba3871e
51 changed files with 11456 additions and 477 deletions

View File

@@ -0,0 +1,56 @@
#!/usr/bin/env bash
# Run database backup + clean-and-seed on PRODUCTION.
# Usage: on the production server, from repo root or backend:
# ./backend/scripts/run-production-clean-and-seed.sh
# Or: bash backend/scripts/run-production-clean-and-seed.sh
#
# Requires: DATABASE_URL in environment or in backend/.env
# Requires: pg_dump (for backup) and Node/npm (for clean-and-seed)
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
BACKEND_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
REPO_ROOT="$(cd "$BACKEND_DIR/.." && pwd)"
# Load .env from backend if present
if [ -f "$BACKEND_DIR/.env" ]; then
set -a
source "$BACKEND_DIR/.env"
set +a
fi
if [ -z "$DATABASE_URL" ]; then
echo "❌ DATABASE_URL is not set. Set it in backend/.env or export it."
exit 1
fi
echo "⚠️ This will TRUNCATE all tables and re-seed the database."
echo " DATABASE_URL is set (database will be modified)."
echo ""
read -p "Type YES to continue: " confirm
if [ "$confirm" != "YES" ]; then
echo "Aborted."
exit 0
fi
BACKUP_DIR="${BACKUP_DIR:-$REPO_ROOT/backups}"
mkdir -p "$BACKUP_DIR"
BACKUP_FILE="$BACKUP_DIR/backup_before_cleanup_$(date +%Y%m%d_%H%M%S).sql"
echo "📦 Backing up database to $BACKUP_FILE ..."
if pg_dump "$DATABASE_URL" > "$BACKUP_FILE"; then
echo "✅ Backup saved."
else
echo "❌ Backup failed. Aborting."
exit 1
fi
echo ""
echo "🧹 Running clean-and-seed..."
cd "$BACKEND_DIR"
npm run db:clean-and-seed
echo ""
echo "✅ Done. Restart the application so it uses the cleaned database."
echo " Default logins: gm@atmata.com / sales.manager@atmata.com / sales.rep@atmata.com (Password: Admin@123)"