ReferenceIndividual lint rules
Constraint and index names
Configure explicit names and naming templates for keys, constraints, and indexes.
Checks primary keys, foreign keys, indexes, unique constraints, checks, and exclusion constraints.
Enable this opt-in rule under lint.rules.
Configuration
import { defineConfig } from '@mwillbanks/zenstack-zenlev'
export default defineConfig({
lint: {
rules: {
'zenlev/naming/constraint': [
'error',
{
kinds: ['index', 'foreign-key'],
templates: {
index: 'idx_{table}_{columns}',
'foreign-key': 'fk_{table}_{columns}',
},
explicit: true,
},
],
},
},
})Parameters
templatesets the fallback format.templatessupplies templates by kind usingprimary-key,foreign-key,index,unique,check, orexclusion.separatorjoins column lists and defaults to_.irregularanduncountablecustomize inflection.explicit: truerequires authored names.explicit: falserequires generated names. The check reports a coverage gap when the evidence cannot establish how a name was chosen.
See the rule overview for naming template variables.
All built-in rules accept the shared selectors.
Example
For orders with a foreign key on customer_id, use fk_orders_customer_id. Name the matching index idx_orders_customer_id.