Skip to content

fix: broken migrations and smoke test against real MariaDB#468

Merged
nielsdrost7 merged 3 commits into
developfrom
claude/github-actions-workflows-hEB8a
Jun 6, 2026
Merged

fix: broken migrations and smoke test against real MariaDB#468
nielsdrost7 merged 3 commits into
developfrom
claude/github-actions-workflows-hEB8a

Conversation

@nielsdrost7

@nielsdrost7 nielsdrost7 commented Jun 5, 2026

Copy link
Copy Markdown
Collaborator
  • recurring_invoices: remove FK to non-existent document_groups table

  • payments: add explicit index on invoice_id so MariaDB handles the
    nullable ON DELETE SET NULL FK constraint (errno 150 fix)

  • report_templates: delete duplicate migration in ReportBuilder module
    (identical file already exists in Core)

  • smoke.yml: switch from SQLite to MariaDB 10.11 service so FK
    constraint errors are caught; add push/pull_request triggers on
    master and develop so it runs automatically

  • quickstart.yml: uncomment and wire up MariaDB service

  • phpunit.yml: bump PHP 8.3 → 8.4, add pdo_sqlite extension

  • yarn-update.yml: bump PHP 8.2 → 8.4, fix extension names

https://claude.ai/code/session_01Q4fwmdZcuFrrB6UQDeGWKd

Summary by CodeRabbit

  • Refactor

    • Recurring invoice numbering changed from free-text to a dropdown selector for clearer selection and fewer entry errors.
  • Bug Fixes / Improvements

    • Tightened invoice/payment database constraints to reduce risk of orphaned or inconsistent records.
    • Removed obsolete report-templates migration.
  • Chores

    • Testing workflows now use MariaDB and run migrations.
    • CI PHP runtime upgraded to 8.4.

claude added 2 commits June 5, 2026 08:35
- recurring_invoices: remove FK to non-existent document_groups table
- payments: add explicit index on invoice_id so MariaDB handles the
  nullable ON DELETE SET NULL FK constraint (errno 150 fix)
- report_templates: delete duplicate migration in ReportBuilder module
  (identical file already exists in Core)

- smoke.yml: switch from SQLite to MariaDB 10.11 service so FK
  constraint errors are caught; add push/pull_request triggers on
  master and develop so it runs automatically
- quickstart.yml: uncomment and wire up MariaDB service
- phpunit.yml: bump PHP 8.3 → 8.4, add pdo_sqlite extension
- yarn-update.yml: bump PHP 8.2 → 8.4, fix extension names

https://claude.ai/code/session_01Q4fwmdZcuFrrB6UQDeGWKd
…rop SQLite

recurring_invoices:
- rename document_group_id → numbering_id; add FK to numbering table
  matching the same pattern invoices uses (onUpdate cascade, onDelete restrict)
- update RecurringInvoiceFactory: Numbering instead of missing DocumentGroup
- update RecurringInvoiceForm: numbering_id Select with relationship

payments:
- invoice_id is NOT NULL (payment requires an invoice)
- restore explicit constraint name payments_invoice_id_foreign
  with onUpdate cascade / onDelete restrict

testing env:
- .env.testing.example: replace SQLite :memory: with MySQL settings
- phpunit.yml: add MariaDB 10.11 service, set DB env vars,
  uncomment migration step so tests run against real MariaDB

https://claude.ai/code/session_01Q4fwmdZcuFrrB6UQDeGWKd
@coderabbitai

coderabbitai Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 681934e5-db1d-4d7b-8853-f3fea03fc08a

📥 Commits

Reviewing files that changed from the base of the PR and between 427285d and 6fe3453.

📒 Files selected for processing (1)
  • Modules/Invoices/Filament/Company/Resources/RecurringInvoices/Schemas/RecurringInvoiceForm.php
🚧 Files skipped from review as they are similar to previous changes (1)
  • Modules/Invoices/Filament/Company/Resources/RecurringInvoices/Schemas/RecurringInvoiceForm.php

📝 Walkthrough

Walkthrough

Switches test environment from SQLite to MariaDB, updates CI workflows to PHP 8.4 and runs migrations in CI, replaces recurring-invoices' document_group_id with numbering_id across migration/factory/form, and makes payments.invoice_id non-nullable with a named foreign key.

Changes

Test Environment Infrastructure

