Create safe, reversible database migration scripts with rollback capabilities, data validation, and zero-downtime deployments. Use when changing database schemas, migrating data between systems, or performing large-scale data transformations.
Create robust, safe, and reversible data migration scripts for database schema changes and data transformations with minimal downtime.
Minimal working example:
import { Knex } from "knex";
// migrations/20240101000000_add_user_preferences.ts
export async function up(knex: Knex): Promise<void> {
// Create new table
await knex.schema.createTable("user_preferences", (table) => {
table.uuid("id").primary().defaultTo(knex.raw("gen_random_uuid()"));
table
.uuid("user_id")
.notNullable()
.references("id")
.inTable("users")
.onDelete("CASCADE");
table.jsonb("preferences").defaultTo("{}");
table.timestamp("created_at").defaultTo(knex.fn.now());
table.timestamp("updated_at").defaultTo(knex.fn.now());
table.index("user_id");
});
// Migrate existing data
await knex.raw(`
INSERT INTO user_preferences (user_id, preferences)
SELECT id, jsonb_build_object(
'theme', COALESCE(theme, 'light'),
// ... (see reference guides for full implementation)
Detailed implementations in the references/ directory:
| Guide | Contents | |---|---| | Knex.js Migrations (Node.js) | Knex.js Migrations (Node.js) | | Alembic Migrations (Python/SQLAlchemy) | Alembic Migrations (Python/SQLAlchemy) | | Large Data Migration with Batching | Large Data Migration with Batching | | Zero-Downtime Migration Pattern | Zero-Downtime Migration Pattern | | Migration Validation | Migration Validation | | Cross-Database Migration | Cross-Database Migration |
up and down migrationsnpx skills add aj-geddes/data-migration-scripts下载完整 Skill 目录,包含 SKILL.md 及所有相关文件
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer