Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion Gradient-Backend/db.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import duckdb
from pathlib import Path
import threading

BASE_DIR = Path(__file__).resolve().parent
DB_PATH = BASE_DIR / "db" / "database.duckdb"
Expand All @@ -8,6 +9,8 @@

conn = duckdb.connect(DB_PATH)

db_lock = threading.RLock()

def _ensure_column(table: str, column: str, definition: str) -> None:
exists = conn.execute(
"""
Expand All @@ -28,10 +31,13 @@ def init_db():
username TEXT UNIQUE NOT NULL,
email TEXT NOT NULL,
password TEXT NOT NULL,
role TEXT NOT NULL DEFAULT 'manager' CHECK (role IN ('admin', 'manager'))
role TEXT NOT NULL DEFAULT 'manager' CHECK (role IN ('admin', 'manager')),
is_active BOOLEAN NOT NULL DEFAULT TRUE
)
""")

_ensure_column("users", "is_active", "BOOLEAN DEFAULT TRUE")

conn.execute("""
CREATE TABLE IF NOT EXISTS processed_emails (
gmail_id TEXT PRIMARY KEY,
Expand Down Expand Up @@ -95,6 +101,8 @@ def init_db():
)
""")

_ensure_column("lead_status_history", "rejection_reason", "TEXT")

conn.execute("""
CREATE TABLE IF NOT EXISTS app_settings (
key TEXT PRIMARY KEY,
Expand Down
33 changes: 0 additions & 33 deletions Gradient-Backend/fix_admin.py

This file was deleted.

11 changes: 0 additions & 11 deletions Gradient-Backend/fix_admin.sql

This file was deleted.

4 changes: 3 additions & 1 deletion Gradient-Backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from routes.userRoutes import router as user_router
from routes.gmailRoutes import router as gmail_router
from routes.settingsRoutes import router as settings_router
from routes.managerRoutes import router as manager_router
from routes import emailRoutes
from routes.leadRoutes import router as lead_router
from service.autosyncService import auto_sync_loop
Expand All @@ -12,7 +13,7 @@

app.add_middleware(
CORSMiddleware,
allow_origins=["http://localhost:3000", "http://127.0.0.1:3000"],
allow_origins=["http://localhost:3000", "http://127.0.0.1:3000", "http://localhost:3001", "http://127.0.0.1:3001"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
Expand All @@ -21,6 +22,7 @@
app.include_router(user_router)
app.include_router(gmail_router)
app.include_router(settings_router)
app.include_router(manager_router)
app.include_router(lead_router)
app.include_router(emailRoutes.router)

Expand Down
80 changes: 0 additions & 80 deletions Gradient-Backend/migrate_database.py

This file was deleted.

Loading