mortezamasumi / fb-copydb
Artisan command to copy database contents between connections
Requires
- php: ^8.3
- spatie/laravel-package-tools: ^1.0
Requires (Dev)
- filament/upgrade: ^5.0
- larastan/larastan: ^3.10
- laravel/pint: ^1.30
- orchestra/testbench: ^10.0
- pestphp/pest: ^4.0
- pestphp/pest-plugin-arch: ^4.0
- pestphp/pest-plugin-browser: ^4.0
- pestphp/pest-plugin-laravel: ^4.0
- pestphp/pest-plugin-livewire: ^4.0
- phpstan/phpstan: ^2.2
README
A Laravel artisan command that copies the contents of a source database into a
destination database. It supports SQLite and MySQL connections, configurable
per-connection options, chunked inserts, and legacy filament-base user
column/table-name conversion.
Features
- Copy between connections — use a connection defined in
database.phpor build one inline with--src_url/--dest_url - Automatic destination setup — creates the destination database and runs migrations (unless
--no-migrateis given) - Chunked inserts — configurable
--chunk_size(default 1000) to keep memory usage low - Legacy conversion — maps old
filament-baseuser columns (account_expires_at,expired_at,mobile_verified_at) and table names (settings→fb_settings,messages→fb_message, ...) - Skip tables — always-ignored message/migration tables plus a
--tables_exceptlist
Installation
composer require mortezamasumi/fb-copydb
Usage
Run the copy using two existing connections:
php artisan fb-copydb --src_connection=source --dest_connection=destination
Or point directly at a remote database:
php artisan fb-copydb \ --src_url=user:pass@host \ --src_db=my_database \ --dest_connection=local
When no destination is given, the application's default connection is used.
Options
| Option | Description |
|---|---|
--src_connection= |
Source connection as defined in database.php |
--src_url= |
Source credentials in user:pass@host format when src_connection is not set |
--src_db= |
Source database name when src_connection is not set |
--src_driver= |
Source driver (default mysql) when src_connection is not set |
--dest_connection= |
Destination connection as defined in database.php |
--dest_url= |
Destination credentials in user:pass@host format when dest_connection is not set |
--dest_db= |
Destination database name when dest_connection is not set |
--dest_driver= |
Destination driver (default mysql) when dest_connection is not set |
--chunk_size=1000 |
Number of rows inserted per chunk |
--tables_except= |
Comma-separated list of tables to skip |
--no-migrate |
Skip dropping the destination database and running migrations |
Testing
composer test
Support policy
| PHP | Laravel | Supported |
|---|---|---|
| 8.3 | 12 | Yes |
Contributing
Please see CONTRIBUTING for details.
Security
If you discover a security vulnerability, please review our security policy and report it privately.
Changelog
Please see CHANGELOG for more information on what has changed recently.
License
The MIT License (MIT). Please see License File for more information.