@@ -70,7 +70,7 @@ |
||
70 | 70 | ) { |
71 | 71 | parent::__construct($app, $config, $filesystem); |
72 | 72 | $this->setName('seed:exec') |
73 | - ->setDescription('Command to execute seed'); |
|
73 | + ->setDescription('Command to execute seed'); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -57,8 +57,7 @@ discard block |
||
57 | 57 | * @template T |
58 | 58 | * @extends AbstractSeedCommand<T> |
59 | 59 | */ |
60 | -class SeedExecuteCommand extends AbstractSeedCommand |
|
61 | -{ |
|
60 | +class SeedExecuteCommand extends AbstractSeedCommand { |
|
62 | 61 | /** |
63 | 62 | * Create new instance |
64 | 63 | * {@inheritdoc} |
@@ -67,7 +66,7 @@ discard block |
||
67 | 66 | Application $app, |
68 | 67 | Config $config, |
69 | 68 | Filesystem $filesystem |
70 | - ) { |
|
69 | + ) { |
|
71 | 70 | parent::__construct($app, $config, $filesystem); |
72 | 71 | $this->setName('seed:exec') |
73 | 72 | ->setDescription('Command to execute seed'); |
@@ -76,23 +75,22 @@ discard block |
||
76 | 75 | /** |
77 | 76 | * {@inheritdoc} |
78 | 77 | */ |
79 | - public function execute() |
|
80 | - { |
|
78 | + public function execute() { |
|
81 | 79 | $io = $this->io(); |
82 | 80 | $writer = $io->writer(); |
83 | 81 | $writer->boldYellow('SEED EXECUTION', true)->eol(); |
84 | 82 | |
85 | 83 | $seeds = array_values($this->getAvailableSeeds()); |
86 | 84 | |
87 | - if (empty($seeds)) { |
|
85 | + if (empty($seeds)) { |
|
88 | 86 | $writer->boldGreen('No seed available for execution'); |
89 | - } else { |
|
87 | + } else { |
|
90 | 88 | $choices = []; |
91 | - foreach ($seeds as $key => $seed) { |
|
89 | + foreach ($seeds as $key => $seed) { |
|
92 | 90 | $choices[$key + 1] = $seed; |
93 | 91 | } |
94 | 92 | $indexes = $io->choices('Choose which seed to execute', $choices, []); |
95 | - foreach ($indexes as $index) { |
|
93 | + foreach ($indexes as $index) { |
|
96 | 94 | $this->executeSeed($seeds[$index - 1]); |
97 | 95 | } |
98 | 96 | } |
@@ -53,8 +53,7 @@ |
||
53 | 53 | * @class AbstractSeed |
54 | 54 | * @package Platine\Framework\Migration\Seed |
55 | 55 | */ |
56 | -abstract class AbstractSeed extends QueryBuilder |
|
57 | -{ |
|
56 | +abstract class AbstractSeed extends QueryBuilder { |
|
58 | 57 | /** |
59 | 58 | * Run the seed |
60 | 59 | * @return void |
@@ -72,7 +72,7 @@ |
||
72 | 72 | ) { |
73 | 73 | parent::__construct($app, $repository, $config, $filesystem); |
74 | 74 | $this->setName('migration:migrate') |
75 | - ->setDescription('Upgrade migration to latest'); |
|
75 | + ->setDescription('Upgrade migration to latest'); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
@@ -58,8 +58,7 @@ discard block |
||
58 | 58 | * @template T |
59 | 59 | * @extends AbstractCommand<T> |
60 | 60 | */ |
61 | -class MigrationMigrateCommand extends AbstractCommand |
|
62 | -{ |
|
61 | +class MigrationMigrateCommand extends AbstractCommand { |
|
63 | 62 | /** |
64 | 63 | * Create new instance |
65 | 64 | * {@inheritdoc} |
@@ -69,7 +68,7 @@ discard block |
||
69 | 68 | MigrationRepository $repository, |
70 | 69 | Config $config, |
71 | 70 | Filesystem $filesystem |
72 | - ) { |
|
71 | + ) { |
|
73 | 72 | parent::__construct($app, $repository, $config, $filesystem); |
74 | 73 | $this->setName('migration:migrate') |
75 | 74 | ->setDescription('Upgrade migration to latest'); |
@@ -78,8 +77,7 @@ discard block |
||
78 | 77 | /** |
79 | 78 | * {@inheritdoc} |
80 | 79 | */ |
81 | - public function execute() |
|
82 | - { |
|
80 | + public function execute() { |
|
83 | 81 | $io = $this->io(); |
84 | 82 | $writer = $io->writer(); |
85 | 83 | $writer->boldYellow('MIGRATION UPGRADE TO LATEST', true)->eol(); |
@@ -88,23 +86,23 @@ discard block |
||
88 | 86 | $executed = $this->getExecuted(); |
89 | 87 | $diff = array_diff_key($migrations, $executed); |
90 | 88 | |
91 | - if (empty($diff)) { |
|
89 | + if (empty($diff)) { |
|
92 | 90 | $writer->boldGreen('Migration already up to date'); |
93 | 91 | return; |
94 | 92 | } |
95 | 93 | |
96 | 94 | $writer->bold('Migration list to be upgraded:', true); |
97 | - foreach ($diff as $version => $value) { |
|
95 | + foreach ($diff as $version => $value) { |
|
98 | 96 | $cleanDescription = str_replace('_', ' ', $value); |
99 | 97 | $writer->boldGreen(sprintf(' * %s - %s', $version, $cleanDescription), true); |
100 | 98 | } |
101 | 99 | |
102 | 100 | $writer->write('', true); |
103 | 101 | |
104 | - if ($io->confirm('Are you confirm the migration upgrade to latest?', 'n')) { |
|
102 | + if ($io->confirm('Are you confirm the migration upgrade to latest?', 'n')) { |
|
105 | 103 | /** @var MigrationExecuteCommand<T> $migrationExecute */ |
106 | 104 | $migrationExecute = $this->application->get(MigrationExecuteCommand::class); |
107 | - foreach ($diff as $version => $description) { |
|
105 | + foreach ($diff as $version => $description) { |
|
108 | 106 | $cleanDescription = str_replace('_', ' ', $description); |
109 | 107 | $version = (string) $version; |
110 | 108 | $migrationExecute->executeMigrationUp($version, $cleanDescription); |
@@ -219,9 +219,9 @@ discard block |
||
219 | 219 | { |
220 | 220 | /** @var MigrationEntity[] $migrations */ |
221 | 221 | $migrations = $this->repository |
222 | - ->query() |
|
223 | - ->orderBy('version', $orderDir) |
|
224 | - ->all(); |
|
222 | + ->query() |
|
223 | + ->orderBy('version', $orderDir) |
|
224 | + ->all(); |
|
225 | 225 | $result = []; |
226 | 226 | |
227 | 227 | foreach ($migrations as $entity) { |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | protected function getMigrationClassName(string $description, string $version): string |
244 | 244 | { |
245 | 245 | return Str::camel($description, false) |
246 | - . Str::replaceFirst('_', '', $version); |
|
246 | + . Str::replaceFirst('_', '', $version); |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | /** |
@@ -66,8 +66,7 @@ discard block |
||
66 | 66 | * @package Platine\Framework\Migration\Command |
67 | 67 | * @template T |
68 | 68 | */ |
69 | -abstract class AbstractCommand extends Command |
|
70 | -{ |
|
69 | +abstract class AbstractCommand extends Command { |
|
71 | 70 | /** |
72 | 71 | * The migration repository |
73 | 72 | * @var MigrationRepository |
@@ -116,7 +115,7 @@ discard block |
||
116 | 115 | MigrationRepository $repository, |
117 | 116 | Config $config, |
118 | 117 | Filesystem $filesystem |
119 | - ) { |
|
118 | + ) { |
|
120 | 119 | parent::__construct('migration', 'Command to manage database migration'); |
121 | 120 | $this->application = $app; |
122 | 121 | $this->repository = $repository; |
@@ -135,7 +134,7 @@ discard block |
||
135 | 134 | { |
136 | 135 | $directory = $this->filesystem->directory($this->migrationPath); |
137 | 136 | |
138 | - if (!$directory->exists() || !$directory->isWritable()) { |
|
137 | + if (!$directory->exists() || !$directory->isWritable()) { |
|
139 | 138 | throw new RuntimeException(sprintf( |
140 | 139 | 'Migration directory [%s] does not exist or is writable', |
141 | 140 | $this->migrationPath |
@@ -162,7 +161,7 @@ discard block |
||
162 | 161 | $file = $this->filesystem->file($fullPath); |
163 | 162 | $fullClassName = 'Platine\\Framework\\Migration\\' . $className; |
164 | 163 | |
165 | - if (!$file->exists()) { |
|
164 | + if (!$file->exists()) { |
|
166 | 165 | throw new RuntimeException(sprintf( |
167 | 166 | 'Migration file [%s] does not exist', |
168 | 167 | $fullPath |
@@ -171,7 +170,7 @@ discard block |
||
171 | 170 | |
172 | 171 | require_once $fullPath; |
173 | 172 | |
174 | - if (!class_exists($fullClassName)) { |
|
173 | + if (!class_exists($fullClassName)) { |
|
175 | 174 | throw new RuntimeException(sprintf( |
176 | 175 | 'Migration class [%s] does not exist', |
177 | 176 | $fullClassName |
@@ -198,9 +197,9 @@ discard block |
||
198 | 197 | $result = []; |
199 | 198 | /** @var FileInterface[] $files */ |
200 | 199 | $files = $directory->read(DirectoryInterface::FILE); |
201 | - foreach ($files as $file) { |
|
200 | + foreach ($files as $file) { |
|
202 | 201 | $matches = []; |
203 | - if (preg_match('/^([0-9_]+)_([a-z0-9_]+)\.php$/i', $file->getName(), $matches)) { |
|
202 | + if (preg_match('/^([0-9_]+)_([a-z0-9_]+)\.php$/i', $file->getName(), $matches)) { |
|
204 | 203 | $result[$matches[1]] = $matches[2]; |
205 | 204 | } |
206 | 205 | } |
@@ -224,7 +223,7 @@ discard block |
||
224 | 223 | ->all(); |
225 | 224 | $result = []; |
226 | 225 | |
227 | - foreach ($migrations as $entity) { |
|
226 | + foreach ($migrations as $entity) { |
|
228 | 227 | /** @var string $version */ |
229 | 228 | $version = $entity->version; |
230 | 229 |
@@ -81,7 +81,7 @@ |
||
81 | 81 | ) { |
82 | 82 | parent::__construct($app, $repository, $config, $filesystem); |
83 | 83 | $this->setName('migration:create') |
84 | - ->setDescription('Create a new migration'); |
|
84 | + ->setDescription('Create a new migration'); |
|
85 | 85 | |
86 | 86 | $this->addArgument('name', 'name of migration', null, false, true); |
87 | 87 | } |
@@ -61,8 +61,7 @@ discard block |
||
61 | 61 | * @template T |
62 | 62 | * @extends AbstractCommand<T> |
63 | 63 | */ |
64 | -class MigrationCreateCommand extends AbstractCommand |
|
65 | -{ |
|
64 | +class MigrationCreateCommand extends AbstractCommand { |
|
66 | 65 | /** |
67 | 66 | * The migration name |
68 | 67 | * @var string |
@@ -78,7 +77,7 @@ discard block |
||
78 | 77 | MigrationRepository $repository, |
79 | 78 | Config $config, |
80 | 79 | Filesystem $filesystem |
81 | - ) { |
|
80 | + ) { |
|
82 | 81 | parent::__construct($app, $repository, $config, $filesystem); |
83 | 82 | $this->setName('migration:create') |
84 | 83 | ->setDescription('Create a new migration'); |
@@ -89,8 +88,7 @@ discard block |
||
89 | 88 | /** |
90 | 89 | * {@inheritdoc} |
91 | 90 | */ |
92 | - public function execute() |
|
93 | - { |
|
91 | + public function execute() { |
|
94 | 92 | $writer = $this->io()->writer(); |
95 | 93 | |
96 | 94 | $version = date('Ymd_His'); |
@@ -113,7 +111,7 @@ discard block |
||
113 | 111 | |
114 | 112 | $io = $this->io(); |
115 | 113 | |
116 | - if ($io->confirm('Are you confirm the generation of new migration?', 'n')) { |
|
114 | + if ($io->confirm('Are you confirm the generation of new migration?', 'n')) { |
|
117 | 115 | $this->checkMigrationPath(); |
118 | 116 | $this->generateClass($fullPath, $className); |
119 | 117 | $writer->boldGreen(sprintf( |
@@ -131,7 +129,7 @@ discard block |
||
131 | 129 | $writer->boldYellow('MIGRATION GENERATION', true)->eol(); |
132 | 130 | |
133 | 131 | $name = $this->getArgumentValue('name'); |
134 | - if (!$name) { |
|
132 | + if (!$name) { |
|
135 | 133 | $io = $this->io(); |
136 | 134 | $name = $io->prompt('Enter the name of the migration', 'Migration description'); |
137 | 135 | } |
@@ -72,7 +72,7 @@ |
||
72 | 72 | ) { |
73 | 73 | parent::__construct($app, $repository, $config, $filesystem); |
74 | 74 | $this->setName('migration:reset') |
75 | - ->setDescription('Rollback all migration done before'); |
|
75 | + ->setDescription('Rollback all migration done before'); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
@@ -58,8 +58,7 @@ discard block |
||
58 | 58 | * @template T |
59 | 59 | * @extends AbstractCommand<T> |
60 | 60 | */ |
61 | -class MigrationResetCommand extends AbstractCommand |
|
62 | -{ |
|
61 | +class MigrationResetCommand extends AbstractCommand { |
|
63 | 62 | /** |
64 | 63 | * Create new instance |
65 | 64 | * {@inheritdoc} |
@@ -69,7 +68,7 @@ discard block |
||
69 | 68 | MigrationRepository $repository, |
70 | 69 | Config $config, |
71 | 70 | Filesystem $filesystem |
72 | - ) { |
|
71 | + ) { |
|
73 | 72 | parent::__construct($app, $repository, $config, $filesystem); |
74 | 73 | $this->setName('migration:reset') |
75 | 74 | ->setDescription('Rollback all migration done before'); |
@@ -78,21 +77,20 @@ discard block |
||
78 | 77 | /** |
79 | 78 | * {@inheritdoc} |
80 | 79 | */ |
81 | - public function execute() |
|
82 | - { |
|
80 | + public function execute() { |
|
83 | 81 | $io = $this->io(); |
84 | 82 | $writer = $io->writer(); |
85 | 83 | $writer->boldYellow('ALL MIGRATION ROLLBACK', true)->eol(); |
86 | 84 | |
87 | 85 | $executed = $this->getExecuted('DESC'); |
88 | 86 | |
89 | - if (empty($executed)) { |
|
87 | + if (empty($executed)) { |
|
90 | 88 | $writer->boldGreen('No migration done before'); |
91 | 89 | return; |
92 | 90 | } |
93 | 91 | |
94 | 92 | $writer->bold('Migration list to be rollback:', true); |
95 | - foreach ($executed as $version => $entity) { |
|
93 | + foreach ($executed as $version => $entity) { |
|
96 | 94 | $writer->boldGreen( |
97 | 95 | sprintf(' * %s - %s', $version, $entity->description), |
98 | 96 | true |
@@ -101,10 +99,10 @@ discard block |
||
101 | 99 | |
102 | 100 | $writer->write('', true); |
103 | 101 | |
104 | - if ($io->confirm('Are you confirm the migration rollback ?', 'n')) { |
|
102 | + if ($io->confirm('Are you confirm the migration rollback ?', 'n')) { |
|
105 | 103 | /** @var MigrationExecuteCommand<T> $migrationExecute */ |
106 | 104 | $migrationExecute = $this->application->get(MigrationExecuteCommand::class); |
107 | - foreach ($executed as $version => $entity) { |
|
105 | + foreach ($executed as $version => $entity) { |
|
108 | 106 | $migrationExecute->executeMigrationDown($version, $entity->description); |
109 | 107 | } |
110 | 108 |
@@ -73,7 +73,7 @@ |
||
73 | 73 | ) { |
74 | 74 | parent::__construct($app, $repository, $config, $filesystem); |
75 | 75 | $this->setName('migration:status') |
76 | - ->setDescription('Show current status of your migrations'); |
|
76 | + ->setDescription('Show current status of your migrations'); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | /** |
@@ -59,8 +59,7 @@ discard block |
||
59 | 59 | * @template T |
60 | 60 | * @extends AbstractCommand<T> |
61 | 61 | */ |
62 | -class MigrationStatusCommand extends AbstractCommand |
|
63 | -{ |
|
62 | +class MigrationStatusCommand extends AbstractCommand { |
|
64 | 63 | /** |
65 | 64 | * Create new instance |
66 | 65 | * {@inheritdoc} |
@@ -70,7 +69,7 @@ discard block |
||
70 | 69 | MigrationRepository $repository, |
71 | 70 | Config $config, |
72 | 71 | Filesystem $filesystem |
73 | - ) { |
|
72 | + ) { |
|
74 | 73 | parent::__construct($app, $repository, $config, $filesystem); |
75 | 74 | $this->setName('migration:status') |
76 | 75 | ->setDescription('Show current status of your migrations'); |
@@ -79,8 +78,7 @@ discard block |
||
79 | 78 | /** |
80 | 79 | * {@inheritdoc} |
81 | 80 | */ |
82 | - public function execute() |
|
83 | - { |
|
81 | + public function execute() { |
|
84 | 82 | $writer = $this->io()->writer(); |
85 | 83 | $writer->boldYellow('MIGRATION STATUS', true)->eol(); |
86 | 84 | $writer->bold('Migration path: '); |
@@ -99,7 +97,7 @@ discard block |
||
99 | 97 | $writer->boldYellow('MIGRATION LIST', true); |
100 | 98 | |
101 | 99 | $rows = []; |
102 | - foreach ($executed as $version => $entity) { |
|
100 | + foreach ($executed as $version => $entity) { |
|
103 | 101 | $rows[] = [ |
104 | 102 | 'version' => (string) $version, |
105 | 103 | 'description' => $entity->description, |
@@ -108,7 +106,7 @@ discard block |
||
108 | 106 | ]; |
109 | 107 | } |
110 | 108 | |
111 | - foreach ($diff as $version => $description) { |
|
109 | + foreach ($diff as $version => $description) { |
|
112 | 110 | $cleanDescription = str_replace('_', ' ', $description); |
113 | 111 | $version = (string) $version; |
114 | 112 | $rows[] = [ |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | ) { |
82 | 82 | parent::__construct($app, $repository, $config, $filesystem); |
83 | 83 | $this->setName('migration:init') |
84 | - ->setDescription('Initialize the migration by creating migration table'); |
|
84 | + ->setDescription('Initialize the migration by creating migration table'); |
|
85 | 85 | |
86 | 86 | $this->schema = $schema; |
87 | 87 | } |
@@ -119,10 +119,10 @@ discard block |
||
119 | 119 | $tableName = $this->table; |
120 | 120 | $this->schema->create($tableName, function (CreateTable $table) { |
121 | 121 | $table->string('version', 20) |
122 | - ->description('The migration version') |
|
123 | - ->primary(); |
|
122 | + ->description('The migration version') |
|
123 | + ->primary(); |
|
124 | 124 | $table->string('description') |
125 | - ->description('The migration description'); |
|
125 | + ->description('The migration description'); |
|
126 | 126 | $table->datetime('created_at') |
127 | 127 | ->description('Migration run time'); |
128 | 128 |
@@ -117,7 +117,7 @@ |
||
117 | 117 | protected function createMigrationTable(): void |
118 | 118 | { |
119 | 119 | $tableName = $this->table; |
120 | - $this->schema->create($tableName, function (CreateTable $table) { |
|
120 | + $this->schema->create($tableName, function(CreateTable $table) { |
|
121 | 121 | $table->string('version', 20) |
122 | 122 | ->description('The migration version') |
123 | 123 | ->primary(); |
@@ -60,8 +60,7 @@ discard block |
||
60 | 60 | * @template T |
61 | 61 | * @extends AbstractCommand<T> |
62 | 62 | */ |
63 | -class MigrationInitCommand extends AbstractCommand |
|
64 | -{ |
|
63 | +class MigrationInitCommand extends AbstractCommand { |
|
65 | 64 | /** |
66 | 65 | * The schema to use |
67 | 66 | * @var Schema |
@@ -78,7 +77,7 @@ discard block |
||
78 | 77 | Schema $schema, |
79 | 78 | Config $config, |
80 | 79 | Filesystem $filesystem |
81 | - ) { |
|
80 | + ) { |
|
82 | 81 | parent::__construct($app, $repository, $config, $filesystem); |
83 | 82 | $this->setName('migration:init') |
84 | 83 | ->setDescription('Initialize the migration by creating migration table'); |
@@ -89,13 +88,12 @@ discard block |
||
89 | 88 | /** |
90 | 89 | * {@inheritdoc} |
91 | 90 | */ |
92 | - public function execute() |
|
93 | - { |
|
91 | + public function execute() { |
|
94 | 92 | $io = $this->io(); |
95 | 93 | $writer = $io->writer(); |
96 | 94 | $writer->boldYellow('MIGRATION INITIALIZATION', true); |
97 | 95 | |
98 | - if ($this->schema->hasTable($this->table, true)) { |
|
96 | + if ($this->schema->hasTable($this->table, true)) { |
|
99 | 97 | $writer->boldRed(sprintf( |
100 | 98 | 'Migration table [%s] already created', |
101 | 99 | $this->table |
@@ -117,7 +115,7 @@ discard block |
||
117 | 115 | protected function createMigrationTable(): void |
118 | 116 | { |
119 | 117 | $tableName = $this->table; |
120 | - $this->schema->create($tableName, function (CreateTable $table) { |
|
118 | + $this->schema->create($tableName, function (CreateTable $table) { |
|
121 | 119 | $table->string('version', 20) |
122 | 120 | ->description('The migration version') |
123 | 121 | ->primary(); |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | ) { |
74 | 74 | parent::__construct($app, $repository, $config, $filesystem); |
75 | 75 | $this->setName('migration:exec') |
76 | - ->setDescription('Execute the migration up/down for one version'); |
|
76 | + ->setDescription('Execute the migration up/down for one version'); |
|
77 | 77 | |
78 | 78 | $this->addArgument('type', 'type of migration [up|down]', 'up', true, true, false, function ($val) { |
79 | 79 | if (!in_array($val, ['up', 'down'])) { |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | )); |
84 | 84 | } |
85 | 85 | |
86 | - return $val; |
|
86 | + return $val; |
|
87 | 87 | }); |
88 | 88 | |
89 | 89 | $this->addOption('-i|--id', 'the migration version', null, false, true); |
@@ -75,7 +75,7 @@ |
||
75 | 75 | $this->setName('migration:exec') |
76 | 76 | ->setDescription('Execute the migration up/down for one version'); |
77 | 77 | |
78 | - $this->addArgument('type', 'type of migration [up|down]', 'up', true, true, false, function ($val) { |
|
78 | + $this->addArgument('type', 'type of migration [up|down]', 'up', true, true, false, function($val) { |
|
79 | 79 | if (!in_array($val, ['up', 'down'])) { |
80 | 80 | throw new RuntimeException(sprintf( |
81 | 81 | 'Invalid argument type [%s], must be one of [up, down]', |
@@ -59,8 +59,7 @@ discard block |
||
59 | 59 | * @template T |
60 | 60 | * @extends AbstractCommand<T> |
61 | 61 | */ |
62 | -class MigrationExecuteCommand extends AbstractCommand |
|
63 | -{ |
|
62 | +class MigrationExecuteCommand extends AbstractCommand { |
|
64 | 63 | /** |
65 | 64 | * Create new instance |
66 | 65 | * {@inheritdoc} |
@@ -70,13 +69,13 @@ discard block |
||
70 | 69 | MigrationRepository $repository, |
71 | 70 | Config $config, |
72 | 71 | Filesystem $filesystem |
73 | - ) { |
|
72 | + ) { |
|
74 | 73 | parent::__construct($app, $repository, $config, $filesystem); |
75 | 74 | $this->setName('migration:exec') |
76 | 75 | ->setDescription('Execute the migration up/down for one version'); |
77 | 76 | |
78 | - $this->addArgument('type', 'type of migration [up|down]', 'up', true, true, false, function ($val) { |
|
79 | - if (!in_array($val, ['up', 'down'])) { |
|
77 | + $this->addArgument('type', 'type of migration [up|down]', 'up', true, true, false, function ($val) { |
|
78 | + if (!in_array($val, ['up', 'down'])) { |
|
80 | 79 | throw new RuntimeException(sprintf( |
81 | 80 | 'Invalid argument type [%s], must be one of [up, down]', |
82 | 81 | $val |
@@ -92,8 +91,7 @@ discard block |
||
92 | 91 | /** |
93 | 92 | * {@inheritdoc} |
94 | 93 | */ |
95 | - public function execute() |
|
96 | - { |
|
94 | + public function execute() { |
|
97 | 95 | $type = $this->getArgumentValue('type'); |
98 | 96 | |
99 | 97 | $io = $this->io(); |
@@ -104,43 +102,43 @@ discard block |
||
104 | 102 | $executed = $this->getExecuted('DESC'); |
105 | 103 | $version = $this->getOptionValue('id'); |
106 | 104 | |
107 | - if ($type === 'up') { |
|
105 | + if ($type === 'up') { |
|
108 | 106 | $diff = array_diff_key($migrations, $executed); |
109 | - if (empty($diff)) { |
|
107 | + if (empty($diff)) { |
|
110 | 108 | $writer->boldGreen('Migration already up to date'); |
111 | - } else { |
|
112 | - if (empty($version)) { |
|
109 | + } else { |
|
110 | + if (empty($version)) { |
|
113 | 111 | $version = $io->choice('Choose which version to migrate up', $diff); |
114 | 112 | } |
115 | 113 | |
116 | - if (!isset($diff[$version])) { |
|
114 | + if (!isset($diff[$version])) { |
|
117 | 115 | $writer->boldRed(sprintf( |
118 | 116 | 'Invalid migration version [%s] or already executed', |
119 | 117 | $version |
120 | 118 | )); |
121 | - } else { |
|
119 | + } else { |
|
122 | 120 | $description = str_replace('_', ' ', $migrations[$version]); |
123 | 121 | $this->executeMigrationUp($version, $description); |
124 | 122 | } |
125 | 123 | } |
126 | - } else { |
|
127 | - if (empty($executed)) { |
|
124 | + } else { |
|
125 | + if (empty($executed)) { |
|
128 | 126 | $writer->boldGreen('No migration to rollback'); |
129 | - } else { |
|
127 | + } else { |
|
130 | 128 | $data = []; |
131 | - foreach ($executed as $ver => $entity) { |
|
129 | + foreach ($executed as $ver => $entity) { |
|
132 | 130 | $data[$ver] = $entity->description; |
133 | 131 | } |
134 | - if (empty($version)) { |
|
132 | + if (empty($version)) { |
|
135 | 133 | $version = $io->choice('Choose which version to rollback', $data); |
136 | 134 | } |
137 | 135 | |
138 | - if (!isset($data[$version])) { |
|
136 | + if (!isset($data[$version])) { |
|
139 | 137 | $writer->boldRed(sprintf( |
140 | 138 | 'Invalid migration version [%s] or not yet executed', |
141 | 139 | $version |
142 | 140 | )); |
143 | - } else { |
|
141 | + } else { |
|
144 | 142 | $description = str_replace('_', ' ', $data[$version]); |
145 | 143 | $this->executeMigrationDown($version, $description); |
146 | 144 | } |
@@ -197,7 +195,7 @@ discard block |
||
197 | 195 | 'version' => $version |
198 | 196 | ]); |
199 | 197 | |
200 | - if ($entity) { |
|
198 | + if ($entity) { |
|
201 | 199 | $this->repository->delete($entity); |
202 | 200 | } |
203 | 201 | } |