schema-design

Design and modify Drizzle ORM schemas with relationships, constraints, and indexes.

21|2|Updated Nov 5, 2023
One-click install
npx skills add https://github.com/sgcarstrends/sgcarstrends --skill schema-design-sgcarstrends
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: schema-design
Source: https://github.com/sgcarstrends/sgcarstrends/tree/main/.claude/skills/schema-design
Command: npx skills add https://github.com/sgcarstrends/sgcarstrends --skill schema-design-sgcarstrends

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill assists in designing and modifying database schemas using Drizzle ORM with proper relationships and constraints.

Core Features & Use Cases

  • Table definitions with relationships and constraints.
  • Indexing and performance considerations.
  • Migration planning and evolving schemas safely.

Quick Start

Create a new table with a foreign key relationship to an existing users table.

Frequently Asked Questions about schema-design

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

FAQPage Schema
How do I design a database schema with Drizzle ORM?

Design a Drizzle schema by defining tables with columns, data types, and constraints in your schema file. Use relations to connect tables, add indexes for performance, and follow camelCase naming conventions. Drizzle generates migrations automatically for your database layer.

How do I create foreign key relationships in Drizzle?

Define foreign key relationships using Drizzle's relation syntax when creating tables. Specify the referenced table and column, and Drizzle enforces the constraint. This ensures data integrity across your schema and integrates with the migration workflow.

When should I add indexes to my database schema?

Add indexes to columns frequently used in WHERE clauses, joins, or sorting to improve query performance. Drizzle schema-design supports explicit index configuration. Plan indexes during initial schema design and migrations to optimize your database layer.

How do I modify an existing Drizzle schema safely?

Modify schemas by altering table definitions in your schema file, then generate migrations through Drizzle's migration workflow. You can rename, drop, or add columns and constraints. Migrations ensure safe evolution while maintaining data integrity.

Can I use Drizzle schema-design with an existing database project?

Yes. Integrate Drizzle schema-design into existing projects by defining tables in your drizzle.config.ts and migrations folder. Drizzle supports evolving schemas incrementally through the migration system without requiring a full rebuild.

What constraints can I enforce in a Drizzle schema?

Drizzle supports primary keys, foreign keys, unique constraints, not-null, and default values in schema definitions. Explicit constraints ensure data validity and relationships. Configure them during table creation or schema modifications.