-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathInitCommand.php
More file actions
60 lines (52 loc) · 1.5 KB
/
InitCommand.php
File metadata and controls
60 lines (52 loc) · 1.5 KB
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
<?php
/**
* User: aguidet
* Date: 27/02/15
* Time: 17:13
*/
namespace Migrate\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class InitCommand extends AbstractEnvCommand
{
protected function configure()
{
$this
->setName('migrate:init')
->setDescription('Create the changelog table on your environment database')
->addArgument(
'env',
InputArgument::REQUIRED,
'Environment'
)->addOption(
'database',
null,
InputOption::VALUE_REQUIRED,
'Database '
)->addOption(
'driver',
null,
InputOption::VALUE_REQUIRED,
'DB driver'
);
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->init($input, $output);
$changelog = $this->getChangelogTable();
$this->getDb()->exec(
"
CREATE table $changelog
(
id numeric(20,0),
applied_at character varying(25),
version character varying(25),
description character varying(255)
)
"
);
$output->writeln("changelog table ($changelog) successfully created");
}
}