ifixkart-backend/fix_db.py
adithiyan 10bfba7d58 feat: add warranties, refunds, notifications, CRM calendar, system config & delivery modules
- New models: WarrantyModel, WalletModel, SystemConfigModel
- New schemas: WarrantySchema, RefundSchema, SystemConfig, CrmTaskCalendar, NotificationTemplate, NotificationGateway, RepairErp, ReviewModeration, InventoryPos, MultiDashboard, BillingFinance
- New services: WarrantyService, RefundService, CrmService, CrmTaskCalendarService, DeliveryService, EmailTemplateService, InventoryPosService, MultiDashboardService, NotificationGatewayService, RepairErpService, ReviewModerationService, SystemConfigService, TemplateService, CreditService
- Updated routers: AdminOrder, BillingFinance, Cart, Catalog, Checkout, Crm, InventoryPos, NotificationGateway, RolePermission, ServiceJob, Settings, Storefront, UserCreation
- Updated models: Inventory, Notification, Order, Product, Service, Setting, SystemConfig, User
- Updated core: database init, invoice generator, main app
- Added WarrantyRouter with full CRUD and claim flow
2026-10-13 22:05:16 +05:30

25 lines
881 B
Python

from sqlalchemy import create_engine
from sqlalchemy.sql import text
from app.core.config.Config import settings
engines = [
create_engine(settings.CORE_DATABASE_URL),
create_engine(settings.CRM_DATABASE_URL),
create_engine(settings.COMMERCE_DATABASE_URL)
]
tables_to_drop = ["notification_attempts", "dead_letter_notifications", "whatsapp_sessions", "notifications"]
for engine in engines:
with engine.connect() as conn:
try:
print(f"Checking DB: {engine.url.database}")
for table in tables_to_drop:
try:
conn.execute(text(f'DROP TABLE IF EXISTS {table};'))
print(f"Dropped {table}")
except Exception as e: print(e)
conn.commit()
except Exception as e:
print(f"Error connecting to {engine.url.database}: {e}")
print('Done!')