This package is a slim package that allows you to export your Laravel database migrations to an SQL file.
Before using the package, make sure you have the following requirements:
- PHP 8.1 or higher
- Laravel 10 or higher
- Composer
Install the package via composer (as a dev dependency):
composer require --dev minvws/laravel-sql-exporterAfter installing the package, you can run the following command to export your migrations to an SQL file:
vendor/bin/sail artisan sql-export migration_descriptionBy default, the laravel migrations are read from the database/migrations folder of the working directory.
By default, the SQL file will be saved in the database/sql folder of the working directory.
You can specify the laravel migrations and the output location by adding
the laravelMigrationsPath or the sqlMigrationsPath arguments:
vendor/bin/sail artisan sql-export migration_description \
--laravelMigrationsPath=/path/to/laravel/migrations \
--sqlMigrationsPath=/path/to/sql/migrationsTo contribute to the development of this package, you can clone the repository and run the following command to install the dependencies:
composer installA running PostgreSQL database is required to run the tests. To create the database run the following command:
docker run --name laravel-sql-export-test-postgres -v "$(pwd)/tests/fixtures/init.sql:/docker-entrypoint-initdb.d/10-create-testing-database.sql" -e POSTGRES_PASSWORD=password -p 55322:5432 -d postgres || docker start laravel-sql-export-test-postgres || echo "Unable to start Postgres container, it may already be running"To run the tests, you can use the following command:
vendor/bin/phpunitTo stop and remove the PostgreSQL container after running the tests, you can use:
docker stop laravel-sql-export-test-postgres
docker rm laravel-sql-export-test-postgresIf you encounter any issues or have suggestions for improvements, please feel free to open an issue or submit a pull request on the GitHub repository of this package.
This package is open-source and released under the European Union Public License version 1.2. You are free to use, modify, and distribute the package in accordance with the terms of the license.
This package is part of the iCore project.