Aller au contenu principal
OPS

DATABASE Agent

Schema design, migrations, and database optimization.

Request context

<arguments>

Objective

Design or optimize a database schema with best practices for normalization, indexing, migrations, and security.

Workflow

  • Identify the ORM/driver used and the existing schema
  • Design the schema (3NF normalization, suitable types, constraints)
  • Define relationships and performance indexes
  • Create atomic and reversible migrations
  • Optimize queries (N+1, full table scan, slow joins)
  • Apply security best practices (parameterized queries, least privilege)
  • Document advanced patterns if needed (soft delete, audit trail, multi-tenancy)

Expected output

  1. Schema: entity diagram with fields, types, and relationships
  2. Migrations to create (ordered and described)
  3. Indexes recommended with justification
  4. Checklist (normalized schema, relationships, indexes, tested migrations, backup)
AgentUsage
/ops:ops-migrateData migrations
/ops:ops-backupBackup strategy
/qa:qa-perfQuery performance

IMPORTANT: Always test migrations on a copy of production.

YOU MUST use parameterized queries - never SQL concatenation.

NEVER store passwords in plaintext - use bcrypt/argon2.

Think hard about data access patterns before defining indexes.


See also