Layer / File(s) Summary
Testing environment database configuration
.env.testing.example
Testing environment example configuration switches from SQLite in-memory to MySQL with explicit DB_HOST, DB_PORT, DB_DATABASE, DB_USERNAME, DB_PASSWORD for invoiceplane_test.
MariaDB service provisioning in workflows
.github/workflows/phpunit.yml, .github/workflows/quickstart.yml
PHPUnit and quickstart workflows now define MariaDB 10.11 service containers with health checks and workflow-level environment variables connecting Laravel to the containerized database for testing.
PHP version, extensions, and migrations in CI
.github/workflows/phpunit.yml, .github/workflows/quickstart.yml, .github/workflows/smoke.yml, .github/workflows/yarn-update.yml
Workflows updated to PHP 8.4, phpunit workflow enables running php artisan migrate --force --env=testing before tests, and php-extensions lists adjusted (including pdo_mysql, pdo_sqlite, and other required extensions).

Recurring Invoices Foreign Key Refactoring

Layer / File(s) Summary
Recurring invoices table schema update
Modules/Invoices/Database/Migrations/2010_01_01_000023_create_recurring_invoices_table.php
Migration replaces nullable document_group_id column with nullable numbering_id column and introduces a named foreign key constraint (recurring_invoices_numbering_id_foreign) referencing the numbering table with cascade-on-update and restrict-on-delete actions.
Factory and form updates for numbering reference
Modules/Invoices/Database/Factories/RecurringInvoiceFactory.php, Modules/Invoices/Filament/Company/Resources/RecurringInvoices/Schemas/RecurringInvoiceForm.php
RecurringInvoiceFactory imports Numbering model and generates numbering_id from a randomly selected record using null-safe access, and RecurringInvoiceForm replaces document_group_id TextInput with a numbering_id Select field bound to the numbering relationship.

Payments Invoice ID Constraint Enforcement

Layer / File(s) Summary
Invoice ID constraint and nullability update
Modules/Payments/Database/Migrations/2010_01_01_000024_create_payments_table.php
Payments table migration makes invoice_id non-nullable (changed from nullable unsigned big integer) and replaces the unnamed foreign key constraint with a named constraint (payments_invoice_id_foreign) that cascades on update and restricts deletes to invoices.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • InvoicePlane/InvoicePlane-v2#295: Both PRs modify test-environment database configuration and phpunit setup behavior; PR #295 changes tests to SQLite in-memory while this PR configures MariaDB and runs migrations.

Suggested labels

codex

Poem

🐇 I hopped to CI where MariaDB grows,
I swapped group ids for numbering rows,
PHP 8.4 hums the test-time song,
Payments bound, constraints made strong,
A happy hare skips through the code!

