https://github.com/rokde/laravel-clone-database-command
Clone a database with overwriting table values
https://github.com/rokde/laravel-clone-database-command
Last synced: about 1 year ago
JSON representation
Clone a database with overwriting table values
- Host: GitHub
- URL: https://github.com/rokde/laravel-clone-database-command
- Owner: rokde
- License: mit
- Created: 2024-02-06T13:50:09.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-02-06T15:55:39.000Z (over 2 years ago)
- Last Synced: 2024-02-07T16:17:12.721Z (over 2 years ago)
- Language: PHP
- Size: 23.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
Awesome Lists containing this project
README
# This is the laravel clone database command
[](https://packagist.org/packages/rokde/laravel-clone-database-command)
[](https://github.com/rokde/laravel-clone-database-command/actions?query=workflow%3Arun-tests+branch%3Amain)
[](https://github.com/rokde/laravel-clone-database-command/actions?query=workflow%3A"Fix+PHP+code+style+issues"+branch%3Amain)
[](https://packagist.org/packages/rokde/laravel-clone-database-command)
This artisan command can clone a production database to development databases with overwriting some personal data as configured.
## Installation
You can install the package via composer:
```bash
composer require rokde/laravel-clone-database-command
```
## Usage
You can use the pre-configured artisan console command:
```bash
php artisan db:clone
```
This assumes that there are the entries `source` and `target` in the database configuration.
Otherwise you can create your own clone command to meet the configurable needs.
All single tasks can be found in the `src/Actions` folder. So you can join it like you want if necessary.
### Configuration
The whole configuration is stored in a class `DatabaseSyncConfiguration`.
#### source & target connection
The name of the connections and the connection configuration is editable. So if you already have a `target` or `source` connection configured - you can change that name if necessary.
#### chunk size
The chunk size can be configured for a specific table or for any table.
#### limit
The limit of rows can be configured for a specific table or for any table.
#### mutations
A mutation can be configured for a specific table or for any table. So the given column name can be used for any table when existent. So you can replace all `email` columns by a fake email like so:
```php
$config->addMutation('email', fn() => fake()->email);
```
#### behaviour
We can decided what to do with the tables already existing on the target: keep it as is, or drop all unhandled tables.
Another option is to delete records before inserting the new ones or should the table be dropped before and the structure should be stored newly.
## Testing
```bash
composer test
```
## Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
## Contributing
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
## Security Vulnerabilities
Please review [our security policy](../../security/policy) on how to report security vulnerabilities.
## Credits
- [Robert Kummer](https://github.com/rokde)
- [All Contributors](../../contributors)
## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.