Download the PHP package robinncode/laravel-db-craft without Composer
On this page you can find all versions of the php package robinncode/laravel-db-craft. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download robinncode/laravel-db-craft
More information about robinncode/laravel-db-craft
Files in robinncode/laravel-db-craft
Package laravel-db-craft
Short Description Generate Laravel migrations and seeders from existing database connections
License MIT
Homepage https://github.com/robinNcode/lara-db-craft
Informations about the package laravel-db-craft
Laravel DB Craft
Laravel DB Craft is a powerful package that automatically generates migration and seeder files from your existing database connections. Perfect for reverse engineering databases, creating backups, or migrating from legacy systems.
Features
- ✨ Automatic Migration Generation: Generate Laravel migration files from existing database tables
- 🔄 Seeder Generation: Create seeders with actual table data
- 🎯 Table-Specific Generation: Generate for all tables or specific ones
- 🗄️ Multi-Database Support: Works with MySQL, PostgreSQL, and SQLite
- 🔗 Foreign Key Detection: Automatically detects and includes foreign key constraints
- 📊 Index Support: Preserves indexes and unique constraints
- ⚙️ Configurable: Exclude tables, customize paths, and more
- 🚀 Easy to Use: Simple artisan commands
Requirements
- PHP 8.0 or higher
- Laravel 9.x, 10.x, or 11.x
- Database connection (MySQL, PostgreSQL, or SQLite)
Installation
You can install the package via composer:
The package will automatically register its service provider.
Optionally, publish the configuration file:
This will create a config/db-craft.php file where you can customize the package behavior.
Usage
Generate Migrations
Generate migrations for all tables:
Generate migration for a specific table:
Use a specific database connection:
Generate Seeders
Generate seeders for all tables with data:
Generate seeder for a specific table:
Use a specific database connection:
Configuration
After publishing the config file, you can customize the following options in config/db-craft.php:
Examples
Reverse Engineering an Existing Database
If you have an existing database and want to create Laravel migrations:
Backing Up Table Data
Create seeders to backup your current data:
Working with Multiple Databases
Generated Files
Migration Example
Seeder Example
Supported Column Types
The package automatically maps database column types to Laravel migration types:
- Integer types (int, bigint, smallint, tinyint, mediumint)
- String types (varchar, char, text, mediumtext, longtext)
- Decimal types (decimal, float, double)
- Date/Time types (date, datetime, timestamp, time, year)
- JSON types (json, jsonb)
- Boolean types (boolean, bool)
- Binary types (binary)
- And more...
Tips & Best Practices
- Review Generated Files: Always review the generated migrations before running them
- Test in Development: Test the migrations in a development environment first
- Backup Your Data: Always backup your database before running migrations
- Large Tables: For tables with millions of records, consider generating seeders in smaller batches
- Foreign Keys: The package attempts to detect foreign keys, but verify them manually
- Timestamps: Laravel's
timestamps()helper is used when detected
Troubleshooting
Foreign Key Detection Issues
If foreign keys are not detected properly:
- Ensure your database user has proper permissions
- Check that foreign keys are properly defined in the database
- Some database configurations may not expose foreign key information
Large Dataset Memory Issues
For very large tables:
- Adjust
seeder_chunk_sizein the config file - Consider generating seeders for specific tables only
- Use database-specific dump tools for very large datasets
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
The MIT License (MIT). Please see License File for more information.
Credits
- Inspired by robinncode/db_craft for CodeIgniter 4
- Built with ❤️ for the Laravel community
Support
If you find this package helpful, please consider:
- Starring the repository
- Sharing it with others
- Contributing improvements
For issues and feature requests, please use the GitHub issue tracker.