migrationOrder.php 1.82 KB
Newer Older
quentin.vrel's avatar
quentin.vrel committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;

class migrationOrder extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'migrate_in_order';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'This method migrate tables in order';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return int
     */
    public function handle()
    {
      $migrations = [
                      '2014_10_12_000000_create_users_table.php',
                      // '2014_10_12_100000_create_password_resets_table.php',
                      // '2014_10_12_200000_add_two_factor_columns_to_users_table.php',
                      // '2019_08_19_000000_create_failed_jobs_table.php',
                      // '2019_12_14_000001_create_personal_access_tokens_table.php',
                      // '2020_11_12_102755_create_sessions_table.php',
                      '2020_11_24_144826_create_category_table.php',
                      '2020_11_27_082400_game_table.php',
                      '2020_11_26_144745_create_tournament_table.php',
                      '2020_11_27_143058_create_part_table.php',
                      '2020_11_27_144427_create_participation_table.php',
                      '2020_11_28_142001_create_play_table.php'
      ];

      foreach($migrations as $migration)
      {
         $basePath = 'database/migrations/';
         $migrationName = trim($migration);
         $path = $basePath.$migrationName;
         $this->call('migrate:refresh', [
          '--path' => $path ,
         ]);
      }
    }
}