{"id":33979191,"url":"https://github.com/onlinepets/laravel-conditional-migrations","last_synced_at":"2025-12-13T03:00:52.312Z","repository":{"id":55867431,"uuid":"127100183","full_name":"onlinepets/laravel-conditional-migrations","owner":"onlinepets","description":"⏰ Run your Laravel migrations only when you want them to","archived":false,"fork":false,"pushed_at":"2020-12-10T14:45:16.000Z","size":36,"stargazers_count":1,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-19T12:11:54.859Z","etag":null,"topics":["database","eloquent","laravel","laravel-package","migrations"],"latest_commit_sha":null,"homepage":"","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/onlinepets.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2018-03-28T07:19:21.000Z","updated_at":"2022-05-12T06:07:06.000Z","dependencies_parsed_at":"2022-08-15T08:10:17.382Z","dependency_job_id":null,"html_url":"https://github.com/onlinepets/laravel-conditional-migrations","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/onlinepets/laravel-conditional-migrations","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onlinepets%2Flaravel-conditional-migrations","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onlinepets%2Flaravel-conditional-migrations/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onlinepets%2Flaravel-conditional-migrations/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onlinepets%2Flaravel-conditional-migrations/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/onlinepets","download_url":"https://codeload.github.com/onlinepets/laravel-conditional-migrations/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onlinepets%2Flaravel-conditional-migrations/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27699211,"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","status":"online","status_checked_at":"2025-12-13T02:00:09.769Z","response_time":147,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["database","eloquent","laravel","laravel-package","migrations"],"created_at":"2025-12-13T03:00:19.307Z","updated_at":"2025-12-13T03:00:52.299Z","avatar_url":"https://github.com/onlinepets.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Deprecated:\n## We don't maintain this version anymore, checkout [Laravel conditional migrations](https://github.com/mll-lab/laravel-conditional-migrations) for the latest version\n\n---\n\n## Laravel Conditional Migrations\n\n[![Latest Version on Packagist][ico-version]][link-packagist]\n[![Total Downloads][ico-downloads]][link-downloads]\n[![Software License][ico-license]](LICENSE.md)\n[![Build Status][ico-travis]][link-travis]\n[![StyleCI][ico-styleci]][link-styleci]\n\nThis package allows you to configure migrations to run based on a condition. We\nexpose a `ConditionalMigration` interface, which you can have your migrations\nimplement to determine whether or not it should run.\n\n## Index\n- [Installation](#installation)\n  - [Downloading](#downloading)\n  - [Registering the service provider](#registering-the-service-provider)\n- [Usage](#usage)\n  - [Nightly cronjob](#nightly-cronjob)\n- [Configuration](#configuration)\n- [Contributing](#contributing)\n- [License](#license)\n\n## Installation\nYou'll have to follow a couple of steps to install this package.\n\n### Downloading\nVia [composer](http://getcomposer.org):\n\n```bash\n$ composer require onlinepets/laravel-conditional-migrations\n```\n\nOr add the package to your dependencies in `composer.json` and run\n`composer update` on the command line to download the package:\n\n```json\n{\n    \"require\": {\n        \"onlinepets/laravel-conditional-migrations\": \"^1.0\"\n    }\n}\n```\n\n\n### Registering the service provider\nIf you're **not** using [auto discovery](https://medium.com/@taylorotwell/package-auto-discovery-in-laravel-5-5-ea9e3ab20518),\nregister the `\\Onlinepets\\ConditionalMigrations\\ServiceProvider` in `config/app.php`:\n\n```php\n'providers' =\u003e [\n    // ...\n    Onlinepets\\ConditionalMigrations\\ServiceProvider::class,\n];\n```\n\n## Usage\nTo make sure a migration only runs between 1 AM and 2 AM, implement the `ConditionalMigration`\ninterface and its `-\u003eshouldRun()` method:\n\n```php\nuse Onlinepets\\ConditionalMigrations\\Contracts\\ConditionalMigration;\nuse Illuminate\\Database\\Migrations\\Migration;\nuse Illuminate\\Database\\Schema\\Blueprint;\nuse Illuminate\\Support\\Facades\\Schema;\nuse Illuminate\\Support\\Carbon;\n\nclass DoSomethingVeryIntensive extends Migration implements ConditionalMigration\n{\n    public function up()\n    {\n        Schema::table('users', function (Blueprint $table) {\n            //\n        });\n    }\n\n    public function down()\n    {\n        Schema::table('users', function (Blueprint $table) {\n            //\n        });\n    }\n\n    public function shouldRun(): bool\n    {\n        return (new Carbon('1 AM'))-\u003elessThan(now())\n            \u0026\u0026 (new Carbon('2 AM'))-\u003egreaterThan(now());\n    }\n}\n```\n\nThe code snippet above will make sure the `do_something_very_intensive` migration\nwill be skipped unless it is executed between 1 AM and 2 AM. This can be useful\nif your migration does something that should not be run during the daytime, like\nadding an index to a table containing lots of data.\n\n### Nightly cronjob\nTo take full advantage of this package, you can schedule a task to migrate the\ndatabase during the \"whitelisted\" times. **This package does not implement this**.\n\n## Configuration\nYou can optionally publish the configuration file:\n\n```bash\n$ php artisan vendor:publish --provider=\"Onlinepets\\ConditionalMigrations\\ServiceProvider\"\n```\n\nThis will create the file `config/conditional-migrations.php`, which is where you can\nconfigure whether your migrations should run, _regardless of individual configuration_:\n\n```php\nreturn [\n    \n    'always_run' =\u003e env('APP_DEBUG', false),\n    \n];\n``` \n\nYou can also use a closure if you want to do more advanced calculations:\n\n```php\nreturn [\n\n    'always_run' =\u003e function (): bool {\n        // calculate whether it should run\n    },\n\n];\n```\n\n## Contributing\nAll contributions (pull requests, issues and feature requests) are\nwelcome. Make sure to read through the [CONTRIBUTING.md](CONTRIBUTING.md) first,\nthough. See the [contributors page](../../graphs/contributors) for all contributors.\n\n## License\n`onlinepets/laravel-conditional-migrations` is licensed under the MIT License (MIT). Please\nsee the [license file](LICENSE.md) for more information.\n\n[ico-version]: https://img.shields.io/packagist/v/onlinepets/laravel-conditional-migrations.svg?style=flat-square\n[ico-license]: https://img.shields.io/badge/license-MIT-green.svg?style=flat-square\n[ico-downloads]: https://img.shields.io/packagist/dt/onlinepets/laravel-conditional-migrations.svg?style=flat-square\n[ico-travis]: https://img.shields.io/travis/onlinepets/laravel-conditional-migrations.svg?style=flat-square\n[ico-styleci]: https://styleci.io/repos/127100183/shield\n\n[link-packagist]: https://packagist.org/packages/onlinepets/laravel-conditional-migrations\n[link-downloads]: https://packagist.org/packages/onlinepets/laravel-conditional-migrations\n[link-travis]: https://travis-ci.org/onlinepets/laravel-conditional-migrations\n[link-styleci]: https://styleci.io/repos/127100183\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fonlinepets%2Flaravel-conditional-migrations","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fonlinepets%2Flaravel-conditional-migrations","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fonlinepets%2Flaravel-conditional-migrations/lists"}