mirror of
https://github.com/OHV-IT/collabrix.git
synced 2025-12-15 16:48:36 +01:00
- Complete chat application similar to Microsoft Teams - Code snippet library with syntax highlighting - Real-time messaging with WebSockets - File upload with Office integration - Department-based permissions - Dark/Light theme support - Production deployment with SSL/Reverse Proxy - Docker containerization - PostgreSQL database with SQLModel ORM
67 lines
1.7 KiB
Python
67 lines
1.7 KiB
Python
#!/usr/bin/env python3
|
|
import os
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
# Add parent directory to path to import app modules
|
|
sys.path.insert(0, str(Path(__file__).parent.parent))
|
|
|
|
import psycopg2
|
|
from dotenv import load_dotenv
|
|
|
|
# Load environment variables from .env file
|
|
env_path = Path(__file__).parent.parent / '.env'
|
|
load_dotenv(dotenv_path=env_path)
|
|
|
|
# Get database URL from environment
|
|
database_url = os.getenv('DATABASE_URL')
|
|
if not database_url:
|
|
print("ERROR: DATABASE_URL not found in environment variables")
|
|
sys.exit(1)
|
|
|
|
# Parse PostgreSQL connection string
|
|
# Format: postgresql://user:password@host:port/database
|
|
db_parts = database_url.replace('postgresql://', '').split('@')
|
|
user_pass = db_parts[0].split(':')
|
|
host_port_db = db_parts[1].split('/')
|
|
host_port = host_port_db[0].split(':')
|
|
|
|
conn_params = {
|
|
'dbname': host_port_db[1],
|
|
'user': user_pass[0],
|
|
'password': user_pass[1],
|
|
'host': host_port[0],
|
|
'port': host_port[1]
|
|
}
|
|
|
|
print(f"Connecting to database: {conn_params['host']}:{conn_params['port']}/{conn_params['dbname']}")
|
|
|
|
try:
|
|
# Connect to PostgreSQL
|
|
conn = psycopg2.connect(**conn_params)
|
|
cur = conn.cursor()
|
|
|
|
print("\nAdding is_deleted column to message table...")
|
|
|
|
# Add is_deleted column
|
|
cur.execute("""
|
|
ALTER TABLE message
|
|
ADD COLUMN IF NOT EXISTS is_deleted BOOLEAN DEFAULT FALSE;
|
|
""")
|
|
print("✓ Added is_deleted column")
|
|
|
|
conn.commit()
|
|
print("\n✅ Migration completed successfully!")
|
|
|
|
except Exception as e:
|
|
print(f"\n❌ Error: {e}")
|
|
if conn:
|
|
conn.rollback()
|
|
sys.exit(1)
|
|
|
|
finally:
|
|
if cur:
|
|
cur.close()
|
|
if conn:
|
|
conn.close()
|