鱼皮AI导航
鱼皮AI导航
  • 主页
  • 社区
  • AI工具
  • AI知识库
  • AI提示词
  • MCP
  • Skills
  • AI学习资源
  • AI资讯
  • GitHub开源
登录/注册

database-testing

面向数据库全生命周期的质量保障,覆盖结构定义验证、数据约束检查、迁移脚本可靠性测试、事务并发行为验证及查询性能度量,确保数据持久化过程中的准确性、一致性与稳定性。

数据库
访问 GitHub
文档Skills.MD
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
tokenEstimate900
agents["qe-test-data-architect","qe-test-executor","qe-performance-tester"]
implementation_status
optimized
optimization_version1
last_optimized"2025-12-02T00:00:00.000Z"
dependencies[]
quick_reference_cardtrue
tags["database","schema","migration","transactions","integrity","sql","performance"]

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

TypeFocusWhen
SchemaStructure correctTable creation
IntegrityConstraints workData operations
MigrationUp/down workSchema changes
TransactionACID propertiesConcurrent access
PerformanceQuery speedOptimization

ACID Properties

PropertyTest Focus
AtomicityAll or nothing (rollback on error)
ConsistencyConstraints always valid
IsolationConcurrent transactions don't interfere
DurabilityCommitted data persists

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: 'test@example.com' }); await expect( db.users.create({ email: 'test@example.com' }) ).rejects.toThrow('unique constraint violation'); }); test('foreign key prevents orphaned records', async () => { const user = await db.users.create({ email: 'test@example.com' }); 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: 'test@example.com' }); await migrate('add-age-column'); const user = await db.users.findOne({ email: 'test@example.com' }); 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: 'user1@example.com' }); await trx('users').insert({ email: 'user2@example.com' }); 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

▼
text
复制代码
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 - Generate test data
  • performance-testing - Query performance
  • compliance-testing - Data protection

Remember

Database bugs are catastrophic. Data loss is unrecoverable. Corruption spreads silently. Performance issues compound.

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.

数据库

快捷安装

复制到终端去安装 Skill

npxadd-skillproffesor-for-testing/agentic-qe--skill"database-testing"
站长:程序员鱼皮 老鱼简历 商务合作 增值电信业务经营许可证
2026 鱼皮AI导航 | 沪ICP备19026706号-6
站长:程序员鱼皮 老鱼简历 商务合作 增值电信业务经营许可证
2026 鱼皮AI导航 | 沪ICP备19026706号-6
🔥热门工具
朱雀AI检测朱雀AI检测
朱雀AI检测助手朱雀AI检测助手
LovartLovart
老鱼简历老鱼简历
WritePass官网WritePass官网
面多多面多多
CursorCursor
星月写作星月写作
朱雀AI检测助手朱雀AI检测助手
零感AI零感AI
Skills 推荐
relational-database-mcp-cloudbase
面向 CloudBase 关系型数据库的自动化管理,支持安全执行只读查询、写入与结构变更操作,并可检视及调整表级安全规则,确保在无应用上下文的代理环境中精准控制数据访问与修改权限。
database-index-advisor
通过分析数据库查询负载和现有索引配置,自动识别缺失的高效索引以加速慢查询,同时发现长期未被使用的冗余索引以便清理,从而在提升读取性能的同时节省存储空间并优化写入效率。
detecting-sql-injection-vulnerabilities
自动识别和分析应用程序代码及数据库查询中的 SQL 注入风险,覆盖输入点检测、查询构造审查、参数化验证与安全模式推荐,生成结构化安全报告并提供修复建议。
database
规范 NestJS 应用的数据访问层设计,涵盖 ORM 选型、连接池与分片等可扩展架构,强制使用仓库模式隔离数据库逻辑,通过异步配置加载敏感信息,禁用生产环境自动同步,依赖迁移脚本实现零停机演进,并统一要求分页、索引声明与事务保护。
prisma-schema-helper
提供 Prisma 数据模型定义的自动化辅助能力,涵盖模式校验、关系配置、字段类型推导及迁移脚本生成,支持 Node.js 等后端技术栈的数据库层快速搭建与维护。