antonioribeiro / antonioribeiro/tracker

SQLSTATE[23000]: Integrity constraint violation on an empty database

Open
#208 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
2.9k
Forks
594
PR merge metrics
No merged PRs in 30d

Description

I was using this module without problems, then i messed around with records (deleting rows directly in the database) and ive got this error. I thought that i broke some integrity constraint, so rolled back the migration and re-migrated.

I am now working on a fresh empty database, but each access leads to this SQL error.

This is the broken query:

``` sql
insert into `tracker_log` (`session_id`, `method`, `path_id`, `query_id`, `referer_id`, `is_ajax`, `is_secure`, `is_json`, `wants_json`, `updated_at`, `created_at`) values (1, GET, 52, , , 0, 0, 0, 0, 2016-10-04 21:15:32, 2016-10-04 21:15:32
```

This is the full error:

```
Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`stats`.`tracker_log`, CONSTRAINT `tracker_log_path_id_foreign` FOREIGN KEY (`path_id`) REFERENCES `tracker_paths` (`id`) ON DELETE CASCADE ON UPDATE CASCADE)
```

I can see that some table is being written despite the error. I can see records in
- tracker_agents
- tracker_devices
- tracker_errors
- tracker_languages
- tracker_sessions

How to fix this?

Contributor guide

No contributing guide indexed for this repository

Research direction

No source files or tests are named. Start by reproducing the insert into tracker_log on a fresh database, then trace how path_id and its tracker_paths row are created; done means normal access no longer violates tracker_log_path_id_foreign and the related records are present.

Written by the indexing model from the issue text.

Assessment

Tech stack
laravel, php, sql
Domain
database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.