PHPackages                             ziming/laravel-specific-migrate-fresh - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. ziming/laravel-specific-migrate-fresh

ActiveLibrary[Database &amp; ORM](/categories/database)

ziming/laravel-specific-migrate-fresh
=====================================

Migrate Fresh for Specific Tables Only

0.3(1mo ago)04.0k2MITPHPPHP ^8.2CI failing

Since Sep 27Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/ziming/laravel-specific-migrate-fresh)[ Packagist](https://packagist.org/packages/ziming/laravel-specific-migrate-fresh)[ Docs](https://github.com/ziming/laravel-specific-migrate-fresh)[ GitHub Sponsors](https://github.com/ziming)[ RSS](/packages/ziming-laravel-specific-migrate-fresh/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (28)Versions (5)Used By (0)

Laravel Specific Migrate:Fresh
==============================

[](#laravel-specific-migratefresh)

[![Latest Version on Packagist](https://camo.githubusercontent.com/1e92603109f48daee69912767d8d112d534a413160c46e966871a6b9be73cf2d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7a696d696e672f6c61726176656c2d73706563696669632d6d6967726174652d66726573682e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ziming/laravel-specific-migrate-fresh)[![GitHub Tests Action Status](https://camo.githubusercontent.com/05c634def79083b6e28119c59f489251d8f55ba3ef1590b2605b629b62d3abb2/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f7a696d696e672f6c61726176656c2d73706563696669632d6d6967726174652d66726573682f72756e2d74657374733f6c6162656c3d7465737473)](https://github.com/ziming/laravel-specific-migrate-fresh/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/e3aa1e7641c419457a3f4a53f1f970d5e72f5d9146fd453b359e6227f3de0243/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f7a696d696e672f6c61726176656c2d73706563696669632d6d6967726174652d66726573682f466978253230504850253230636f64652532307374796c652532306973737565733f6c6162656c3d636f64652532307374796c65)](https://github.com/ziming/laravel-specific-migrate-fresh/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/3542b6929620382f898d43d2d3673821bad08bdfe0c64138cea4cdc0c577df1e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7a696d696e672f6c61726176656c2d73706563696669632d6d6967726174652d66726573682e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ziming/specific-migrate-fresh)

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

Support me
----------

[](#support-me)

Donations are welcomed.

Installation
------------

[](#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
-----

[](#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.

```
