richan-fongdasen / database-converter-laravel
A database converter tool for Laravel Applications
Fund package maintenance!
richan-fongdasen
Requires
- php: ^8.2
- illuminate/console: ^11.0
- illuminate/contracts: ^11.0
- illuminate/database: ^11.0
- illuminate/support: ^11.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- larastan/larastan: ^2.9
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.1.1
- orchestra/testbench: ^9.0.0
- pestphp/pest: ^2.34
- pestphp/pest-plugin-arch: ^2.7
- pestphp/pest-plugin-laravel: ^2.3
- phpstan/extension-installer: ^1.3
- phpstan/phpstan-deprecation-rules: ^1.1
- phpstan/phpstan-phpunit: ^1.3
- phpstan/phpstan-strict-rules: ^1.5
README
This package provides a simple way to convert your database schema from one database management system to another. It is built on top of the Laravel framework.
Installation
You can install the package via composer:
composer require richan-fongdasen/database-converter-laravel
Publishing Configuration
You can publish the configuration file using the following command:
php artisan vendor:publish --provider="RichanFongdasen\DatabaseConverter\DatabaseConverterServiceProvider"
The above command publishes the configuration file to config/database-converter-laravel.php
, and the content of the configuration file will look like this:
return [ 'chunk_size' => 700, ];
Usage
In this example, we will convert the database schema from MySQL to SQLite.
Configure the database connection as conversion target
First, you need to configure the database connection that you want to convert to. You can do this by adding a new database connection configuration in your config/database.php
file.
'connections' => [ 'sqlite' => [ 'driver' => 'sqlite', 'database' => database_path('database.sqlite'), 'prefix' => '', 'foreign_key_constraints' => true, ], ],
Run database migration on the conversion target
Before you can convert the database schema, you need to run the migration on the conversion target database. You can do this by running the following command:
php artisan migrate --database=sqlite --path=database/migrations
Convert the database schema
Now, you can convert the database schema from MySQL to SQLite by running the following command:
php artisan db:convert mysql sqlite
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.