skills/drizzle-migration/SKILL.md
Use this skill for database schema changes with Drizzle ORM. Invoke when adding tables, columns, indexes, or modifying database structure.
npx skillsauth add gentamura/dotfiles drizzle-migrationInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Safe database schema changes following Drizzle ORM best practices.
Modify the schema file (e.g., src/db/schema.ts):
// Example: Adding a new column
export const users = pgTable('users', {
id: serial('id').primaryKey(),
email: varchar('email', { length: 255 }).notNull(),
// New column
avatarUrl: varchar('avatar_url', { length: 500 }),
});
drizzle-kit generate
Review the generated file in drizzle/ or your migrations folder.
Check for:
# Development
drizzle-kit migrate
# Or with custom script
bun run db:migrate
# Connect and inspect
psql -d your_database
# Check table structure
\d table_name
# Verify data integrity
SELECT count(*) FROM table_name;
// Schema
export const users = pgTable('users', {
// existing columns...
newColumn: varchar('new_column', { length: 100 }),
});
// Add with default first, then remove default if needed
newColumn: varchar('new_column').notNull().default(''),
export const users = pgTable('users', {
// columns...
}, (table) => ({
emailIdx: index('email_idx').on(table.email),
}));
export const posts = pgTable('posts', {
id: serial('id').primaryKey(),
authorId: integer('author_id')
.notNull()
.references(() => users.id),
});
psqlDocument rollback approach before applying:
## Migration: Add avatar_url to users
### Forward
- Adds nullable `avatar_url` column
### Rollback
- Safe to drop column (no data loss concerns)
- SQL: `ALTER TABLE users DROP COLUMN avatar_url;`
# Introspect current database
drizzle-kit introspect
# Compare with schema file
# Resolve differences
tools
Use this skill to break down requirements into user stories, acceptance criteria, and actionable tasks. Invoke when starting a new feature or receiving new requirements.
devops
Use this skill for release preparation and execution. Invoke when deploying to staging or production environments.
development
Use this skill to review pull requests against coding standards and best practices. Invoke when reviewing code changes before merge.
tools
Use this skill to create a pull request from current local changes. Invoke when the user asks to create a branch, commit, push, and open a PR.