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
-
Require via Composer:
composer require dotted-ai/laravel-db-introspector
-
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 underdatabase/migrationsto place generated files.
Examples
-
Generate migrations for all tables, skip existing:
php artisan db:generate-migrations
-
Generate only
usersandposts, 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
- Introspection: Uses Doctrine DBAL to list tables and columns.
- Build: Maps Doctrine column types to Laravel schema methods.
- Generate: Writes migration files with timestamps to avoid naming conflicts.
📄 License
MIT © Your Company
统计信息
- 总下载量: 1.05k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2025-07-08