Squashing Migrations

Squashing Migrations and Schema Dumps

Years of migrations make a fresh install slow. schema:dump writes the current schema to database/schema/mysql-schema.sql (named after the connection), and --prune deletes the migrations it replaces:

Output of 77
$ php artisan schema:dump --prune
mysqldump: [Warning] Using a password on the command line interface can be insecure.
mysqldump: Error: 'SELECT command denied to user 'shop_app'@'localhost' for table
  'column_masking_policy'' when trying to dump masking policies
   INFO  Database schema dumped and pruned successfully.

The 241-line file holds the CREATE TABLE statements, CHECK and comments included, and ten INSERT INTO migrations rows. On a database with no migrations recorded, migrate loads it and then runs any migration it does not record, and so do tests that rebuild the database (Database Testing). Commit it. --prune deleted the whole database/migrations folder, and make:migration recreates it. Squashing supports MySQL 524 , MariaDB 3,681 , PostgreSQL 1,289 and SQLite 4,756 , and needs the mysqldump and mysql clients.