new-db-table

Creates Drizzle ORM tables, Zod schemas, and D1 migrations for Cloudflare Workers projects.

1|Updated Jul 8, 2026
One-click install
npx skills add https://github.com/fayazara/bangalore.fyi --skill new-db-table-fayazara
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: new-db-table
Source: https://github.com/fayazara/bangalore.fyi/tree/main/.agents/skills/new-db-table
Command: npx skills add https://github.com/fayazara/bangalore.fyi --skill new-db-table-fayazara

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Adding a database table in a TanStack Start + Cloudflare D1 project involves several error-prone steps: writing Drizzle schema definitions with SQLite-specific column types, deriving Zod validation schemas, and generating then applying migrations with wrangler. This Skill guides the entire workflow and prevents common mistakes like using Postgres column types on D1. ## Core Features & Use Cases - Schema Definition: Add tables to src/db/schema.ts using Drizzle's SQLite column builders with correct patterns for primary keys, timestamps, booleans, and JSON columns. - Type and Validation Exports: Generate inferred TypeScript types and drizzle-zod insert/select schemas with .pick() restrictions so callers cannot set server-managed fields. - Migration Workflow: Run db:generate and db:migrate in the correct order for local D1, and db:migrate:prod for remote databases. - Use Case: When a user says "I need a posts table with a title and author", the Skill produces the table definition, Zod schemas, migration commands, and example CRUD queries ready to use in server functions or API routes. ## Quick Start Ask the AI to add a new database table, for example: "Add a posts table with title, body, and authorId fields to the database."

Frequently Asked Questions about new-db-table

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a new database table with Drizzle ORM and Cloudflare D1?

Define the table in src/db/schema.ts using Drizzle's SQLite column builders like sqliteTable, text, and int, then export inferred types and drizzle-zod schemas. Run npm run db:generate to create the SQL migration and npm run db:migrate to apply it to local D1.

How to generate and apply Drizzle migrations on Cloudflare D1?

Run npm run db:generate to produce a SQL migration file in the drizzle directory, then npm run db:migrate to apply it locally via wrangler. For production, use npm run db:migrate:prod to apply migrations to the remote D1 database.

Can I use Postgres column types like varchar or serial on Cloudflare D1?

No, D1 is SQLite-based, so Postgres types like varchar and serial do not apply. Use text for strings and int with primaryKey autoIncrement for identifiers, and add mode timestamp for date columns stored as integers.

Why should I avoid drizzle-kit push in a D1 project?

This workflow does not use drizzle-kit push; instead it generates versioned SQL migration files and applies them with wrangler. This keeps a migration history and lets local and remote D1 databases be updated in a controlled, repeatable way.

How do I restrict which fields clients can insert with drizzle-zod?

Build the insert schema with createInsertSchema and chain .pick() to whitelist only client-settable fields such as title and body. This prevents callers from setting server-managed fields like id or createdAt.