Skip to main content
skill CX Codex

database-testing · proffesor-for-testing — Claude Code skill: database tests and setup

database-testing is a Claude Code skill for checking database schemas, data integrity, migrations, transactions, and query performance. It applies to data persistence checks and schema changes.

MIT 146 installs ★ 533 updated 2026-10-25

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add proffesor-for-testing/agentic-qe --skill database-testing -a claude-code
Open on GitHub

What database-testing does

The skill guides tests for table structure, constraints, and relationships between records. It covers forward migrations and rollbacks, data preservation, concurrent transaction isolation, and query speed.

Migration examples call for testing in staging before production deployment. The snippets use db, migrate, and rollback; they do not name a specific database or library.

What it helps with

  • check tables and columns against an expected schema
  • catch duplicate values and broken foreign-key references
  • test migration rollback and data preservation
  • find isolation issues in concurrent transactions
  • measure query performance and index usage

Example prompts for the agent

  • Check whether the users table matches the expected schema.
  • Test add-users-table by applying it and rolling it back.
  • Check isolation for two concurrent transactions that withdraw funds.

How to install database-testing

1Skills CLI (Vercel)

npx skills add proffesor-for-testing/agentic-qe --skill database-testing -a claude-code

2Manually: put the files in place

~/.claude/skills/database-testing/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/database-testing/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about database-testing

How do I install database-testing in Claude Code?

Run npx skills add proffesor-for-testing/agentic-qe --skill database-testing -a claude-code. The skill file is placed at ~/.claude/skills/database-testing/SKILL.md.

What does database-testing do?

It guides tests for database schemas and constraints, migrations, data integrity, transactions, and query performance.

What should migration tests cover?

Check that the migration applies and rolls back, and that existing data remains intact.

Source text

SKILL.md · MIT
---
name: database-testing
description: "Database schema validation, data integrity testing, migration testing, transaction isolation, and query performance. Use when testing data persistence, ensuring referential integrity, or validating database migrations."
category: specialized-testing
priority: high
tokenEstimate: 900
agents: [qe-test-data-architect, qe-test-executor, qe-performance-tester]
implementation_status: optimized
optimization_version: 1.0
last_optimized: 2025-12-02
dependencies: []
quick_reference_card: true
tags: [database, schema, migration, transactions, integrity, sql, performance]
trust_tier: 3
validation:
  schema_path: schemas/output.json
  validator_path: scripts/validate-config.json
  eval_path: evals/database-testing.yaml
---

# Database Testing

<default_to_action>
When testing database operations:
1. VALIDATE schema (tables, columns, constraints exist as expected)
2. TEST data integrity (unique, foreign key, check constraints)
3. VERIFY migrations (forward works, rollback works, data preserved)
4. CHECK transaction isolation (ACID properties, concurrent access)
5. MEASURE query performance (indexes used, execution time)

**Quick DB Testing Checklist:**
- Schema matches specification
- Unique constraints prevent duplicates
- Foreign keys prevent orphaned records
- Migrations are reversible
- Transactions roll back on error

**Critical Success Factors:**
- Database bugs cause data loss/corruption (catastrophic)
- Test migrations in staging before production
- Transaction tests catch concurrency bugs
</default_to_action>

## Quick Reference Card

### When to Use
- New table/schema creation
- Migration development
- Data integrity validation
- Query performance optimization

### Database Test Types
| Type | Focus | When |
|------|-------|------|
| **Schema** | Structure correct | Table creation |
| **Integrity** | Constraints work | Data operations |
| **Migration** | Up/down work | Schema changes |
| **Transaction** | ACID properties | Concurrent access |
| **Performance** | Query speed | Optimization |

---

## Schema Testing

```javascript
test('users table has correct schema', async () => {
  const schema = await db.raw(`
    SELECT column_name, data_type, is_nullable
    FROM information_schema.columns
    WHERE table_name = 'users'
  `);

  expect(schema).toContainEqual({
    column_name: 'id',
    data_type: 'integer',
    is_nullable: 'NO'
  });

  expect(schema).toContainEqual({
    column_name: 'email',
    data_type: 'character varying',
    is_nullable: 'NO'
  });
});
```

---

## Data Integrity Testing

```javascript
test('email must be unique', async () => {
  await db.users.create({ email: '[email protected]' });

  await expect(
    db.users.create({ email: '[email protected]' })
  ).rejects.toThrow('unique constraint violation');
});

test('foreign key prevents orphaned records', async () => {
  const user = await db.users.create({ email: '[email protected]' });
  await db.orders.create({ userId: user.id, total: 100 });

  await expect(
    db.users.delete({ id: user.id })
  ).rejects.toThrow('foreign key constraint');
});
```

---

## Migration Testing

```javascript
test('migration is reversible', async () => {
  await migrate('add-users-table');

  // Table exists after migration
  const tables = await db.raw(`SELECT table_name FROM information_schema.tables`);
  expect(tables.map(t => t.table_name)).toContain('users');

  await rollback('add-users-table');

  // Table gone after rollback
  const tablesAfter = await db.raw(`SELECT table_name FROM information_schema.tables`);
  expect(tablesAfter.map(t => t.table_name)).not.toContain('users');
});

test('migration preserves existing data', async () => {
  await db.users.create({ email: '[email protected]' });

  await migrate('add-age-column');

  const user = await db.users.findOne({ email: '[email protected]' });
  expect(user).toBeDefined();
  expect(user.age).toBeNull(); // New column, null default
});
```

---

## Transaction Testing

