d

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore.

15 St Margarets, NY 10033
(+381) 11 123 4567
ouroffice@aware.com

 

KMF

Laravel Migration Actions | Laravel News

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:

1<?php

2 

3use DragonCodeLaravelActionsSupportActionable;

4use IlluminateSupportFacadesDB;

5 

6class ExampleAction extends Actionable

7{

8 protected $transactions = true;

9 

10 /**

11 * Run the actions.

12 *

13 * @return void

14 */

15 public function up(): void

16 {

17 DB::table('users')->insert([

18 'name' => 'Example User',

19 'email' => 'user@example.com',

20 'password' => bcrypt('password')

21 ]);

22 }

23 

24 /**

25 * Reverse the actions.

26 *

27 * @return void

28 */

29 public function down(): void

30 {

31 //

32 }

33}

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.

Credit: Source link

Previous Next
Close
Test Caption
Test Description goes like this