ifixkart-admin/Backend/add_location_raw.py
Adithiyan bbd3a3e959 feat: initial commit — full platform snapshot
- Backend: FastAPI app with all models, services, schemas, routes
- Admin Panel: Next.js dashboard with all modules
  (CRM, POS, repairs, warranties, billing, notifications, etc.)
- Ecommerce: storefront (submodule) + product catalog
- AI Agents: .agents/ skill library for Antigravity IDE
- Docs: architecture, billing, notification gateway markdown
- Submodules: Backend/OpenWA, Ecommerce/File 2/storefront
2026-10-13 12:59:47 +05:30

51 lines
1.6 KiB
Python

import pymysql
import datetime
import ulid
conn = pymysql.connect(
host='127.0.0.1',
user='root',
password='NewStrongPassword123!',
database='ifixkart_crm'
)
try:
with conn.cursor() as cursor:
# Create table if not exists
cursor.execute("""
CREATE TABLE IF NOT EXISTS crm_locations (
location_id VARCHAR(36) PRIMARY KEY,
tenant_id VARCHAR(36) NOT NULL DEFAULT 'tenant_default',
code VARCHAR(50) NOT NULL,
name VARCHAR(255) NOT NULL,
address TEXT,
city VARCHAR(100),
state VARCHAR(100),
pincode VARCHAR(20),
phone VARCHAR(20),
is_active BOOLEAN DEFAULT 1,
is_primary BOOLEAN DEFAULT 0,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME ON UPDATE CURRENT_TIMESTAMP
)
""")
# Check if locations exist
cursor.execute("SELECT COUNT(*) FROM crm_locations")
count = cursor.fetchone()[0]
if count == 0:
location_id = str(ulid.ULID())
cursor.execute("""
INSERT INTO crm_locations (location_id, tenant_id, code, name, city, is_active, is_primary)
VALUES (%s, %s, %s, %s, %s, %s, %s)
""", (location_id, 'tenant_default', 'HQ01', 'Headquarters', 'Bangalore', 1, 1))
conn.commit()
print("Successfully inserted default location.")
else:
print(f"Locations already exist. Found {count} location(s).")
except Exception as e:
print(f"Error: {e}")
finally:
conn.close()