🔐 Database Constraints Setup

This script adds foreign key constraints to prevent orphaned records in the future.

📋 Current Foreign Key Constraints

ConstraintTableColumnReferences TableReferences Column
fk_assets_brandtbl_assetsbrand_idtbl_asset_brandsid
fk_assets_categorytbl_assetscategory_idtbl_asset_categoriesid
fk_assets_customertbl_assetsassigned_totbl_customersid
fk_assets_modeltbl_assetsmodel_idtbl_asset_modelsid
fk_models_brandtbl_asset_modelsbrand_idtbl_asset_brandsid
fk_odc_ports_odctbl_odc_portsodc_idtbl_odcid
fk_odp_ports_odptbl_odp_portsodp_idtbl_odpid
fk_olt_ports_olttbl_olt_portsolt_idtbl_oltid
tbl_support_tickets_replies_ibfk_1tbl_support_tickets_repliesticket_idtbl_support_ticketsticket_id

🎯 Recommended Actions

⚠️ Missing Constraint

The system lacks a foreign key constraint between tbl_user_recharges.customer_id and tbl_customers.id.

Benefits of adding this constraint:


📚 Manual SQL Commands

If you prefer to run these manually in your database:

-- Add foreign key constraint (run this in your MySQL database)
ALTER TABLE tbl_user_recharges 
ADD CONSTRAINT fk_recharge_customer 
FOREIGN KEY (customer_id) 
REFERENCES tbl_customers(id) 
ON DELETE CASCADE 
ON UPDATE CASCADE;

Analysis completed at 2026-07-26 21:54:20