dbarzin / mercator

Mapping the information system / Cartographie du système d'information
GNU General Public License v3.0
226 stars 36 forks source link

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

Closed tvalero35678 closed 1 month ago

tvalero35678 commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

Corrigé !