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.