Skip to content

Change unique course fields per tenant - #128

Merged
andreia merged 2 commits into
4.xfrom
unique_course_fields_per_tenant
Sep 10, 2026
Merged

Change unique course fields per tenant#128
andreia merged 2 commits into
4.xfrom
unique_course_fields_per_tenant

Conversation

@andreia

@andreia andreia commented Sep 8, 2026

Copy link
Copy Markdown
Member

Details

Change unique course fields (name, slug, and external_id) per tenant.

php artisan vendor:publish --tag=filament-lms-migrations
php artisan migrate

Note

Medium Risk
Schema migration changes uniqueness rules on a core table; misconfiguration or partial deploy could affect course creation, but behavior is gated on tenancy config and covered by tests.

Overview
Enables separate tenants to reuse the same course name, slug, and external_id without colliding, aligning DB constraints and admin validation with multi-tenant LMS usage.

When tenancy is enabled and the tenant column exists on lms_courses, a new published migration drops global unique indexes on those three columns and adds composite uniques on [tenant_column, column]. The migration is idempotent on re-run, skips work when tenancy is off, and intentionally leaves down() empty so rollback does not try to restore global uniques after cross-tenant duplicates may exist.

Course admin forms now use scopedUnique instead of unique on name, external_id, and slug so Filament validation matches the tenant-scoped indexes. Feature tests cover index shape, no-op when tenancy is disabled, and rollback behavior.

Reviewed by Cursor Bugbot for commit febf572. Bugbot is set up for automated code reviews on this repo. Configure here.

@andreia
andreia requested a review from swilla September 8, 2026 23:49

@cursor cursor 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.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 1ac487e. Configure here.

Comment thread src/Resources/CourseResource.php
@andreia
andreia merged commit 6ff02d8 into 4.x Sep 10, 2026
16 checks passed
@andreia
andreia deleted the unique_course_fields_per_tenant branch September 10, 2026 21:08
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.

1 participant