afenda-database-patterns

Document and enforce AFENDA-NEXUS database schema patterns with Drizzle ORM and PostgreSQL.

Updated Feb 11, 2026
One-click install
npx skills add https://github.com/pohlai88/AFENDA-NEXUS2 --skill afenda-database-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: afenda-database-patterns
Source: https://github.com/pohlai88/AFENDA-NEXUS2/tree/main/.agents/skills/afenda-database-patterns
Command: npx skills add https://github.com/pohlai88/AFENDA-NEXUS2 --skill afenda-database-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides clear, actionable guidance and examples for adhering to AFENDA-NEXUS's specific database schema design, multi-tenancy implementation, and migration strategies using Drizzle ORM and PostgreSQL.

Core Features & Use Cases

  • Schema Design: Understand and implement composite primary keys, entity column helpers, and indexing strategies.
  • Multi-tenancy: Learn how to apply Row-Level Security (RLS) for robust tenant isolation.
  • Migrations: Follow best practices for creating, reviewing, and applying database migrations.
  • Drizzle ORM: Master conventions for defining schemas, writing queries, and leveraging type inference.
  • Use Case: When developing a new feature that requires database interaction, consult this Skill to ensure your schema adheres to AFENDA's standards for security, performance, and maintainability.

Quick Start

Show me an example of a Drizzle ORM schema definition for a new table that includes composite primary keys and tenant RLS.

Frequently Asked Questions about afenda-database-patterns

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

FAQPage Schema
How do I set up Row-Level Security (RLS) for multi-tenancy in PostgreSQL?

Row-Level Security (RLS) for multi-tenancy in PostgreSQL is implemented by applying tenant isolation policies directly to your database schema, ensuring robust data separation across different tenants.

What is the best way to define composite primary keys using Drizzle ORM?

The best way to define composite primary keys using Drizzle ORM is by following specific schema conventions that combine entity column helpers and indexing strategies to maintain data integrity and performance.

How do I manage database migrations safely with Drizzle ORM and PostgreSQL?

Managing database migrations safely with Drizzle ORM and PostgreSQL involves following established best practices for creating, reviewing, and applying migrations throughout their lifecycle to ensure schema consistency.

When should I use composite primary keys in my PostgreSQL schema design?

You should use composite primary keys in your PostgreSQL schema design when defining tables that require multi-column uniqueness constraints, often paired with entity column composition for maintainable structures.

Can I use Drizzle ORM type inference with multi-tenant database schemas?

Yes, you can use Drizzle ORM type inference with multi-tenant database schemas by adhering to specific conventions for defining schemas and writing queries that leverage type safety alongside Row-Level Security.