{"id":36252224,"url":"https://github.com/robinncode/lara-db-craft","last_synced_at":"2026-01-11T07:01:31.131Z","repository":{"id":321915677,"uuid":"1087185099","full_name":"robinNcode/lara-db-craft","owner":"robinNcode","description":"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.","archived":false,"fork":false,"pushed_at":"2025-11-01T09:53:51.000Z","size":45,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-11-01T11:26:10.494Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/robinNcode.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-10-31T14:02:35.000Z","updated_at":"2025-10-31T14:03:15.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/robinNcode/lara-db-craft","commit_stats":null,"previous_names":["robinncode/lara-db-craft"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/robinNcode/lara-db-craft","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robinNcode%2Flara-db-craft","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robinNcode%2Flara-db-craft/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robinNcode%2Flara-db-craft/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robinNcode%2Flara-db-craft/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robinNcode","download_url":"https://codeload.github.com/robinNcode/lara-db-craft/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robinNcode%2Flara-db-craft/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28296941,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-11T04:44:51.577Z","status":"ssl_error","status_checked_at":"2026-01-11T04:44:44.232Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-11T07:01:20.055Z","updated_at":"2026-01-11T07:01:31.120Z","avatar_url":"https://github.com/robinNcode.png","language":"PHP","readme":"# Laravel DB Craft\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/robinncode/lara-db-craft.svg?style=flat-square)](https://packagist.org/packages/robinncode/lara-db-craft)\n[![Total Downloads](https://img.shields.io/packagist/dt/robinncode/lara-db-craft.svg?style=flat-square)](https://packagist.org/packages/robinncode/lara-db-craft)\n\nLaravel 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.\n\n## Features\n\n- ✨ **Automatic Migration Generation**: Generate Laravel migration files from existing database tables\n- 🔄 **Seeder Generation**: Create seeders with actual table data\n- 🎯 **Table-Specific Generation**: Generate for all tables or specific ones\n- 🗄️ **Multi-Database Support**: Works with MySQL, PostgreSQL, and SQLite\n- 🔗 **Foreign Key Detection**: Automatically detects and includes foreign key constraints\n- 📊 **Index Support**: Preserves indexes and unique constraints\n- ⚙️ **Configurable**: Exclude tables, customize paths, and more\n- 🚀 **Easy to Use**: Simple artisan commands\n\n## Requirements\n\n- PHP 8.0 or higher\n- Laravel 9.x, 10.x, or 11.x\n- Database connection (MySQL, PostgreSQL, or SQLite)\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require robinncode/laravel-db-craft\n```\n\nThe package will automatically register its service provider.\n\nOptionally, publish the configuration file:\n\n```bash\nphp artisan vendor:publish --provider=\"RobinNcode\\LaravelDbCraft\\DbCraftServiceProvider\"\n```\n\nThis will create a `config/db-craft.php` file where you can customize the package behavior.\n\n## Usage\n\n### Generate Migrations\n\n#### Generate migrations for all tables:\n\n```bash\nphp artisan get:migration\n```\n\n#### Generate migration for a specific table:\n\n```bash\nphp artisan get:migration users\n```\n\n#### Use a specific database connection:\n\n```bash\nphp artisan get:migration --connection=mysql\n```\n\n### Generate Seeders\n\n#### Generate seeders for all tables with data:\n\n```bash\nphp artisan get:seeder\n```\n\n#### Generate seeder for a specific table:\n\n```bash\nphp artisan get:seeder users\n```\n\n#### Use a specific database connection:\n\n```bash\nphp artisan get:seeder --connection=mysql\n```\n\n## Configuration\n\nAfter publishing the config file, you can customize the following options in `config/db-craft.php`:\n\n```php\nreturn [\n    // Database connection to use\n    'connection' =\u003e env('DB_CRAFT_CONNECTION', null),\n    \n    // Path where migration files will be stored\n    'migrations_path' =\u003e database_path('migrations'),\n    \n    // Path where seeder files will be stored\n    'seeders_path' =\u003e database_path('seeders'),\n    \n    // Tables to exclude from generation\n    'exclude_tables' =\u003e [\n        'migrations',\n        'password_resets',\n        'password_reset_tokens',\n        'failed_jobs',\n        'personal_access_tokens',\n    ],\n    \n    // Number of records per chunk in seeders\n    'seeder_chunk_size' =\u003e 100,\n];\n```\n\n## Examples\n\n### Reverse Engineering an Existing Database\n\nIf you have an existing database and want to create Laravel migrations:\n\n```bash\n# Connect to your existing database in .env\nDB_CONNECTION=mysql\nDB_HOST=127.0.0.1\nDB_PORT=3306\nDB_DATABASE=your_existing_db\nDB_USERNAME=root\nDB_PASSWORD=secret\n\n# Generate all migrations\nphp artisan get:migration\n\n# Generate all seeders\nphp artisan get:seeder\n```\n\n### Backing Up Table Data\n\nCreate seeders to backup your current data:\n\n```bash\n# Generate seeders for all tables\nphp artisan get:seeder\n\n# Or for specific critical tables\nphp artisan get:seeder users\nphp artisan get:seeder products\nphp artisan get:seeder orders\n```\n\n### Working with Multiple Databases\n\n```bash\n# Generate migrations from production database\nphp artisan get:migration --connection=production\n\n# Generate seeders from staging database\nphp artisan get:seeder --connection=staging\n```\n\n## Generated Files\n\n### Migration Example\n\n```php\n\u003c?php\n\nuse Illuminate\\Database\\Migrations\\Migration;\nuse Illuminate\\Database\\Schema\\Blueprint;\nuse Illuminate\\Support\\Facades\\Schema;\n\nreturn new class extends Migration\n{\n    public function up(): void\n    {\n        Schema::create('users', function (Blueprint $table) {\n            $table-\u003eid('id');\n            $table-\u003estring('name');\n            $table-\u003estring('email');\n            $table-\u003etimestamp('email_verified_at')-\u003enullable();\n            $table-\u003estring('password');\n            $table-\u003erememberToken();\n            $table-\u003etimestamps();\n            \n            $table-\u003eunique('email');\n        });\n    }\n\n    public function down(): void\n    {\n        Schema::dropIfExists('users');\n    }\n};\n```\n\n### Seeder Example\n\n```php\n\u003c?php\n\nnamespace Database\\Seeders;\n\nuse Illuminate\\Database\\Seeder;\nuse Illuminate\\Support\\Facades\\DB;\n\nclass UsersTableSeeder extends Seeder\n{\n    public function run(): void\n    {\n        DB::statement('SET FOREIGN_KEY_CHECKS=0;');\n        \n        DB::table('users')-\u003etruncate();\n        \n        DB::table('users')-\u003einsert([\n            [\n                'id' =\u003e 1,\n                'name' =\u003e 'John Doe',\n                'email' =\u003e 'john@example.com',\n                'created_at' =\u003e '2024-01-01 00:00:00',\n                'updated_at' =\u003e '2024-01-01 00:00:00',\n            ],\n            // More records...\n        ]);\n        \n        DB::statement('SET FOREIGN_KEY_CHECKS=1;');\n    }\n}\n```\n\n## Supported Column Types\n\nThe package automatically maps database column types to Laravel migration types:\n\n- Integer types (int, bigint, smallint, tinyint, mediumint)\n- String types (varchar, char, text, mediumtext, longtext)\n- Decimal types (decimal, float, double)\n- Date/Time types (date, datetime, timestamp, time, year)\n- JSON types (json, jsonb)\n- Boolean types (boolean, bool)\n- Binary types (binary)\n- And more...\n\n## Tips \u0026 Best Practices\n\n1. **Review Generated Files**: Always review the generated migrations before running them\n2. **Test in Development**: Test the migrations in a development environment first\n3. **Backup Your Data**: Always backup your database before running migrations\n4. **Large Tables**: For tables with millions of records, consider generating seeders in smaller batches\n5. **Foreign Keys**: The package attempts to detect foreign keys, but verify them manually\n6. **Timestamps**: Laravel's `timestamps()` helper is used when detected\n\n## Troubleshooting\n\n### Foreign Key Detection Issues\n\nIf foreign keys are not detected properly:\n- Ensure your database user has proper permissions\n- Check that foreign keys are properly defined in the database\n- Some database configurations may not expose foreign key information\n\n### Large Dataset Memory Issues\n\nFor very large tables:\n- Adjust `seeder_chunk_size` in the config file\n- Consider generating seeders for specific tables only\n- Use database-specific dump tools for very large datasets\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n\n## Credits\n\n- Inspired by [robinncode/db_craft](https://github.com/robinNcode/db_craft) for CodeIgniter 4\n- Built with ❤️ for the Laravel community\n\n## Support\n\nIf you find this package helpful, please consider:\n- Starring the repository\n- Sharing it with others\n- Contributing improvements\n\nFor issues and feature requests, please use the [GitHub issue tracker](https://github.com/robinncode/laravel-db-craft/issues).","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobinncode%2Flara-db-craft","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobinncode%2Flara-db-craft","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobinncode%2Flara-db-craft/lists"}