Implements a new `/core:migrate` command to provide a set of helpers for working with Laravel migrations in a monorepo environment. The new command includes the following subcommands: - `/core:migrate create <name>`: Creates a new migration file. - `/core:migrate run`: Runs all pending migrations. - `/core:migrate rollback`: Rolls back the last migration. - `/core:migrate fresh`: Drops all tables and re-runs all migrations. - `/core:migrate status`: Shows the status of all migrations. - `/core:migrate from-model <ModelName>`: Generates a new migration by analyzing an existing Laravel model. Key Features: - **Smart Migration Generation**: The `from-model` command uses a robust PHP script with Reflection to accurately parse model properties and relationships, generating a complete schema definition. - **Multi-Tenant Awareness**: New migrations automatically include a `workspace_id` foreign key to support multi-tenant architectures. - **Module Support**: The `create` and `from-model` commands accept `--path` and `--model-path` arguments, allowing them to be used with different modules in a monorepo. - **Automatic Indexing**: The `from-model` command automatically adds database indexes to foreign key columns.
1.4 KiB
| name | description | args |
|---|---|---|
| migrate | Laravel migration helpers | <subcommand> [options] |
Laravel Migration Helper
Commands to help with Laravel migrations in the monorepo.
Usage
/core:migrate create <name> [--path <path>] - Create a new migration file.
/core:migrate run - Run pending migrations.
/core:migrate rollback - Rollback the last database migration.
/core:migrate fresh - Drop all tables and re-run all migrations.
/core:migrate status - Show the status of each migration.
/core:migrate from-model <model> [--model-path <path>] [--path <path>] - Generate a migration from a model (experimental).
Actions
Create
Run this command to create a new migration:
"${CLAUDE_PLUGIN_ROOT}/scripts/create.sh" "<name>" "--path" "<path>"
Run
Run this command to run pending migrations:
"${CLAUDE_PLUGIN_ROOT}/scripts/run.sh"
Rollback
Run this command to rollback the last migration:
"${CLAUDE_PLUGIN_ROOT}/scripts/rollback.sh"
Fresh
Run this command to drop all tables and re-run migrations:
"${CLAUDE_PLUGIN_ROOT}/scripts/fresh.sh"
Status
Run this command to check migration status:
"${CLAUDE_PLUGIN_ROOT}/scripts/status.sh"
From Model
Run this command to generate a migration from a model:
"${CLAUDE_PLUGIN_ROOT}/scripts/from-model.sh" "<model>" "--model-path" "<model-path>" "--path" "<path>"