cycle/schema-migrations-generator
Enhanced Migration Naming (ChangesCountNameGenerator)
2024_01_01_000001_create_users_table.php) to prevent naming collisions in parallel development.000002 vs. add_index_to_users_email). Requires hybrid adoption (e.g., semantic names for critical migrations, incremental for parallel work).Database-Centric Workflow
migrate:status output becomes less intuitive).Configurable Naming Generator
config/schema-migrations-generator.php:
'name_generator' => \Cycle\SchemaMigrationsGenerator\NameGenerators\ChangesCountNameGenerator::class,
--name-generator flag for schema:generate:
php artisan schema:generate --name-generator=ChangesCountNameGenerator
Dependency & CI Updates
laravel-schema-dumper).ChangesCountNameGenerator-generated files in CI checks.Naming Collision Mitigation
migrations.lock to serialize generation.ChangesCountNameGenerator for feature branches only.Testing Overhead
migrate:fresh tests to account for numeric suffixes.migrate:rollback --step=1 works with incremental names.--pretend flag pre-deployment:
php artisan migrate --pretend | grep -E "0000[0-9]{2}_"
Unchanged Risks
Adoption Strategy
ChangesCountNameGenerator be enabled by default (risk: unexpected renaming) or opt-in (risk: inconsistent usage)?Naming Convention Coexistence
add_soft_deletes_to_users) and incremental names (e.g., 000002) coexist in the same project?'generators' => [
'mysql' => [
'default' => DefaultNameGenerator::class,
'tables' => [
'users' => ChangesCountNameGenerator::class,
],
],
],
CI/CD Pipeline Impact
schema:diff), and how will naming conflicts be resolved?php artisan schema:generate --dry-run | grep -c "Duplicate migration name"
Rollback & Downgrade Safety
migrate:rollback --step=1) or database downgrades?php artisan migrate:rollback --step=1 --pretend
Legacy Migration Path
ChangesCountNameGenerator?Laravel Native
config/schema-migrations-generator.php to enable:
'name_generator' => \Cycle\SchemaMigrationsGenerator\NameGenerators\ChangesCountNameGenerator::class,
--name-generator flag for schema:generate:
php artisan schema:generate --name-generator=ChangesCountNameGenerator --tables=users,products
Tooling Synergy
pre-push to validate naming uniqueness:
# .git/hooks/pre-push
php artisan schema:generate --dry-run | grep -q "Duplicate" && exit 1
php artisan schema:generate --name-generator=ChangesCountNameGenerator --force
Assessment Phase
YYYY_MM_DD_title.php).users, orders with frequent changes).php artisan schema:list to catalog existing migrations.Pilot Phase
ChangesCountNameGenerator for non-production environments first.php artisan schema:generate --name-generator=ChangesCountNameGenerator --tables=test_data --dry-run
git diff to ensure no semantic loss.Incremental Adoption
php artisan schema:generate --name-generator=ChangesCountNameGenerator --tables=users --force
--force sparingly; backup migrations pre-execution.schema:diff).Fallback Plan
DefaultNameGenerator for legacy, ChangesCountNameGenerator for new:
'generators' => [
'mysql' => [
'default' => DefaultNameGenerator::class,
'new_tables' => ChangesCountNameGenerator::class,
],
],
php artisan schema:generate --name-generator=ChangesCountNameGenerator --tables=users --force
Laravel Versions
Database Drivers
Configuration
name_generator to config/schema-migrations-generator.php:
'name_generator' => \Cycle\SchemaMigrationsGenerator\NameGenerators\ChangesCountNameGenerator::class,
.env:
SCHEMA_NAME_GENERATOR=ChangesCountNameGenerator
Third-Party Tools
ChangesCountNameGenerator-generated files as "new"; whitelist them in CI.Pre-Migration
cp -r database/migrations database/migrations_backup_$(date +%Y%m%d)
php artisan migrate:status to log current state.Generation
How can I help you explore Laravel packages today?