|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Rougin\Refinery\Commands; |
|
4
|
|
|
|
|
5
|
|
|
use Symfony\Component\Console\Input\InputOption; |
|
6
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
|
7
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
8
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
9
|
|
|
|
|
10
|
|
|
use Rougin\SparkPlug\Instance; |
|
11
|
|
|
use Rougin\Refinery\Common\MigrationHelper; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* Reset Migration Command |
|
15
|
|
|
* |
|
16
|
|
|
* Resets all migrations. |
|
17
|
|
|
* |
|
18
|
|
|
* @package Refinery |
|
19
|
|
|
* @author Rougin Royce Gutib <[email protected]> |
|
20
|
|
|
*/ |
|
21
|
|
|
class ResetCommand extends AbstractCommand |
|
22
|
|
|
{ |
|
23
|
|
|
/** |
|
24
|
|
|
* Sets the configurations of the specified command. |
|
25
|
|
|
* |
|
26
|
|
|
* @return void |
|
27
|
|
|
*/ |
|
28
|
10 |
|
protected function configure() |
|
29
|
|
|
{ |
|
30
|
10 |
|
$this->setName('reset') |
|
31
|
10 |
|
->setDescription('Resets all migrations'); |
|
32
|
10 |
|
} |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Executes the command. |
|
36
|
|
|
* |
|
37
|
|
|
* @param InputInterface $input |
|
38
|
|
|
* @param OutputInterface $output |
|
39
|
|
|
* @return object|OutputInterface |
|
40
|
|
|
*/ |
|
41
|
2 |
|
protected function execute(InputInterface $input, OutputInterface $output) |
|
42
|
|
|
{ |
|
43
|
2 |
|
$migration = file_get_contents(APPPATH . '/config/migration.php'); |
|
44
|
2 |
|
$current = MigrationHelper::getLatestVersion($migration); |
|
45
|
|
|
|
|
46
|
2 |
|
if ($current <= 0) { |
|
47
|
2 |
|
$message = 'Database\'s version is now in 0.'; |
|
48
|
|
|
|
|
49
|
2 |
|
return $output->writeln('<info>' . $message . '</info>'); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
// Enables migration and change the current version to 0 |
|
53
|
2 |
|
MigrationHelper::toggleMigration(true); |
|
54
|
2 |
|
MigrationHelper::changeVersion($current, 0); |
|
55
|
|
|
|
|
56
|
2 |
|
$this->codeigniter->load->library('migration'); |
|
|
|
|
|
|
57
|
2 |
|
$this->codeigniter->migration->current(); |
|
|
|
|
|
|
58
|
|
|
|
|
59
|
2 |
|
MigrationHelper::toggleMigration(); |
|
60
|
|
|
|
|
61
|
2 |
|
return $output->writeln('<info>Database has been resetted.</info>'); |
|
62
|
|
|
} |
|
63
|
|
|
} |
|
64
|
|
|
|
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.
If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.