richan-fongdasen/database-converter-laravel

A database converter tool for Laravel Applications

0.1.0 2024-05-04 09:00 UTC

This package is auto-updated.

Last update: 2024-05-17 07:09:22 UTC


README

Latest Version on Packagist License: MIT PHPStan Test Coding Style Total Downloads

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.