skillfed

drizzle-migrations

This skill guides you through Drizzle ORM's migration workflow for SQLite databases, covering schema definition, column types, and common changes like adding tables or indexes. Learn production-ready strategies for generating migrations, applying them in code, and managing relations between tables.

drizzle-migrations helps you generate and apply database schema changes with Drizzle ORM for SQLite.

AI-generated summary based on this skill's SKILL.md

164 27 MIT updated by curiositech

Install

curiositech/some_claude_skills/drizzle-migrations · repository language: TypeScript

CLI (skillfed)coming soon
git clone https://github.com/curiositech/some_claude_skills
cp -r some_claude_skills/.claude/skills/drizzle-migrations ~/.claude/skills/drizzle-migrations

Frequently asked questions

AI-generated answers based on this skill's SKILL.md and metadata

How do I create drizzle migrations for SQLite?

drizzle-migrations guides you through generating and applying migrations using Drizzle ORM. Start by defining your schema in a TypeScript file, then run `drizzle-kit generate sqlite` to create migration files. Execute migrations in your application using `db.run()` or the push workflow. The skill covers schema definition, column types, relations, and production deployment strategies.

What's the difference between drizzle db push and generate migrate?

drizzle-migrations explains that `db push` applies schema changes directly to your database without creating migration files—ideal for development. The `generate migrate` command creates explicit migration files that you version control and apply later, essential for production. Use `push` for rapid prototyping and `generate migrate` for managed schema evolution across environments.

How do I add a table or column with drizzle-migrations?

drizzle-migrations teaches you to modify your schema file by adding new table definitions or column properties, then run `drizzle-kit generate sqlite` to create a migration. The generated migration file contains the SQL to add your table or column. Review the migration, commit it to version control, and apply it using your application's migration runner or `db push`.

How do I set up foreign key relations in drizzle-migrations?

drizzle-migrations covers defining relations between SQLite tables using the `relations()` helper and `.references()` on columns. Define a foreign key column with a type matching the referenced table's primary key, then use `.references(() => otherTable.id)`. Relations enable type-safe joins and queries. Generate migrations after defining relations to ensure referential integrity constraints.

What are drizzle-migrations production best practices?

drizzle-migrations recommends versioning all migration files in your repository, testing migrations in a staging environment before production, and using transactions for multi-step changes. Always review generated migrations before applying them. Use explicit migration files rather than `push` in production. Monitor migration execution and maintain rollback procedures for critical deployments.

How do I create indexes and write type-safe queries?

drizzle-migrations shows how to add indexes using `.index()` on table definitions, then generate migrations to apply them. For queries, use Drizzle's query builder with `.select()`, `.where()`, `.join()`, and `.groupBy()` for type-safe operations. Aggregations like `.count()` and `.avg()` are built-in. Migrations ensure indexes exist before queries rely on them for performance.

SKILL.md

rendered from the published skill — quoted content, verbatim

Drizzle ORM Migrations

This skill helps you manage database schema changes using Drizzle ORM with SQLite.

When to Use

USE this skill for: - Adding new tables or modifying existing columns - Generating and running database migrations - Drizzle-specific query patterns and relations - SQLite schema best practices with Drizzle - Setting up Drizzle configuration

DO NOT use for:

(truncated - see the full file via the links below)

Read as markdown · JSON record · Browse the source repository

File tree — 1 file
.claude/skills/drizzle-migrations/SKILL.md

Related skills

Tags

schema-versioning orm-tooling database-automation sql-generation type-safe-queries migration-management sqlite-specific dev-to-prod-workflow