database-migration-helper
БесплатноБез исполняемых скриптовНе проверенCreate and manage database migrations safely with rollback support. Use when modifying database schema, adding indexes, or managing database changes.
от armanzeroeight★ 30 звёзд на GitHubОб этом скилле
Database Migration Helper
Create and manage database migrations safely with proper rollback support.
Quick Start
Create migration files with up/down functions, test locally, backup before production, run migrations incrementally.
Instructions
Migration Structure
Basic migration:
// migrations/001_create_users_table.js
exports.up = async (db) => {
await db.schema.createTable('users', (table) => {
table.increments('id').primary();
table.string('email').unique().notNullable();
table.string('password_hash').notNullable();
table.timestamps(true, true);
});
};
exports.down = async (db) => {
await db.schema.dropTable('users');
};
Creating Tables
With Knex:
exports.up = async (knex) => {
await knex.schema.createTable('posts', (table) => {
table.increments('id').primary();
table.integer('user_id').unsigned().notNullable();
table.string('title', 200).notNullable();
table.text('content');
table.enum('status', ['draft', 'published', 'archived']).defaultTo('draft');
table.timestamps(true, true);
// Foreign key
table.foreign('user_id').references('users.id').onDelete('CASCADE');
// Indexes
table.index('user_id');
table.index('status');
});
};
exports.down = async (knex) => {
await knex.schema.dropTable('posts');
};
With raw SQL:
-- migrations/001_create_users.up.sql
CREATE TABLE users (
id SERIAL PRIMARY KEY,
email VARCHAR(255) UNIQUE NOT NULL,
password_hash VARCHAR(255) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX idx_users_email ON users(email);
-- migrations/001_create_users.down.sql
DROP TABLE IF EXISTS users;
Adding Columns
exports.up = async (knex) => {
await knex.schema.table('users', (table) => {
table.string('phone', 20);
table.boolean('is_verified').defaultTo(false);
});
};
exports.down = async (knex) => {
await knex.schema.table('users', (table) => {
table.dropColumn('phone');
table.dropColumn('is_verified');
});
};
Modifying Columns
exports.up = async (knex) => {
await knex.schema.alterTable('users', (table) => {
table.string('email', 320).alter(); // Increase length
table.string('name', 100).notNullable().alter(); // Add NOT NULL
});
};
exports.down = async (knex) => {
await knex.schema.alterTable('users', (table) => {
table.string('email', 255).alter();
table.string('name', 100).nullable().alter();
});
};
Adding Indexes
exports.up = async (knex) => {
await knex.schema.table('posts', (table) => {
table.index('created_at');
table.index(['user_id', 'created_at']); // Composite index
});
};
exports.down = async (knex) => {
await knex.schema.table('posts', (table) => {
table.dropIndex('created_at');
table.dropIndex(['user_id', 'created_at']);
});
};
Data Migrations
exports.up = async (knex) => {
// Add column
await knex.schema.table('users', (table) => {
table.string('full_name');
});
// Migrate data
const users = await knex('users').select('id', 'first_name', 'last_name');
for (const user of users) {
await knex('users')
.where('id', user.id)
.update({ full_name: `${user.first_name} ${user.last_name}` });
}
// Drop old columns
await knex.schema.table('users', (table) => {
table.dropColumn('first_name');
table.dropColumn('last_name');
});
};
exports.down = async (knex) => {
// Add old columns
await knex.schema.table('users', (table) => {
table.string('first_name');
table.string('last_name');
});
// Migrate data back
const users = await knex('users').select('id', 'full_name');
for (const user of users) {
const [firstName, ...lastNameParts] = user.full_name.split(' ');
await knex('users')
.where('id', user.id)
.update({
first_name: firstName,
last_name: lastNameParts.join(' ')
});
}
// Drop new column
await knex.schema.table('users', (table) => {
table.dropColumn('full_name');
});
};
Foreign Keys
exports.up = async (knex) => {
await knex.schema.table('posts', (table) => {
table.foreign('user_id')
.references('id')
.inTable('users')
.onDelete('CASCADE')
.onUpdate('CASCADE');
});
};
exports.down = async (knex) => {
await knex.schema.table('posts', (table) => {
table.dropForeign('user_id');
});
};
Renaming Tables/Columns
exports.up = async (knex) => {
await knex.schema.renameTable('posts', 'articles');
await knex.schema.table('articles', (table) => {
table.renameColumn('content', 'body');
});
};
exports.down = async (knex) => {
await knex.schema.table('articles', (table) => {
table.renameColumn('body', 'content');
});
await knex.schema.renameTable
Установить database-migration-helper в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл database-migration-helper?
Create and manage database migrations safely with rollback support. Use when modifying database schema, adding indexes, or managing database changes.
Как установить скилл database-migration-helper?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл database-migration-helper запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic