db-schema-change

star 271

Use when adding/modifying database tables or columns in Drizzle ORM schema

hiroppy By hiroppy schedule Updated 2/13/2026

name: db-schema-change description: Use when adding/modifying database tables or columns in Drizzle ORM schema

DB Schema Change Skill

Checklist (MUST complete all)

  • Add createdAt: text("created_at").notNull() to new tables
  • Add updatedAt: text("updated_at").notNull() to new tables
  • Specify onDelete for all foreign keys (cascade/set null)
  • Add index for frequently queried columns
  • Update packages/db/src/schema/relations.ts if adding relations
  • Run migration: pnpm --filter @mf-dashboard/db exec drizzle-kit generate
  • Update architecture/database-schema.md with new ERD

File Locations

  • Schema: packages/db/src/schema/tables.ts
  • Relations: packages/db/src/schema/relations.ts
  • Repositories: packages/db/src/repositories/
  • Types: packages/db/src/types.ts

Template

export const newTable = sqliteTable("new_table", {
  id: integer("id").primaryKey({ autoIncrement: true }),
  // ... your columns ...
  createdAt: text("created_at").notNull(),
  updatedAt: text("updated_at").notNull(),
});

Foreign Key Template

foreignKeyColumn: integer("foreign_key_column")
  .notNull()
  .references(() => parentTable.id, { onDelete: "cascade" }),

Index Template

export const myTable = sqliteTable(
  "my_table",
  {
    // columns...
  },
  (table) => [index("my_table_column_idx").on(table.columnName)],
);
Install via CLI
npx skills add https://github.com/hiroppy/mf-dashboard --skill db-schema-change
Repository Details
star Stars 271
call_split Forks 31
navigation Branch main
article Path SKILL.md
More from Creator