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 RollbackCommand extends BaseCommand
10
{
11
    use ConfirmableTrait;
12
 
13
    /**
14
     * The console command name.
15
     *
16
     * @var string
17
     */
18
    protected $name = 'migrate:rollback';
19
 
20
    /**
21
     * The console command description.
22
     *
23
     * @var string
24
     */
25
    protected $description = 'Rollback the last database migration';
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
        $this->migrator->usingConnection($this->option('database'), function () {
59
            $this->migrator->setOutput($this->output)->rollback(
60
                $this->getMigrationPaths(), [
61
                    'pretend' => $this->option('pretend'),
62
                    'step' => (int) $this->option('step'),
63
                ]
64
            );
65
        });
66
 
67
        return 0;
68
    }
69
 
70
    /**
71
     * Get the console command options.
72
     *
73
     * @return array
74
     */
75
    protected function getOptions()
76
    {
77
        return [
78
            ['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use'],
79
 
80
            ['force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production'],
81
 
82
            ['path', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'The path(s) to the migrations files to be executed'],
83
 
84
            ['realpath', null, InputOption::VALUE_NONE, 'Indicate any provided migration file paths are pre-resolved absolute paths'],
85
 
86
            ['pretend', null, InputOption::VALUE_NONE, 'Dump the SQL queries that would be run'],
87
 
88
            ['step', null, InputOption::VALUE_OPTIONAL, 'The number of migrations to be reverted'],
89
        ];
90
    }
91
}