```javascript
test('transaction rolls back on error', async () => {
  const initialCount = await db.users.count();

  try {
    await db.transaction(async (trx) => {
      await trx('users').insert({ email: '[email protected]' });
      await trx('users').insert({ email: '[email protected]' });
      throw new Error('Rollback test');
    });
  } catch (error) { /* Expected */ }

  expect(await db.users.count()).toBe(initialCount);
});

test('concurrent transactions isolated', async () => {
  const user = await db.users.create({ balance: 100 });

  // Two concurrent withdrawals (race condition test)
  await Promise.all([
    db.transaction(async (trx) => {
      const current = await trx('users').where({ id: user.id }).first();
      await trx('users').update({ balance: current.balance - 50 });
    }),
    db.transaction(async (trx) => {
      const current = await trx('users').where({ id: user.id }).first();
      await trx('users').update({ balance: current.balance - 50 });
    })
  ]);

  const final = await db.users.findOne({ id: user.id });
  expect(final.balance).toBe(0); // Proper isolation
});
```

---

## Agent-Driven Database Testing

```typescript
// Generate test data with integrity
await Task("Generate Test Data", {
  schema: 'ecommerce',
  tables: ['users', 'products', 'orders'],
  count: { users: 1000, products: 500, orders: 5000 },
  preserveReferentialIntegrity: true
}, "qe-test-data-architect");

// Test migration safety
await Task("Migration Test", {
  migration: 'add-payment-status-column',
  tests: ['forward', 'rollback', 'data-preservation'],
  environment: 'staging'
}, "qe-test-executor");
```

---

## Agent Coordination Hints

### Memory Namespace
```
aqe/database-testing/
├── schema-snapshots/*   - Current schema state
├── migrations/*         - Migration test results
├── integrity/*          - Constraint validation
└── performance/*        - Query benchmarks
```

### Fleet Coordination
```typescript
const dbFleet = await FleetManager.coordinate({
  strategy: 'database-testing',
  agents: [
    'qe-test-data-architect',  // Generate test data
    'qe-test-executor',        // Run DB tests
    'qe-performance-tester'    // Query performance
  ],
  topology: 'sequential'
});
```

---

## Related Skills
- [test-data-management](../test-data-management/) - Generate test data
- [performance-testing](../performance-testing/) - Query performance
- [compliance-testing](../compliance-testing/) - Data protection

---

## Remember

**Test migrations before production:** Forward works, rollback works, data preserved, performance acceptable. Never deploy untested migrations.

**With Agents:** `qe-test-data-architect` generates realistic test data with referential integrity. `qe-test-executor` validates migrations automatically in CI/CD.

© proffesor-for-testing · MIT · proffesor-for-testing/agentic-qe

Similar skills

All skills for Testing and QA →

database-testing by other authors comes first.

database-testing kindlmann A skill for database testing: checks migrations forward and backward, schema constraints, seed data and query plans. Useful when a migration passes but drops data anyway. CX Codex +1 1,500installs database-development okou-ai database-development sorts database work into tracks and points to the reference that covers yours: migrations, queries, transactions, external effects, deploy order. CX Codex +1 1installs database-designer Alireza Rezvani database-designer reviews database schemas, query indexes, and migration plans. Use it when you need to inspect a schema or prepare a change with an expand-contract plan. CX Codex +1 819installs specsfy-aux-database promovaweb The specsfy-aux-database Claude Code skill keeps the project’s data map in .specsfy/DATABASE.md aligned with its implementation. It runs after persistence changes or during a map audit. CX Codex +1 473installs database-migration bobmatnyc database-migration guides AI coding assistants through zero-downtime database schema updates. It provides safe multi-phase migration templates and rollback guides. CX Codex +1 432installs database-schema-designer borghei database-schema-designer — a Claude Code skill that turns product requirements into a normalized relational schema with tables, ORM models, RLS, indexes and migrations. Works across six platforms, including Codex, Cursor and Gemini CLI. CX Codex +1 183installs surrealkit surrealdb A skill for Claude Code, Codex, Cursor, and other agents that brings SurrealKit — SurrealDB's schema-management and migration CLI — into the agent's context. CX Codex +1 521installs

From the same set73

The whole set →
pr-review The pr-review skill reviews GitHub PRs for scope, trust-tier assignments, code quality, and security. Use it to prepare clear feedback with actionable next steps. CX Codex +1 155installs agentic-quality-engineering The agentic-quality-engineering skill organizes AI agents around testing, risk analysis, and quality checks. It uses PACTS principles to guide coordination and agent selection. CX Codex +1 153installs security-testing security-testing is a Claude Code skill that checks projects for vulnerabilities using the OWASP Top 10 approach. It activates for auth audits, injection testing, and security automation. CX Codex +1 152installs pentest-validation pentest-validation validates SAST and DAST scanner findings against non-production targets, filters out false alarms, and produces PoC exploit proof. CX Codex +1 147installs performance-testing performance-testing is a Claude Code skill for planning load, stress, and soak tests, setting performance targets, and investigating bottlenecks in API and application results. CX Codex +1 144installs qe-test-generation qe-test-generation generates tests for new or changed code, with emphasis on contracts, invariants, and property checks. Use it to fill coverage gaps or move tests between frameworks. CX Codex +1 142installs qe-requirements-validation qe-requirements-validation is a skill that checks acceptance criteria for testability, links requirements to test cases, and generates BDD scenarios from user stories before development. CX Codex +1 141installs refactoring-patterns Applies refactoring patterns. Runs when you need to improve code structure without changing behavior. CX Codex +1 140installs

Project sponsors

Companies that keep this analytics open