migrate

Create Yii2 database migrations with safeUp() and safeDown() methods.

10|6|Updated Dec 2, 2025
One-click install
npx skills add https://github.com/WarLikeLaux/yii2-book-catalog --skill migrate-warlikelaux
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: migrate
Source: https://github.com/WarLikeLaux/yii2-book-catalog/tree/main/.claude/skills/migrate
Command: npx skills add https://github.com/WarLikeLaux/yii2-book-catalog --skill migrate-warlikelaux

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill provides a standardized and safe way to manage database schema changes in Yii2 applications, ensuring consistency and preventing data loss.

Core Features & Use Cases

  • Standardized Migration Creation: Generates migration files with correct naming conventions and structure.
  • Safe Schema Modifications: Guides users on safely altering tables, columns, indexes, and foreign keys.
  • Rollback Capabilities: Ensures that safeDown() methods correctly revert changes made by safeUp().
  • Use Case: When adding a new feature that requires database changes, use this Skill to create a migration that adds the necessary tables and columns, and then safely apply it to the development, staging, and production databases.

Quick Start

Use the migrate skill to create a new database migration named 'add_user_email_unique_index'.

Frequently Asked Questions about migrate

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a safe Yii2 database migration that handles foreign key constraints?

To create a safe Yii2 database migration, this Skill enforces conventions for structure and provides guidelines for handling foreign key constraints. It ensures your migration file correctly manages schema modifications and prevents data loss.

Why does my Yii2 migration rollback fail to revert schema changes correctly?

Yii2 migration rollbacks fail when the safeDown() method is not transactional or does not revert changes. This Skill ensures safeDown() methods correctly revert schema modifications made by safeUp(), maintaining database consistency.

What is the best way to manage auto-increment values and character encoding in SQL migrations?

The best way to manage auto-increment values and character encoding in SQL migrations is following standardized guidelines. This Skill provides specific rules for handling these properties during schema creation and modification.

How do I add a unique index to a table column using a Yii2 migration?

You add a unique index by generating a migration file with correct naming conventions. This Skill guides you on safely creating indexes and altering tables within the safeUp() and safeDown() methods to apply changes safely.

Does this migration approach work without additional PHP dependencies for Yii2 applications?

Yes, this migration approach works without additional dependencies. It relies on standard Yii2 framework capabilities to manage SQL schema changes, enforcing conventions for creation, modification, and rollback without external packages.

When do I need to use transactional safeUp() and safeDown() methods in database migrations?

You need transactional safeUp() and safeDown() methods whenever you modify database schemas to ensure safe rollbacks. This Skill enforces these methods to be correctly implemented and transactional, preventing partial updates and data loss.