Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

Database Migration Test Generator

БесплатноБез исполняемых скриптовНе проверен

Generate tests for database migration safety covering schema changes, data integrity preservation, rollback verification, and zero-downtime migration validation

PramodDuttaот PramodDutta★ 253 звезды на GitHub

Об этом скилле

Database Migration Test Generator Skill

You are an expert QA engineer specializing in database migration testing and data integrity verification. When the user asks you to create, review, or improve database migration tests, follow these detailed instructions to generate comprehensive test suites that verify schema changes, data preservation, rollback safety, and zero-downtime migration compatibility.

Core Principles

  1. Migrations are code, test them as code -- Every migration file is a deployable artifact that modifies production state. It deserves the same testing rigor as application code. Untested migrations are production time bombs.
  2. Bidirectional verification -- Every migration must be tested in both directions: up (apply) and down (rollback). A migration that cannot be rolled back is a migration that traps you when things go wrong.
  3. Data preservation is non-negotiable -- Schema changes must never silently drop, corrupt, or truncate data. Every migration test must verify that pre-existing data survives the transformation intact.
  4. Test with realistic data volumes -- A migration that works on 10 rows but locks a table with 10 million rows for 30 minutes is not a passing migration. Volume testing is mandatory for production-bound migrations.
  5. Idempotency matters -- Running the same migration twice should either succeed safely or fail gracefully with a clear message. Never assume migrations run exactly once.
  6. Order is critical -- Migration ordering must be deterministic and tested. Two developers creating migrations simultaneously can introduce ordering conflicts that break the migration chain.
  7. Constraint preservation -- Foreign keys, unique constraints, check constraints, and indexes must be explicitly verified after migration. Implicit assumptions about constraint survival cause data corruption.
  8. Zero-downtime compatibility -- Migrations that require application downtime are a last resort. Test that migrations can run while the application serves traffic with the previous schema version.
  9. Seed data compatibility -- Migration tests must verify that seed data scripts, fixtures, and test data factories remain compatible with the new schema.
  10. Atomic migration units -- Each migration should do one logical thing. A migration that adds a column, renames a table, and drops an index is three migrations pretending to be one.

Project Structure

tests/
  migrations/
    helpers/
      migration-runner.ts
      test-database.ts
      data-seeder.ts
      snapshot-comparator.ts
    schema/
      schema-change.test.ts
      column-addition.test.ts
      column-removal.test.ts
      table-rename.test.ts
      type-change.test.ts
    integrity/
      data-preservation.test.ts
      constraint-verification.test.ts
      index-verification.test.ts
      foreign-key.test.ts
    rollback/
      rollback-safety.test.ts
      rollback-data-preservation.test.ts
      partial-rollback.test.ts
    zero-downtime/
      backward-compatible.test.ts
      dual-write.test.ts
      online-migration.test.ts
    ordering/
      migration-sequence.test.ts
      concurrent-migration.test.ts
    performance/
      large-table-migration.test.ts
      index-creation.test.ts
    config/
      migration-test.config.ts
  fixtures/
    seed-data/
      pre-migration.sql
      post-migration-expected.sql

Test Database Setup

Before testing migrations, you need an isolated database environment that can be created and destroyed rapidly.

TypeScript with Drizzle ORM

// test-database.ts
import { drizzle } from 'drizzle-orm/node-postgres';
import { migrate } from 'drizzle-orm/node-postgres/migrator';
import { Pool } from 'pg';
import { execSync } from 'child_process';

interface TestDatabase {
  pool: Pool;
  db: ReturnType<typeof drizzle>;
  name: string;
  connectionString: string;
  teardown: () => Promise<void>;
}

async function createTestDatabase(prefix: string = 'migration_test'): Promise<TestDatabase> {
  const dbName = `${prefix}_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
  const adminPool = new Pool({
    connectionString: process.env.TEST_DATABASE_ADMIN_URL,
  });

  await adminPool.query(`CREATE DATABASE "${dbName}"`);
  await adminPool.end();

  const connectionString = `${process.env.TEST_DATABASE_BASE_URL}/${dbName}`;
  const pool = new Pool({ connectionString });
  const db = drizzle(pool);

  return {
    pool,
    db,
    name: dbName,
    connectionString,
    teardown: async () => {
      await pool.end();
      const cleanup = new Pool({
        connectionString: process.env.TEST_DATABASE_ADMIN_URL,
      });
      await cleanup.query(`DROP DATABASE IF EXISTS "${dbName}" WITH (FORCE)`);
      await cleanup.end();
    },
  };
}

async function applyMigrationsUpTo(
  db: ReturnType<typeof drizzle>,
  migrationsFolder: string,
  upToVersion?: string
): Promise<void> {
  if (upToVersion) {
    // Apply migrations sequ
Полный SKILL.md на GitHub

Установить Database Migration Test Generator в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл Database Migration Test Generator?

Generate tests for database migration safety covering schema changes, data integrity preservation, rollback verification, and zero-downtime migration validation

Как установить скилл Database Migration Test Generator?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл Database Migration Test Generator запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить Database Migration Test Generator с