{"id":13538579,"url":"https://github.com/spatie/laravel-migrate-fresh","last_synced_at":"2025-04-02T05:31:24.034Z","repository":{"id":57056534,"uuid":"78428025","full_name":"spatie/laravel-migrate-fresh","owner":"spatie","description":"An artisan command to build up a database from scratch","archived":true,"fork":false,"pushed_at":"2019-09-13T09:20:48.000Z","size":65,"stargazers_count":183,"open_issues_count":0,"forks_count":24,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-23T07:25:27.601Z","etag":null,"topics":["artisan","database","debug","eloquent","laravel","migrations","php"],"latest_commit_sha":null,"homepage":"https://murze.be/2017/01/laravel-package-rebuild-database/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/spatie.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-09T12:46:01.000Z","updated_at":"2023-01-28T17:15:23.000Z","dependencies_parsed_at":"2022-08-24T07:30:23.382Z","dependency_job_id":null,"html_url":"https://github.com/spatie/laravel-migrate-fresh","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Flaravel-migrate-fresh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Flaravel-migrate-fresh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Flaravel-migrate-fresh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Flaravel-migrate-fresh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spatie","download_url":"https://codeload.github.com/spatie/laravel-migrate-fresh/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246763805,"owners_count":20829795,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["artisan","database","debug","eloquent","laravel","migrations","php"],"created_at":"2024-08-01T09:01:13.678Z","updated_at":"2025-04-02T05:31:23.746Z","avatar_url":"https://github.com/spatie.png","language":"PHP","funding_links":[],"categories":["PHP"],"sub_categories":["Laravel"],"readme":"## The migrate:fresh command is included by default since Laravel 5.5.\n\n# An artisan command to build up the database from scratch\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/spatie/laravel-migrate-fresh.svg?style=flat-square)](https://packagist.org/packages/spatie/laravel-migrate-fresh)\n[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)\n[![Build Status](https://img.shields.io/travis/spatie/laravel-migrate-fresh/master.svg?style=flat-square)](https://travis-ci.org/spatie/laravel-migrate-fresh)\n[![Quality Score](https://img.shields.io/scrutinizer/g/spatie/laravel-migrate-fresh.svg?style=flat-square)](https://scrutinizer-ci.com/g/spatie/laravel-migrate-fresh)\n[![StyleCI](https://styleci.io/repos/78428025/shield?branch=master)](https://styleci.io/repos/78428025)\n[![Total Downloads](https://img.shields.io/packagist/dt/spatie/laravel-migrate-fresh.svg?style=flat-square)](https://packagist.org/packages/spatie/laravel-migrate-fresh)\n\nLaravel has a `migrate:refresh` command to build up the database using migrations. To clear the database it'll first rollback all migrations by using the `down` method in each migration.\n\nBut what if you don't use the `down` method inside your projects? The `migrate:refresh` command will fail as the database isn't cleared first.\n\nThis package contains a `migrate:fresh` command that'll nuke all the tables in your database regardless of whether you've set up the `down` method in each migration.\n\n## Postcardware\n\nYou're free to use this package (it's [MIT-licensed](LICENSE.md)), but if it makes it to your production environment we highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using.\n\nOur address is: Spatie, Samberstraat 69D, 2060 Antwerp, Belgium.\n\nThe best postcards are published [on our website](https://spatie.be/en/opensource/postcards).\n\n## Requirements\n\nThis command supports MySQL, sqlite, PostgreSQL and MS SQL databases.\n\n_Note: the `migrate:fresh` command is [included by default](https://laravel-news.com/migrate-fresh) in Laravel 5.5._\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require spatie/laravel-migrate-fresh\n```\n\nNext add the `Spatie\\MigrateFresh\\Commands\\MigrateFresh` class to your console kernel.\n\n```php\n// app/Console/Kernel.php\n\nprotected $commands = [\n   ...\n    \\Spatie\\MigrateFresh\\Commands\\MigrateFresh::class,\n]\n```\n\n## Usage\n\nThis command will drop all tables from your database and run all migrations. \n\n```bash\nphp artisan migrate:fresh\n```\n\n\u003e Be aware that the command will knock down all tables in the database. Tables not belonging to your application will be dropped as well.\n\n\nBy tagging on the `seed` option all seeders will run as well.\n \n```bash\nphp artisan migrate:fresh --seed\n```\n\nIf the command is being executed in a production environment, confirmation will be asked first. To suppress the confirmation use the `force` option.\n \n ```bash\n php artisan migrate:fresh --force\n ```\n \n### Events\n \nThis package fires several events, which you can hook into to perform some extra logic rebuilding the database.\n\n- `Spatie\\MigrateFresh\\Events\\DroppingTables`: will be fired right before dropping the first table\n- `Spatie\\MigrateFresh\\Events\\DroppedTables`: will be fired right after all the tables have been dropped and before running the `up` steps of the migrations\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.\n\n## Testing\n\nIn order for the test to be run you should set up an empty mysql database `laravel_migrate_fresh` . The username should be `root`, the required password should be empty.\n\n``` bash\n$ composer test\n```\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n## Security\n\nIf you discover any security related issues, please email freek@spatie.be instead of using the issue tracker.\n\n## Credits\n\n- [Freek Van der Herten](https://github.com/freekmurze)\n- [All Contributors](../../contributors)\n\nInitial code to drop all tables in a Postgresql db was provided by [Jonathan Reinink](https://gist.github.com/reinink) and reviewed by [Peter Matseykanets](https://github.com/pmatseykanets). Peter also added support for Sqlite.\n\n## About Spatie\nSpatie is a webdesign agency based in Antwerp, Belgium. You'll find an overview of all our open source projects [on our website](https://spatie.be/opensource).\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspatie%2Flaravel-migrate-fresh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspatie%2Flaravel-migrate-fresh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspatie%2Flaravel-migrate-fresh/lists"}