This script adds foreign key constraints to prevent orphaned records in the future.
| Constraint | Table | Column | References Table | References Column |
|---|---|---|---|---|
| fk_assets_brand | tbl_assets | brand_id | tbl_asset_brands | id |
| fk_assets_category | tbl_assets | category_id | tbl_asset_categories | id |
| fk_assets_customer | tbl_assets | assigned_to | tbl_customers | id |
| fk_assets_model | tbl_assets | model_id | tbl_asset_models | id |
| fk_models_brand | tbl_asset_models | brand_id | tbl_asset_brands | id |
| fk_odc_ports_odc | tbl_odc_ports | odc_id | tbl_odc | id |
| fk_odp_ports_odp | tbl_odp_ports | odp_id | tbl_odp | id |
| fk_olt_ports_olt | tbl_olt_ports | olt_id | tbl_olt | id |
| tbl_support_tickets_replies_ibfk_1 | tbl_support_tickets_replies | ticket_id | tbl_support_tickets | ticket_id |
The system lacks a foreign key constraint between tbl_user_recharges.customer_id and tbl_customers.id.
Benefits of adding this constraint:
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 22:11:46