From a96e9d5377b742eb7c68f333aa9c643d8bbcc7eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 24 Nov 2025 09:23:12 +0000 Subject: [PATCH] Associate activity's creator as a participant by default, and retro-actively append the creator to each activity --- .../unreleased/Fixed-20251118-140559.yaml | 7 +++ .../Controller/ActivityController.php | 1 + .../migrations/Version20251118124241.php | 50 +++++++++++++++++++ 3 files changed, 58 insertions(+) create mode 100644 .changes/unreleased/Fixed-20251118-140559.yaml create mode 100644 src/Bundle/ChillActivityBundle/migrations/Version20251118124241.php diff --git a/.changes/unreleased/Fixed-20251118-140559.yaml b/.changes/unreleased/Fixed-20251118-140559.yaml new file mode 100644 index 000000000..70f081e55 --- /dev/null +++ b/.changes/unreleased/Fixed-20251118-140559.yaml @@ -0,0 +1,7 @@ +kind: Fixed +body: | + Associate activity's creator as a participant by default, and retro-actively append the creator to each activity +time: 2025-11-18T14:05:59.904993123+01:00 +custom: + Issue: "466" + SchemaChange: Add columns or tables diff --git a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php index f248c6559..bc9adc698 100644 --- a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php +++ b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php @@ -382,6 +382,7 @@ final class ActivityController extends AbstractController $entity = new Activity(); $entity->setUser($this->security->getUser()); + $entity->addUser($this->security->getUser()); if ($person instanceof Person) { $entity->setPerson($person); diff --git a/src/Bundle/ChillActivityBundle/migrations/Version20251118124241.php b/src/Bundle/ChillActivityBundle/migrations/Version20251118124241.php new file mode 100644 index 000000000..c06f3e674 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/migrations/Version20251118124241.php @@ -0,0 +1,50 @@ +addSql('ALTER TABLE activity_user ADD COLUMN by_migration BOOL DEFAULT FALSE'); + $this->addSql("COMMENT ON COLUMN activity_user.by_migration IS 'For backup purpose - can be safely deleted after a while. See migration \\Chill\\Migrations\\Activity\\Version20251118124241'"); + + $this->addSql('INSERT INTO activity_user (activity_id, user_id, by_migration) + SELECT id, user_id, true FROM activity + ON CONFLICT DO NOTHING'); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE activity_user DROP COLUMN by_migration'); + } +}