New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

ziming/laravel-specific-migrate-fresh

Migrate Fresh for Specific Tables Only
4,116
Install
composer require ziming/laravel-specific-migrate-fresh
Latest Version:0.3
PHP:^8.2
Laravel:10 – 13
Older releases:9
License:MIT
Last Updated:Jun 23, 2026
Links: GitHub  ·  Packagist
Maintainer: ziming.opensource

Laravel Specific Migrate:Fresh

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Want php artisan migrate:fresh but not drop all the tables? This is for you.

Support me

Donations are welcomed.

Installation

You can install the package via composer:

composer require ziming/laravel-specific-migrate-fresh

You can publish the config file with:

php artisan vendor:publish --tag="specific-migrate-fresh-config"

This is the contents of the published config file:

return [

    /*
     * There are 2 modes 'exclude' and 'include'.
     *
     * 'exclude' mode will drop all tables except the tables you specified in the 'excluded_tables' array.
     * 'include' mode will drop only the tables you specified in the 'included_tables' array.
     */
    'mode' => env('SPECIFIC_MIGRATE_FRESH_MODE', 'exclude'),

    /*
     * This will be used if mode is 'exclude'.
     *
     * If mode is 'exclude', the database tables in this array will be excluded
     * from getting dropped.
     */
    'excluded_tables' => [
        //
    ],

    /*
     * This will be used if mode is 'include'.
     *
     * If mode is 'include', only the database tables in this array will be dropped
     */
    'included_tables' => [
        //
    ],
];

Usage

Go to the config file, choose your preferred mode ('exclude' or 'include').

Fill in the relevant array ('excluded_tables' or 'included_tables').

Go to your migrations and for the tables you do not want to drop, in the up() method, add in a conditional check to skip the migration if the table still exists. You need to do this so that php artisan migrate will not throw an error about the table or column already exist later.

<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        if (Schema::hasTable('some_giant_table_i_do_not_want_to_drop')) {
            return;
        }

        Schema::create('some_giant_table_i_do_not_want_to_drop', function (Blueprint $table) {
            $table->id();
            // Other columns
        }
}

And call the command below. The --seed option is optional.

php artisan migrate:specific-fresh --seed

The end of this command simply just call the php artisan migrate --seed command at the end.

If you do not want to call your DatabaseSeeder. Leave out --seed from your command.

php artisan migrate:specific-fresh

Testing

PRs are welcomed on this

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.

Related Packages

ziming/laravel-myinfo-sg

Laravel Package for Singapore MyInfo

42,204 16
ziming/laravel-zxcvbn

Zxcvbn Password validation rule for Laravel

86,067 31
ziming/laravel-statsig

Laravel Package for Statsig

56,829 6
ziming/laravel-memory-health-check

Memory Health Check for Spatie Laravel Health Check and Oh Dear

48,235 1
ziming/laravel-email-sniper-link

Laravel package to generate email sniper links based on given email

35,268 15

Version History

Version Released PHP Laravel License
0.3 ^8.2 ^10.0||^11.0||^12.0||^13.0 MIT
0.2 ^8.1 ^9.0||^10.0||^11.0 MIT
0.1 ^8.1 ^9.0 MIT