gorm-composite-primary-key
CommunityEnsure unique records with composite keys
Software Engineering#migrations#associations#gorm#querying#primary key#composite primary key#autoincrement
Authorliurida
Version1.0.0
Installs0
System Documentation
What problem does it solve?
When a single column cannot uniquely identify a record, composite primary keys let you enforce multi-column uniqueness at the schema level so related queries, joins, and associations remain correct and consistent.
Core Features & Use Cases
- Define multi-column primary keys by marking each field that participates in the key so migrations and constraints reflect the combined uniqueness.
- Integer key handling with autoincrement disabled for integer fields that are part of a composite primary key to prevent unintended value generation.
- Associations and join tables automatically include all key columns for many-to-many relations so preloads, joins, and foreign keys remain accurate.
- Use case: Localized product catalogs where (product_id, language_code) uniquely identify a translation record and must be queried and joined reliably.
Quick Start
Create a GORM model by marking every field that composes the unique key with the primary key tag and disable autoincrement for integer key fields when necessary.
Dependency Matrix
Required Modules
None requiredComponents
references
💻 Claude Code Installation
Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.
Please help me install this Skill: Name: gorm-composite-primary-key Download link: https://github.com/liurida/gorm-development-skill/archive/main.zip#gorm-composite-primary-key Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
Agent Skills Search Helper
Install a tiny helper to your Agent, search and equip skill from 471,000+ vetted skills library on demand.