Laravel Migration Actions
Published on by Paul Redmond
Laravel migration actions is like version control for your migration process, allowing your team to modify and share the application's actionable schema. If you have ever had to tell a teammate to perform any action on a production server manually, you've come across an issue that actions solve.
Actions are stored within a database/actions
folder and operate similarly to the way migrations work. This package also includes an Artisan command to create new actions. Here's what an example action might look like:
<?php use DragonCode\LaravelActions\Support\Actionable;use Illuminate\Support\Facades\DB; class ExampleAction extends Actionable{ protected $transactions = true; /** * Run the actions. * * @return void */ public function up(): void { DB::table('users')->insert([ 'name' => 'Example User', 'email' => 'user@example.com', 'password' => bcrypt('password') ]); } /** * Reverse the actions. * * @return void */ public function down(): void { // }}
Some of the packages main features include:
- Ability to run actions every time you call
migrate:actions
command - Execution of actions only in specific environments
- Exclude actions from specific environments
- Easy database transactions in actions with configurable attempts before failing
- Rolling back actions
- Display the status of actions in the current environment
You can learn more about this package, get full installation instructions, and view the source code on GitHub.