Download the PHP package andrewgatenby/snapmigrations without Composer
On this page you can find all versions of the php package andrewgatenby/snapmigrations. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download andrewgatenby/snapmigrations
More information about andrewgatenby/snapmigrations
Files in andrewgatenby/snapmigrations
Package snapmigrations
Short Description Generates an SQL dump of your migrated (and seeded) database to save time re-running Migrations when running Integration and Acceptance Tests in a Lumen environment.
License
Informations about the package snapmigrations
Snap Migrations (for Lumen & Laravel)
This package is designed to be used within your TestCase class and allows for Lumen & Laravel applications to create a static SQL dump of a migrated (and seeded) database. It will automatically do this on the first Test run from a TestCase that uses this Trait. Each subsequent Test run will then use the SQL dumped copy of the database.
Install
Install the package via Composer:
Usage
After a successful installation, you can add SnapMigration
to your Test classes (potentially a parent class). This
package is designed to replace the regular DatabaseMigrations
class that you might use:
The Snap Migration SQL dump itself will be stored in storage/snap_migration.sql
by default, but this can be modified
by use of an environment variable called SNAP_MIGRATION_SQL_FILE
. Note that it would still be within storage/
.
If there is a new database migration created in database/migrations
then Snap Migrations will burst its own cached
copy and generate a new snapshot.
If the Snap Migration gets stuck or out of sync, you can manually delete the file and it will be built afresh.
The SnapMigrations
Trait has its own setUp
method as the main entry point. If your Test classes have their own
setUp
method, then you can alias the SnapMigrations::setUp
method, similar to this:
Credit
This package was inspired by the awesome looking Snipe Migrations that I'd tried to make use of first, but needed a Lumen-friendly implementation. It also uses the excellent MySQL Dump package.
All versions of snapmigrations with dependencies
dg/mysql-dump Version ^1.5
illuminate/database Version ^6.20.14|^7.0|^8.0|^9.0|^10.0