From b784d7d2580c921e9b3715a99082865d3e576f89 Mon Sep 17 00:00:00 2001 From: Tatevik Date: Mon, 18 May 2026 14:13:14 +0400 Subject: [PATCH 1/3] Check for existing phpList schema before applying migration --- src/Migrations/Version20251028092901MySqlInit.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Migrations/Version20251028092901MySqlInit.php b/src/Migrations/Version20251028092901MySqlInit.php index 7b345dad..5589fadf 100644 --- a/src/Migrations/Version20251028092901MySqlInit.php +++ b/src/Migrations/Version20251028092901MySqlInit.php @@ -28,6 +28,19 @@ public function up(Schema $schema): void get_class($platform) ) ); + + $schemaManager = $this->connection->createSchemaManager(); + $tables = $schemaManager->listTableNames(); + $hasUserStats = array_filter( + $tables, + static fn (string $table): bool => + str_ends_with($table, 'userstats') + ); + $this->skipIf( + !empty($hasUserStats), + 'phpList schema already exists.' + ); + // this up() migration is auto-generated, please modify it to your needs $this->addSql(file_get_contents(__DIR__.'/initial_schema.sql')); } From be0b88e1a763fdf5f1cd515c746745b2f3383a40 Mon Sep 17 00:00:00 2001 From: Tatevik Date: Mon, 18 May 2026 18:02:15 +0400 Subject: [PATCH 2/3] Add inverse relationships to ORM mappings for AdminAttributeValue and SubscriberList --- src/Domain/Identity/Model/AdminAttributeValue.php | 2 +- src/Domain/Subscription/Model/SubscriberList.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Domain/Identity/Model/AdminAttributeValue.php b/src/Domain/Identity/Model/AdminAttributeValue.php index f3889085..3d99ba73 100644 --- a/src/Domain/Identity/Model/AdminAttributeValue.php +++ b/src/Domain/Identity/Model/AdminAttributeValue.php @@ -14,7 +14,7 @@ class AdminAttributeValue implements DomainModel { #[ORM\Id] - #[ORM\ManyToOne(targetEntity: AdminAttributeDefinition::class)] + #[ORM\ManyToOne(targetEntity: AdminAttributeDefinition::class, inversedBy: 'attributeValues')] #[ORM\JoinColumn(name: 'adminattributeid', referencedColumnName: 'id')] private AdminAttributeDefinition $attributeDefinition; diff --git a/src/Domain/Subscription/Model/SubscriberList.php b/src/Domain/Subscription/Model/SubscriberList.php index 82eb2c63..621f855e 100644 --- a/src/Domain/Subscription/Model/SubscriberList.php +++ b/src/Domain/Subscription/Model/SubscriberList.php @@ -63,7 +63,7 @@ class SubscriberList implements DomainModel, Identity, CreationDate, Modificatio #[ORM\Column] private ?string $category = ''; - #[ORM\ManyToOne(targetEntity: Administrator::class)] + #[ORM\ManyToOne(targetEntity: Administrator::class, inversedBy: 'ownedLists')] #[ORM\JoinColumn(name: 'owner')] private ?Administrator $owner = null; From 612bcd42469010ff29640186846581097b979338 Mon Sep 17 00:00:00 2001 From: Tatevik Date: Mon, 18 May 2026 18:03:21 +0400 Subject: [PATCH 3/3] Add schema validation to the CI workflow --- .github/workflows/ci.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8e0d5fbe..263488c7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -58,6 +58,14 @@ jobs: run: composer validate --no-check-all --no-check-lock --strict; - name: Linting all php files run: find src/ tests/ public/ -name ''*.php'' -print0 | xargs -0 -n 1 -P 4 php -l; php -l bin/*; + - name: Validate Doctrine schema + run: | + export PHPLIST_DATABASE_NAME=${{ env.DB_DATABASE }} + export PHPLIST_DATABASE_USER=${{ env.DB_USERNAME }} + export PHPLIST_DATABASE_PASSWORD=${{ env.DB_PASSWORD }} + export PHPLIST_DATABASE_PORT=${{ job.services.mysql.ports['3306'] }} + export PHPLIST_DATABASE_HOST=127.0.0.1 + php bin/console doctrine:schema:validate --skip-sync - name: Run units tests with phpunit run: vendor/bin/phpunit tests/Unit/ --testdox - name: Run integration tests with phpunit