Ultimate

X_ENTITY_COUNTS_INVALID

Means

references(…, { countedIn }) names no integer of its parent, or is no key to its primary key

Typical cause

a counter is an integer the database keeps on the parent, from a child key that references() that parent's primary key

Fix

x db gen "count likes" after postId: uuid().references(() => posts.id, { countedIn: () => posts.likeCount }), with likeCount: integer().default(0) on posts

Listed under Entity and database

This page as markdown