بنقرة واحدة
drizzle-patterns
Guidelines for defining Drizzle models, schemas, and migrations in the project.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Guidelines for defining Drizzle models, schemas, and migrations in the project.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
| name | drizzle-patterns |
| description | Guidelines for defining Drizzle models, schemas, and migrations in the project. |
This skill provides the standard patterns and conventions for database modeling and schema validation within the project.
The project uses Drizzle ORM with PostgreSQL (drizzle-orm/pg-core) and TypeBox for runtime validation and static type generation.
All models should follow these conventions:
src/context/permission/context-permission.model.ts).appPgTable from ../../core/database instead of pgTable to ensure consistent base columns. Samething for appPgEnum instead of pgEnummetadataTimestampColumns in the table definition.[name]Model.import { integer, serial } from 'drizzle-orm/pg-core';
import { metadataTimestampColumns, appPgTable } from '../../core/database';
export const exampleModel = appPgTable(
'table_name',
{
id: serial().primaryKey(),
// ... other columns
...metadataTimestampColumns
},
(table) => [
// Constraints, indexes
]
);
Schema definitions reside in schema.ts files (e.g., src/context/permission/schema.ts).
createSelectSchema(model) from drizzle-orm/typebox.createInsertSchema(model).Type.Interface or Type.Omit/Partial to refine schemas for specific API endpoints (e.g., omitting id or contextId from insertion).satisfies FastifySchema.suffix: .model.ts, variable: [domain]Modelsuffix: schema.ts, variables: Select[Domain]Schema, Insert[Domain]Schema, Create[Domain]Schemasuffix: .interface.ts, variable: [Domain]Type{ onDelete: 'cascade' } for critical foreign key relations like contextId.uniqueIndex in the table extra properties.Nullable helper in schema.ts for optional fields that can be null in the database.