Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
namespace Illuminate\Database\Console\Migrations;
4
 
5
use Illuminate\Console\ConfirmableTrait;
6
use Illuminate\Database\Migrations\Migrator;
7
use Symfony\Component\Console\Input\InputOption;
8
 
9
class ResetCommand extends BaseCommand
10
{
11
    use ConfirmableTrait;
12
 
13
    /**
14
     * The console command name.
15
     *
16
     * @var string
17
     */
18
    protected $name = 'migrate:reset';
19
 
20
    /**
21
     * The console command description.
22
     *
23
     * @var string
24
     */
25
    protected $description = 'Rollback all database migrations';
26
 
27
    /**
28
     * The migrator instance.
29
     *
30
     * @var \Illuminate\Database\Migrations\Migrator
31
     */
32
    protected $migrator;
33
 
34
    /**
35
     * Create a new migration rollback command instance.
36
     *
37
     * @param  \Illuminate\Database\Migrations\Migrator  $migrator
38
     * @return void
39
     */
40
    public function __construct(Migrator $migrator)
41
    {
42
        parent::__construct();
43
 
44
        $this->migrator = $migrator;
45
    }
46
 
47
    /**
48
     * Execute the console command.
49
     *
50
     * @return int
51
     */
52
    public function handle()
53
    {
54
        if (! $this->confirmToProceed()) {
55
            return 1;
56
        }
57
 
58
        return $this->migrator->usingConnection($this->option('database'), function () {
59
            // First, we'll make sure that the migration table actually exists before we
60
            // start trying to rollback and re-run all of the migrations. If it's not
61
            // present we'll just bail out with an info message for the developers.
62
            if (! $this->migrator->repositoryExists()) {
63
                return $this->components->warn('Migration table not found.');
64
            }
65
 
66
            $this->migrator->setOutput($this->output)->reset(
67
                $this->getMigrationPaths(), $this->option('pretend')
68
            );
69
        });
70
    }
71
 
72
    /**
73
     * Get the console command options.
74
     *
75
     * @return array
76
     */
77
    protected function getOptions()
78
    {
79
        return [
80
            ['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use'],
81
 
82
            ['force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production'],
83
 
84
            ['path', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'The path(s) to the migrations files to be executed'],
85
 
86
            ['realpath', null, InputOption::VALUE_NONE, 'Indicate any provided migration file paths are pre-resolved absolute paths'],
87
 
88
            ['pretend', null, InputOption::VALUE_NONE, 'Dump the SQL queries that would be run'],
89
        ];
90
    }
91
}