定制 idkwhoami/migration-rules 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

idkwhoami/migration-rules

Composer 安装命令:

composer require idkwhoami/migration-rules

包简介

Enforce consistent Laravel migration naming and ordering via topological sort, inlining, and regeneration.

README 文档

README

A composer require --dev package that scans, sorts, inlines, and regenerates Laravel migrations to enforce consistent naming and ordering rules.

Warning: Safe to run only on undeployed apps. This tool modifies your migration files.

Requirements

  • Laravel 12+ (anonymous class migration convention)
  • PHP 8.2+

Installation

composer require idkwhoami/migration-rules --dev

Usage

# Preview what would change (no files written)
php artisan migrate:enforce --dry-run

# Apply changes
php artisan migrate:enforce

# Show current manifest / state
php artisan migrate:enforce --status

Options

Option Description Default
--dry-run Preview changes without writing files false
--pattern Date prefix for filenames 0001_01_01
--base-step Slot step for base migrations 50
--pivot-step Slot step for pivot migrations 25
--force Auto-resolve collisions (keep base version) false
--status Show manifest state false

Rules

  • Filename pattern: {prefix}_{slot}_{action}.php
  • Base slot step: 50 (each distinct model)
  • Pivot slot step: 25
  • Ordering: Topological sort by FK dependencies
  • Altering migrations: Inlined into base migration (no separate altering migrations)
  • down(): Omitted entirely (undeployed = no rollback needed)

FK Detection

Detects foreign keys via:

  • ->foreignId('column')->constrained()
  • ->foreignIdFor(Model::class)
  • ->foreignUlid('column') / ->foreignUuid('column')
  • ->morphs('column') / ->nullableMorphs() / ->ulidMorphs() / ->uuidMorphs()
  • ->constrained()->onDelete(...)

External table references (tables outside database/migrations/) are skipped.

Manifest

After running, a .migration.rules file is written to your project root and added to .gitignore. This allows subsequent runs to detect drift.

License

MIT

idkwhoami/migration-rules 适用场景与选型建议

idkwhoami/migration-rules 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 04 月 28 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 idkwhoami/migration-rules 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 idkwhoami/migration-rules 我们能提供哪些服务?
定制开发 / 二次开发

基于 idkwhoami/migration-rules 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 3
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 47
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-28