From 0b92cff295db91a2beb37d7a16aaf726ff0ce9bf Mon Sep 17 00:00:00 2001 From: Xavier Leune Date: Thu, 19 Nov 2026 10:04:54 +0100 Subject: [PATCH] =?UTF-8?q?Cr=C3=A9e=20la=20table=20des=20personnes=20conf?= =?UTF-8?q?=C3=A9renciers,=20sans=20l'utiliser?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Le CFP crée une ligne afup_conferenciers par édition ; seul le compte GitHub relie ces lignes, et la moitié n'en a pas. La table afup_speaker_person (slug unique) et la colonne nullable afup_conferenciers.person_id permettront de regrouper les lignes d'une même personne. Le code ne lit ni n'écrit encore ces données : la table part seule en prod pour être remplie avant que le back-office, le CFP puis les pages publiques ne s'en servent. Supprimer une personne détache ses lignes (ON DELETE SET NULL) sans les supprimer. --- .../20261119090000_create_speaker_person.php | 27 +++++++++++ .../Event/Speaker/SpeakerPersonSchemaTest.php | 47 +++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 db/migrations/20261119090000_create_speaker_person.php create mode 100644 tests/integration/AppBundle/Event/Speaker/SpeakerPersonSchemaTest.php diff --git a/db/migrations/20261119090000_create_speaker_person.php b/db/migrations/20261119090000_create_speaker_person.php new file mode 100644 index 000000000..4789588a9 --- /dev/null +++ b/db/migrations/20261119090000_create_speaker_person.php @@ -0,0 +1,27 @@ +table('afup_speaker_person', ['signed' => false]) + ->addColumn('slug', 'string', ['limit' => 255, 'null' => false]) + ->addColumn('created_at', 'datetime', ['null' => false, 'default' => 'CURRENT_TIMESTAMP']) + ->addIndex('slug', ['unique' => true]) + ->create(); + + $this->table('afup_conferenciers') + ->addColumn('person_id', 'integer', ['null' => true, 'default' => null, 'signed' => false, 'after' => 'user_github']) + ->addForeignKey('person_id', 'afup_speaker_person', 'id', ['delete' => 'SET_NULL', 'update' => 'NO_ACTION']) + ->update(); + } +} diff --git a/tests/integration/AppBundle/Event/Speaker/SpeakerPersonSchemaTest.php b/tests/integration/AppBundle/Event/Speaker/SpeakerPersonSchemaTest.php new file mode 100644 index 000000000..1ea221902 --- /dev/null +++ b/tests/integration/AppBundle/Event/Speaker/SpeakerPersonSchemaTest.php @@ -0,0 +1,47 @@ +get(Connection::class); + + $connection->insert('afup_speaker_person', ['id' => 1, 'slug' => 'helene-schapira']); + $connection->insert('afup_conferenciers', ['conferencier_id' => 10, 'id_forum' => 1, 'prenom' => 'Hélène', 'nom' => 'Schapira', 'email' => 'h@example.com', 'person_id' => 1]); + $connection->insert('afup_conferenciers', ['conferencier_id' => 20, 'id_forum' => 2, 'prenom' => 'Hélène', 'nom' => 'Schapira', 'email' => 'h@example.com']); + + self::assertSame([[10, 1], [20, null]], $this->personIds($connection)); + + $connection->delete('afup_speaker_person', ['id' => 1]); + + self::assertSame([[10, null], [20, null]], $this->personIds($connection), 'supprimer une personne détache ses lignes sans les supprimer'); + } + + public function testSlugIsUnique(): void + { + $connection = self::getContainer()->get(Connection::class); + $connection->insert('afup_speaker_person', ['slug' => 'jean-martin']); + + $this->expectException(UniqueConstraintViolationException::class); + $connection->insert('afup_speaker_person', ['slug' => 'jean-martin']); + } + + /** + * @return list + */ + private function personIds(Connection $connection): array + { + return array_map( + static fn(array $row): array => [(int) $row['conferencier_id'], null !== $row['person_id'] ? (int) $row['person_id'] : null], + $connection->fetchAllAssociative('SELECT conferencier_id, person_id FROM afup_conferenciers ORDER BY conferencier_id'), + ); + } +}