« All posts

A CRM That Changes Its Schema via Typed Tools, Not LLM-Written SQL

A Show HN CRM lets users edit database schemas via chat using typed tools instead of LLM-generated SQL, with dual validation and safe undo.

A Show HN project presents a CRM whose database schema is modified through natural language rather than hand-written SQL or generated code. Instead of asking a large language model to produce SQL directly, the system exposes four typed tools—create tables, add column, rename column, change column type—and lets the model pick one along with structured arguments. The application itself generates the SQL, which structurally prevents SQL hallucination and rules out unsupported operations like DROP, since no such tool exists in the vocabulary.

Safety comes from validating twice: the API's strict mode guarantees arguments match a tool's schema, while a separate planning step checks them against live database state—existing tables, taken column names, type compatibility, and NOT NULL constraints. The model never sees stored data values, only table and column names and types, limiting exposure of user data to the LLM's context.

Every migration is stored alongside its reverse, enabling a last-in-first-out undo system: only the most recent still-active change can be reverted, and destructive undos that would erase data require explicit confirmation. If a reverse migration no longer matches the current data, the database rejects the operation instead of silently corrupting state.

Built with Next.js 16, Drizzle, and Postgres in Docker, the project deliberately skips LangChain and treats migrations as a runtime concern rather than a static schema file, introspecting information_schema and pg_catalog directly. Scope is limited to single-user, local use, with no authentication, relationships, or row/table deletion support.