Skip to content

Check for existing phpList schema before applying migration#383

Merged
TatevikGr merged 3 commits into
mainfrom
migrations
May 18, 2026
Merged

Check for existing phpList schema before applying migration#383
TatevikGr merged 3 commits into
mainfrom
migrations

Conversation

@TatevikGr
Copy link
Copy Markdown
Contributor

@TatevikGr TatevikGr commented May 18, 2026

Summary by CodeRabbit

  • Bug Fixes
    • Database initialization now detects already-initialized schemas and skips redundant migrations to avoid conflicts during installs/updates.
  • Chores
    • CI now includes a Doctrine schema validation step to catch schema mismatches before tests run.
  • Refactor
    • Improved entity relationship mappings to strengthen data consistency and prevent subtle synchronization issues.

Review Change Stack

Thanks for contributing to phpList!

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 18, 2026

Warning

Rate limit exceeded

@TatevikGr has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 56 minutes and 33 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 86bdcab7-d777-43bb-8022-4da31573cc72

📥 Commits

Reviewing files that changed from the base of the PR and between 739f943 and 612bcd4.

📒 Files selected for processing (1)
  • .github/workflows/ci.yml
📝 Walkthrough

Walkthrough

Adds an idempotency check to the MySQL initial-schema migration (skips if migrations table exists), declares inverse sides on two Doctrine many-to-one relations, and adds a CI step that runs php bin/console doctrine:schema:validate against the MySQL service.

Changes

Database Initialization Idempotency

Layer / File(s) Summary
Schema initialization guard
src/Migrations/Version20251028092901MySqlInit.php
The up() method creates a schema manager and checks if doctrine_migration_versions exists; if present, the migration exits with a message that the phpList schema is already initialized instead of executing the SQL setup.

Doctrine inverse-side mappings

Layer / File(s) Summary
AdminAttributeValue inverse mapping
src/Domain/Identity/Model/AdminAttributeValue.php
#[ORM\ManyToOne(..., inversedBy: 'attributeValues')] added to $attributeDefinition.
SubscriberList owner inverse mapping
src/Domain/Subscription/Model/SubscriberList.php
#[ORM\ManyToOne(..., inversedBy: 'ownedLists')] added to $owner.

CI: Doctrine schema validation

Layer / File(s) Summary
Validate Doctrine schema step
.github/workflows/ci.yml
New workflow step exports PHPLIST_DATABASE_* variables and runs php bin/console doctrine:schema:validate against the MySQL service prior to tests.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately summarizes the main change: adding logic to check for an existing phpList schema before applying the migration, which is the primary focus of the changes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch migrations

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/Migrations/Version20251028092901MySqlInit.php`:
- Around line 32-36: The skip check in Version20251028092901MySqlInit.php is
looking for Doctrine's internal table (`doctrine_migration_versions`) so your
migration is skipped prematurely; update the check to look for a table that
initial_schema.sql actually creates (e.g. `phplist_admin`) by changing the call
on $schemaManager->tablesExist(...) used inside the migration (the block that
calls $this->skipIf(...)) to reference 'phplist_admin' instead of
'doctrine_migration_versions' so the migration only skips when the phpList
schema is present.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: e6e91279-b27c-499f-b94b-acf2d5003ff5

📥 Commits

Reviewing files that changed from the base of the PR and between 428f65f and 2c80dec.

📒 Files selected for processing (1)
  • src/Migrations/Version20251028092901MySqlInit.php

Comment thread src/Migrations/Version20251028092901MySqlInit.php
@TatevikGr TatevikGr changed the base branch from dev to main May 18, 2026 12:57
@TatevikGr TatevikGr merged commit 53b1378 into main May 18, 2026
7 checks passed
@TatevikGr TatevikGr deleted the migrations branch May 18, 2026 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants