Schema rules
3 rules that validate database schema design: primary keys, timestamps, and relation configuration. They run against entity-relation data extracted from Prisma schema files, TypeORM and MikroORM entity decorators, or Drizzle table declarations.
| Rule | Severity | What it catches |
|---|---|---|
require-primary-key | error | Entity without a primary key column |
require-timestamps | info | Entity missing createdAt/updatedAt columns |
require-cascade-rule | info | Relation missing explicit onDelete behavior |
require-primary-key
Scope: Schema
Detects entities that have no primary key column.
Why: Entities without primary keys cannot be uniquely identified, breaking lookups, joins, and ORM operations. Every table should have an explicit primary key.
model Product {
name String
price Float
}require-timestamps
Scope: Schema
Detects entities missing createdAt/updatedAt timestamp columns.
Entities whose every column is a primary key or a relation's own column are skipped.
Why: Timestamp columns are essential for auditing, debugging, and data integrity. Without them, there is no way to know when a record was created or last modified.
model Post {
id Int @id @default(autoincrement())
title String
body String
}require-cascade-rule
Scope: Schema
Detects owning-side relations (ManyToOne/OneToOne) without an explicit onDelete behavior.
Why: Without an explicit onDelete, the database default applies, usually RESTRICT or NO ACTION. Deleting a parent record then fails with a constraint error. An explicit cascade behavior also makes the data model self-documenting.
model Comment {
id Int @id @default(autoincrement())
post Post @relation(fields: [postId], references: [id])
postId Int
}