Q:

Laravel many migrations issue

10 people start new project with laravel. 
After for example 2,3 years there will be many migrations.
In case when new programmer joins the team he will setup development environment with code and database.
The problem is that if there are many migrations it will run too slow if there are thousand of migrations.
How to handle this?

A:

Yes running 100s of migrations each time is going to become a headache. You'll want to create a snapshot of your database tables and make that your first migration.
For example lets say you have a blog with a posts and users table. For each table you're going to need a create table statement. If you're working with MySql to get your create table statement for your users table you would query:
SHOW CREATE TABLE users
Once you have your create table statements you can make a new migration which runs those queries and archive all your old migrations.
class CreateSnapshotTables extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        // Create users table
        DB::statement("
            CREATE TABLE `users` (
                `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
                `password` varchar(60) COLLATE utf8_unicode_ci NOT NULL,
                `email` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
                `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
                `remember_token` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
                `created_at` timestamp NULL DEFAULT NULL,
                `updated_at` timestamp NULL DEFAULT NULL,
                `deleted_at` timestamp NULL DEFAULT NULL,
                PRIMARY KEY (`id`),
                UNIQUE KEY `users_email_unique` (`email`)
            );
        ");

        // Create posts table
        DB::statement("
            CREATE TABLE `posts` (
                `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
                `title` varchar(255) COLLATE utf8_unicode_ci NOT NULL,

                // ...etc.

                PRIMARY KEY (`id`),
                UNIQUE KEY `users_email_unique` (`email`)
            );
        ");
    }
}

