Files
plantillas-proyectos/check_ports.py

34 lines
1.1 KiB
Python

import os
import sys
# Add the backend directory to sys.path
sys.path.append(os.path.join(os.getcwd(), "backend"))
from core.database import CoreSessionLocal
from api.v1.modules.a76.general_catalogs.ports.models import Port
from sqlalchemy import text
def check_ports():
db = CoreSessionLocal()
try:
# Check all ports
ports = db.query(Port).all()
print(f"Total ports found in a76.ports: {len(ports)}")
for i, p in enumerate(ports[:10]):
print(f"Port {i}: ID={p.id}, Code={p.port_code}, Desc={p.description}, Tenant={p.tenant_id}, Company={p.company_id}")
# Check by tenant if possible (assuming tenant 1)
tenant_ports = db.query(Port).filter(Port.tenant_id == 1).all()
print(f"Ports for Tenant 1: {len(tenant_ports)}")
# Check schemas
result = db.execute(text("SELECT schema_name FROM information_schema.schemata WHERE schema_name = 'a76'"))
schema_exists = result.fetchone()
print(f"Schema a76 exists: {schema_exists is not None}")
finally:
db.close()
if __name__ == "__main__":
check_ports()