Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL error (Integrity constraint violation) during initial database loading from Master branch. #721

Closed
tvalero35678 opened this issue May 9, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@tvalero35678
Copy link

Erreur SQL (Integrity constraint violation) durant le chargement initiale de la base, à partir de la branche Master.
Avec ou sans l'option d'utilisation des données de démonstration.

SQL error (Integrity constraint violation) during initial database loading from Master branch.
With or without the option to use demo data.


SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails

(`mercator`.`activity_process`, CONSTRAINT `process_id_fk_1627616` FOREIGN KEY (`process_id`) 
 REFERENCES `processes` (`id`) ON DELETE CASCADE) 
insert into `activity_process` (`activity_id`, `process_id`) values (1, 1), (2, 1), (3, 2), (4, 2), (2, 3), (5, 3), (5, 4), (4, 5), (4, 6), (3, 7), (4, 8), (3, 9), (10, 1)**

app-1         |   Database\Seeders\DemoOauthPersonalAccessClientsTableSeeder ......... RUNNING
app-1         |   Database\Seeders\DemoOauthPersonalAccessClientsTableSeeder ....... 1 ms DONE
app-1         |
app-1         |   Database\Seeders\DemoActivityProcessTableSeeder .................... RUNNING
app-1         |
app-1         |    Illuminate\Database\QueryException
app-1         |
app-1         |   SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`mercator`.`activity_process`, CONSTRAINT `process_id_fk_1627616` FOREIGN KEY (`process_id`) REFERENCES `processes` (`id`) ON DELETE CASCADE) (Connection: mysql, SQL: insert into `activity_process` (`activity_id`, `process_id`) values (1, 1), (2, 1), (3, 2), (4, 2), (2, 3), (5, 3), (5, 4), (4, 5), (4, 6), (3, 7), (4, 8), (3, 9), (10, 1))
app-1         |
app-1         |   at vendor/laravel/framework/src/Illuminate/Database/Connection.php:829
app-1         |     825▕                     $this->getName(), $query, $this->prepareBindings($bindings), $e
app-1         |     826▕                 );
app-1         |     827▕             }
app-1         |     828▕
app-1         |   ➜ 829▕             throw new QueryException(
app-1         |     830▕                 $this->getName(), $query, $this->prepareBindings($bindings), $e
app-1         |     831▕             );
app-1         |     832▕         }
app-1         |     833▕     }
app-1         |
app-1         |       +7 vendor frames
app-1         |
app-1         |   8   database/seeders/DemoActivityProcessTableSeeder.php:21
app-1         |       Illuminate\Database\Query\Builder::insert()
app-1         |       +8 vendor frames
app-1         |
app-1         |   17  database/seeders/DatabaseSeeder.php:26
app-1         |       Illuminate\Database\Seeder::call("Database\Seeders\DemoActivityProcessTableSeeder")
app-1         |
app-1         | 2024-05-09 15:25:45,534 INFO exited: migrate (exit status 0; expected)
@dbarzin dbarzin self-assigned this May 9, 2024
@dbarzin dbarzin added the bug Something isn't working label May 9, 2024
@dbarzin
Copy link
Owner

dbarzin commented May 9, 2024

Les données de démonstration ne sont chargées que si la variable USE_DEMO_DATA est vraie ou indéfinie.
C'est contraint par ce test dans la classe DatabaseSeeder :

        if (env("USE_DEMO_DATA", false)) {

Il y avait une erreur dans l'ordre d'importation des données.
Cela n'a jamais été testé avec MySQL. La correction est en cours.

@dbarzin
Copy link
Owner

dbarzin commented May 9, 2024

Corrigé !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants