Skip to content

fix: add unique constraint on component name per site#861

Open
mvanhorn wants to merge 1 commit intoBeaconCMS:mainfrom
mvanhorn:fix/650-component-unique-name
Open

fix: add unique constraint on component name per site#861
mvanhorn wants to merge 1 commit intoBeaconCMS:mainfrom
mvanhorn:fix/650-component-unique-name

Conversation

@mvanhorn
Copy link
Copy Markdown

Summary

Adds a unique constraint on [:site, :name] for components to prevent duplicate component names within a site. Duplicate names cause compilation issues since function overloading is not supported.

Changes

  • lib/beacon/content/component.ex: Added unique_constraint([:site, :name]) to the changeset pipeline
  • lib/beacon/migrations/v007.ex: New migration creating the unique index on beacon_components table
  • lib/beacon/migration.ex: Bumped @current_version from 6 to 7

Follows the same pattern as existing unique constraints on pages (:path, :site) and error pages (:status, :site).

Fixes #650

This contribution was developed with AI assistance (Claude Code).

Adds a unique_constraint on [:site, :name] to the Component changeset
and creates migration V007 with the corresponding database index.
This prevents duplicate component names within a site which would cause
compilation issues since function overloading is not supported.
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.

Components - validate unique name per site

1 participant