dotted-ai/laravel-db-introspector 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

dotted-ai/laravel-db-introspector

Composer 安装命令:

composer require dotted-ai/laravel-db-introspector

包简介

Generate migrations from existing database schema

README 文档

README

A Laravel package to inspect an existing database schema and generate corresponding migration files automatically.

🚀 Installation

  1. Require via Composer:

    composer require dotted-ai/laravel-db-introspector
  2. Publish the stub template (optional):

    php artisan vendor:publish \
        --provider="Vendor\DbIntrospector\DatabaseInspectorServiceProvider" \
        --tag=stubs

🎯 Usage

Run the artisan command to generate migrations:

php artisan db:generate-migrations \
    [--tables=users,posts] \
    [--rewrite] \
    [--output-dir=from_schema]
  • --tables= (optional): Comma-separated list of tables. If omitted, all tables are processed.
  • --rewrite (optional): Overwrite existing migration files instead of skipping.
  • --output-dir= (optional): Specify a subdirectory under database/migrations to place generated files.

Examples

  • Generate migrations for all tables, skip existing:

    php artisan db:generate-migrations
  • Generate only users and posts, overwrite any existing:

    php artisan db:generate-migrations --tables=users,posts --rewrite
  • Output migrations to database/migrations/from_schema:

    php artisan db:generate-migrations --output-dir=from_schema

⚙️ Configuration

You can customize the stub template located at database/stubs/db-introspector/migration.stub after publishing.

The stub uses placeholders:

  • {{class}} — migration class name
  • {{table}} — table name
  • {{fields}} — column definitions

🛠️ How It Works

  1. Introspection: Uses Doctrine DBAL to list tables and columns.
  2. Build: Maps Doctrine column types to Laravel schema methods.
  3. Generate: Writes migration files with timestamps to avoid naming conflicts.

📄 License

MIT © Your Company

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2025-07-08