🚥 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 title accurately describes the main changes: fixing broken migrations (recurring_invoices FK, payments table modifications, duplicate migration removal) and smoke test configuration against real MariaDB.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/github-actions-workflows-hEB8a

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 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 @.github/workflows/phpunit.yml:
- Line 36: The workflow is using a floating actions/checkout@v4 ref and leaves
persist-credentials enabled; update the checkout step (the line containing
"uses: actions/checkout@v4") to a pinned release (e.g., a specific patch tag or
the action's commit SHA instead of the floating `@v4`) and add the with:
persist-credentials: false option to the same step so the job does not retain
the repo auth token/SSH key after checkout.

In
`@Modules/Invoices/Filament/Company/Resources/RecurringInvoices/Schemas/RecurringInvoiceForm.php`:
- Around line 23-25: The Select field created with Select::make('numbering_id')
currently relies on Filament's auto-generated label; update this field to
include an explicit translated label using trans(), e.g. call
->label(trans('...')) on the Select instance so the user-facing text follows the
translation guideline while keeping the existing
->relationship('numbering','name') and ->default(null) intact.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 115dd06d-09e3-4bd7-9208-aafcdc7b48e2

📥 Commits

Reviewing files that changed from the base of the PR and between 3b65f99 and 427285d.

📒 Files selected for processing (10)
  • .env.testing.example
  • .github/workflows/phpunit.yml
  • .github/workflows/quickstart.yml
  • .github/workflows/smoke.yml
  • .github/workflows/yarn-update.yml
  • Modules/Invoices/Database/Factories/RecurringInvoiceFactory.php
  • Modules/Invoices/Database/Migrations/2010_01_01_000023_create_recurring_invoices_table.php
  • Modules/Invoices/Filament/Company/Resources/RecurringInvoices/Schemas/RecurringInvoiceForm.php
  • Modules/Payments/Database/Migrations/2010_01_01_000024_create_payments_table.php
  • Modules/ReportBuilder/Database/Migrations/2025_10_26_create_report_templates_table.php
💤 Files with no reviewable changes (1)
  • Modules/ReportBuilder/Database/Migrations/2025_10_26_create_report_templates_table.php

DB_PASSWORD: root

steps:
- uses: actions/checkout@v4

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify unpinned action refs and checkout credential persistence in workflows
rg -nP '^\s*uses:\s*[^@\s]+@(v?\d+(\.\d+)*)\s*$' .github/workflows
rg -nP '^\s*-\s*uses:\s*actions/checkout@' .github/workflows -A4 -B1

Repository: InvoicePlane/InvoicePlane-v2

Length of output: 2442


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the phpunit workflow around the checkout step
echo "---- phpunit.yml (around checkout) ----"
nl -ba .github/workflows/phpunit.yml | sed -n '1,120p'

# Check whether persist-credentials is set anywhere (especially in phpunit.yml)
echo "---- persist-credentials occurrences ----"
rg -n "persist-credentials" .github/workflows .github/actions || true

# Confirm whether phpunit.yml sets a 'with:' block on the checkout step
echo "---- checkout step in phpunit.yml ----"
rg -n "uses:\s*actions/checkout@" .github/workflows/phpunit.yml -n -C 5

Repository: InvoicePlane/InvoicePlane-v2

Length of output: 173


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "phpunit.yml line count:"
wc -l .github/workflows/phpunit.yml

echo "---- phpunit.yml (first 120 lines) ----"
cat -n .github/workflows/phpunit.yml | sed -n '1,120p'

echo "---- persist-credentials occurrences ----"
rg -n "persist-credentials" .github/workflows .github/actions || true

echo "---- checkout step in phpunit.yml ----"
rg -n "uses:\s*actions/checkout@" .github/workflows/phpunit.yml -C 5 || true

Repository: InvoicePlane/InvoicePlane-v2

Length of output: 2243


🌐 Web query:

actions/checkout persist-credentials default value

💡 Result:

The default value for the persist-credentials input in actions/checkout is true [1][2][3]. When set to true, this setting configures the repository's local git configuration with the authentication token or SSH key used for the checkout [1][4][5]. This allows subsequent git commands (such as git fetch or git push) within the workflow to use these credentials automatically [1][3]. The action removes these credentials from the local configuration during the post-job cleanup process [1][4][5]. Users can set persist-credentials to false to opt out of this behavior [1][5].

Citations:


Pin actions/checkout and disable persisted credentials in phpunit.yml.

  • .github/workflows/phpunit.yml uses a floating ref (actions/checkout@v4) and does not set persist-credentials, whose default is true—so checkout keeps the auth token/SSH key in the local git config for the remainder of the job.

Current state:

      - uses: actions/checkout@v4
Suggested hardening patch
-      - uses: actions/checkout@v4
+      - uses: actions/checkout@<full_commit_sha_for_v4>
+        with:
+          persist-credentials: false
🧰 Tools
🪛 zizmor (1.25.2)

[warning] 36-36: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false

(artipacked)


[error] 36-36: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy)

(unpinned-uses)

🤖 Prompt for 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.

In @.github/workflows/phpunit.yml at line 36, The workflow is using a floating
actions/checkout@v4 ref and leaves persist-credentials enabled; update the
checkout step (the line containing "uses: actions/checkout@v4") to a pinned
release (e.g., a specific patch tag or the action's commit SHA instead of the
floating `@v4`) and add the with: persist-credentials: false option to the same
step so the job does not retain the repo auth token/SSH key after checkout.

@nielsdrost7

Copy link
Copy Markdown
Collaborator Author

@coderabbitai autofix

@coderabbitai

coderabbitai Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

Fixes Applied Successfully

Fixed 1 file(s) based on 2 unresolved review comments.

Files modified:

  • Modules/Invoices/Filament/Company/Resources/RecurringInvoices/Schemas/RecurringInvoiceForm.php

Commit: 6fe3453605ffb21966766c864ba9caf00180fb25

The changes have been pushed to the claude/github-actions-workflows-hEB8a branch.

Time taken: 2m 16s


⚠️ 1 file(s) could not be committed — the agent does not have permission to push to .github/workflows/. Please apply these changes manually:

.github/workflows/phpunit.yml — 1 change:

Lines 33–39
       DB_PASSWORD: root
 
     steps:
-      - uses: actions/checkout@v4
+      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683  # v4.2.2
+        with:
+          persist-credentials: false
 
       - name: Setup PHP with Composer
         uses: ./.github/actions/setup-php-composer

Fixed 1 file(s) based on 2 unresolved review comments.

Co-authored-by: CodeRabbit <noreply@coderabbit.ai>
@nielsdrost7 nielsdrost7 merged commit fe9b995 into develop Jun 6, 2026
5 of 6 checks passed
@nielsdrost7 nielsdrost7 deleted the claude/github-actions-workflows-hEB8a branch June 6, 2026 03:14
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