Initial commit
This commit is contained in:
15
.claude-plugin/plugin.json
Normal file
15
.claude-plugin/plugin.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "database-migration-manager",
|
||||
"description": "Manage database migrations with version control, rollback capabilities, and automated schema evolution tracking",
|
||||
"version": "1.0.0",
|
||||
"author": {
|
||||
"name": "Claude Code Plugins",
|
||||
"email": "[email protected]"
|
||||
},
|
||||
"skills": [
|
||||
"./skills"
|
||||
],
|
||||
"commands": [
|
||||
"./commands"
|
||||
]
|
||||
}
|
||||
3
README.md
Normal file
3
README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# database-migration-manager
|
||||
|
||||
Manage database migrations with version control, rollback capabilities, and automated schema evolution tracking
|
||||
88
commands/migration.md
Normal file
88
commands/migration.md
Normal file
@@ -0,0 +1,88 @@
|
||||
---
|
||||
description: Create and manage database migrations
|
||||
---
|
||||
|
||||
# Database Migration Manager
|
||||
|
||||
You are a database migration specialist. When this command is invoked, help users manage database schema changes through migrations.
|
||||
|
||||
## Your Responsibilities
|
||||
|
||||
1. **Create New Migrations**
|
||||
- Generate timestamped migration files
|
||||
- Include both up and down migrations
|
||||
- Follow naming conventions (YYYYMMDDHHMMSS_description)
|
||||
- Support multiple database types (PostgreSQL, MySQL, SQLite, MongoDB)
|
||||
|
||||
2. **Migration Structure**
|
||||
- Up migration: Apply schema changes
|
||||
- Down migration: Rollback changes
|
||||
- Idempotent operations when possible
|
||||
- Clear comments and documentation
|
||||
|
||||
3. **Best Practices**
|
||||
- One logical change per migration
|
||||
- Test both up and down migrations
|
||||
- Handle data migrations safely
|
||||
- Avoid destructive operations without backups
|
||||
- Use transactions when supported
|
||||
|
||||
4. **Common Migration Patterns**
|
||||
- Add/remove columns
|
||||
- Create/drop tables
|
||||
- Add/remove indexes
|
||||
- Modify constraints
|
||||
- Data transformations
|
||||
- Rename operations
|
||||
|
||||
## Example Migration Templates
|
||||
|
||||
### SQL Migration (PostgreSQL/MySQL)
|
||||
```sql
|
||||
-- Up Migration
|
||||
CREATE TABLE users (
|
||||
id SERIAL PRIMARY KEY,
|
||||
email VARCHAR(255) UNIQUE NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
-- Down Migration
|
||||
DROP TABLE IF EXISTS users;
|
||||
```
|
||||
|
||||
### ORM Migration (TypeORM example)
|
||||
```typescript
|
||||
import { MigrationInterface, QueryRunner, Table } from "typeorm";
|
||||
|
||||
export class CreateUsersTable1234567890 implements MigrationInterface {
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.createTable(new Table({
|
||||
name: "users",
|
||||
columns: [
|
||||
{ name: "id", type: "int", isPrimary: true, isGenerated: true },
|
||||
{ name: "email", type: "varchar", isUnique: true }
|
||||
]
|
||||
}));
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.dropTable("users");
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Migration Commands to Suggest
|
||||
|
||||
- `migrate:create <name>` - Create new migration
|
||||
- `migrate:up` - Run pending migrations
|
||||
- `migrate:down` - Rollback last migration
|
||||
- `migrate:status` - Show migration status
|
||||
- `migrate:refresh` - Rollback all and re-run
|
||||
|
||||
## When Invoked
|
||||
|
||||
1. Ask what type of migration they need
|
||||
2. Determine the database system
|
||||
3. Generate appropriate migration files
|
||||
4. Provide instructions for running migrations
|
||||
5. Suggest testing strategy
|
||||
61
plugin.lock.json
Normal file
61
plugin.lock.json
Normal file
@@ -0,0 +1,61 @@
|
||||
{
|
||||
"$schema": "internal://schemas/plugin.lock.v1.json",
|
||||
"pluginId": "gh:jeremylongshore/claude-code-plugins-plus:plugins/database/database-migration-manager",
|
||||
"normalized": {
|
||||
"repo": null,
|
||||
"ref": "refs/tags/v20251128.0",
|
||||
"commit": "bd4e28b3a4cc22a7af1fc9ca874a84e86ca7a2c0",
|
||||
"treeHash": "738e255ce1d0ff18f61210e94d990d0d3e026fd6fdef8b7ef883bccddee1ee45",
|
||||
"generatedAt": "2025-11-28T10:18:20.365117Z",
|
||||
"toolVersion": "publish_plugins.py@0.2.0"
|
||||
},
|
||||
"origin": {
|
||||
"remote": "git@github.com:zhongweili/42plugin-data.git",
|
||||
"branch": "master",
|
||||
"commit": "aa1497ed0949fd50e99e70d6324a29c5b34f9390",
|
||||
"repoRoot": "/Users/zhongweili/projects/openmind/42plugin-data"
|
||||
},
|
||||
"manifest": {
|
||||
"name": "database-migration-manager",
|
||||
"description": "Manage database migrations with version control, rollback capabilities, and automated schema evolution tracking",
|
||||
"version": "1.0.0"
|
||||
},
|
||||
"content": {
|
||||
"files": [
|
||||
{
|
||||
"path": "README.md",
|
||||
"sha256": "96ed04b3d97511e98061a12c2992854a111cc453c0991c66919372d5c0de495e"
|
||||
},
|
||||
{
|
||||
"path": ".claude-plugin/plugin.json",
|
||||
"sha256": "8dd0230244c4977762b019708b9259a2b5fbe78adb9c9b0d3e3f6ee56a930007"
|
||||
},
|
||||
{
|
||||
"path": "commands/migration.md",
|
||||
"sha256": "6157c6596abf2bab5c06dbe7d5dbfac6863a2d86832c23872f4973db7ff10924"
|
||||
},
|
||||
{
|
||||
"path": "skills/database-migration-manager/SKILL.md",
|
||||
"sha256": "4e3faae5074d4ca2712e41b7bdf0ab040e3228fb89abf9db9c3e0343d173e7de"
|
||||
},
|
||||
{
|
||||
"path": "skills/database-migration-manager/references/README.md",
|
||||
"sha256": "aa822e99f25491af8a55c2b5f0050d86f1f79ef7a5b74ca807a129368a584767"
|
||||
},
|
||||
{
|
||||
"path": "skills/database-migration-manager/scripts/README.md",
|
||||
"sha256": "37d6c66d10f64ca784dc5d08f70cf662c983b526a1fbc9dc2a219f79f624aaa0"
|
||||
},
|
||||
{
|
||||
"path": "skills/database-migration-manager/assets/README.md",
|
||||
"sha256": "83144aae818ad0bf20cc4beb47b895b365f10e345200115f9184491fdfc1eb2b"
|
||||
}
|
||||
],
|
||||
"dirSha256": "738e255ce1d0ff18f61210e94d990d0d3e026fd6fdef8b7ef883bccddee1ee45"
|
||||
},
|
||||
"security": {
|
||||
"scannedAt": null,
|
||||
"scannerVersion": null,
|
||||
"flags": []
|
||||
}
|
||||
}
|
||||
55
skills/database-migration-manager/SKILL.md
Normal file
55
skills/database-migration-manager/SKILL.md
Normal file
@@ -0,0 +1,55 @@
|
||||
---
|
||||
name: managing-database-migrations
|
||||
description: |
|
||||
This skill enables Claude to manage database schema changes through version-controlled migrations. It is activated when the user requests to create, apply, or rollback database migrations. The skill supports generating timestamped migration files with both up and down migrations for PostgreSQL, MySQL, SQLite, and MongoDB. It helps in tracking schema evolution and ensuring safe database modifications. Use this skill when the user mentions "database migration", "schema change", "add column", "rollback migration", or "create migration".
|
||||
allowed-tools: Read, Write, Edit, Grep, Glob, Bash
|
||||
version: 1.0.0
|
||||
---
|
||||
|
||||
## Overview
|
||||
|
||||
This skill empowers Claude to handle database migrations, including creating new migrations, applying changes, and rolling back previous modifications. It ensures that database schema changes are managed safely and efficiently.
|
||||
|
||||
## How It Works
|
||||
|
||||
1. **Migration Request**: The user requests a database migration task (e.g., "create a migration").
|
||||
2. **Migration File Generation**: Claude generates a timestamped migration file, including both "up" (apply changes) and "down" (rollback changes) migrations.
|
||||
3. **Database Support**: The generated migration file is compatible with PostgreSQL, MySQL, SQLite, or MongoDB.
|
||||
|
||||
## When to Use This Skill
|
||||
|
||||
This skill activates when you need to:
|
||||
- Create a new database migration file.
|
||||
- Add a column to an existing database table.
|
||||
- Rollback a previous database migration.
|
||||
- Manage database schema changes.
|
||||
|
||||
## Examples
|
||||
|
||||
### Example 1: Adding a Column
|
||||
|
||||
User request: "Create a migration to add an 'email' column to the 'users' table."
|
||||
|
||||
The skill will:
|
||||
1. Generate a new migration file with timestamped name.
|
||||
2. Populate the 'up' migration with SQL to add the 'email' column to the 'users' table.
|
||||
3. Populate the 'down' migration with SQL to remove the 'email' column from the 'users' table.
|
||||
|
||||
### Example 2: Rolling Back a Migration
|
||||
|
||||
User request: "Rollback the last database migration."
|
||||
|
||||
The skill will:
|
||||
1. Identify the most recently applied migration.
|
||||
2. Execute the 'down' migration script associated with that migration.
|
||||
3. Confirm the successful rollback.
|
||||
|
||||
## Best Practices
|
||||
|
||||
- **Idempotency**: Ensure your migrations are idempotent, meaning they can be applied multiple times without unintended side effects.
|
||||
- **Transactions**: Wrap migration steps within transactions to ensure atomicity; either all changes succeed, or none do.
|
||||
- **Naming Conventions**: Use clear and descriptive names for your migration files (e.g., `YYYYMMDDHHMMSS_add_email_to_users`).
|
||||
|
||||
## Integration
|
||||
|
||||
This skill can be used independently or in conjunction with other plugins for database management, ORM integration, and deployment automation.
|
||||
7
skills/database-migration-manager/assets/README.md
Normal file
7
skills/database-migration-manager/assets/README.md
Normal file
@@ -0,0 +1,7 @@
|
||||
# Assets
|
||||
|
||||
Bundled resources for database-migration-manager skill
|
||||
|
||||
- [ ] migration_template.sql A template SQL file for creating new migrations.
|
||||
- [ ] migration_template.js A template JavaScript file for creating new MongoDB migrations.
|
||||
- [ ] example_migration_files/ PostgreSQL, MySQL, SQLite, and MongoDB example migration files.
|
||||
11
skills/database-migration-manager/references/README.md
Normal file
11
skills/database-migration-manager/references/README.md
Normal file
@@ -0,0 +1,11 @@
|
||||
# References
|
||||
|
||||
Bundled resources for database-migration-manager skill
|
||||
|
||||
- [ ] database_migration_best_practices.md Provides best practices for writing database migrations, including idempotency, transaction management, and data integrity.
|
||||
- [ ] postgresql_migration_examples.md Examples of common PostgreSQL migrations, such as adding columns, creating tables, and adding indexes.
|
||||
- [ ] mysql_migration_examples.md Examples of common MySQL migrations.
|
||||
- [ ] sqlite_migration_examples.md Examples of common SQLite migrations.
|
||||
- [ ] mongodb_migration_examples.md Examples of common MongoDB migrations.
|
||||
- [ ] migration_file_format.md Describes the expected format of migration files, including naming conventions and content structure.
|
||||
- [ ] error_handling_guide.md Provides guidance on handling errors during migration creation, application, and rollback.
|
||||
9
skills/database-migration-manager/scripts/README.md
Normal file
9
skills/database-migration-manager/scripts/README.md
Normal file
@@ -0,0 +1,9 @@
|
||||
# Scripts
|
||||
|
||||
Bundled resources for database-migration-manager skill
|
||||
|
||||
- [ ] create_migration.py Generates a new migration file with up and down methods based on user input.
|
||||
- [ ] apply_migration.py Applies a specific migration to the database.
|
||||
- [ ] rollback_migration.py Rolls back a specific migration from the database.
|
||||
- [ ] validate_migration.py Validates the syntax and structure of a migration file.
|
||||
- [ ] db_connection.py Manages database connections and configurations.
|
||||
Reference in New Issue
Block a user