@@ -8,41 +8,41 @@ |
||
8 | 8 | |
9 | 9 | class MigrationsOrganiserServiceProvider extends MSP |
10 | 10 | { |
11 | - public function register() |
|
12 | - { |
|
13 | - parent::register(); |
|
14 | - $this->registerMigrateOrganise(); |
|
15 | - $this->registerMigrateDisorganise(); |
|
16 | - $this->commands('command.migrate.organise', 'command.migrate.disorganise'); |
|
17 | - } |
|
18 | - |
|
19 | - protected function registerCreator() |
|
20 | - { |
|
21 | - $this->app->singleton('migration.creator', function ($app) { |
|
22 | - return new MigrationCreator($app['files']); |
|
23 | - }); |
|
24 | - } |
|
25 | - |
|
26 | - protected function registerMigrator() |
|
27 | - { |
|
28 | - $this->app->singleton('migrator', function ($app) { |
|
29 | - $repository = $app['migration.repository']; |
|
30 | - |
|
31 | - return new Migrator($repository, $app['db'], $app['files']); |
|
32 | - }); |
|
33 | - } |
|
34 | - |
|
35 | - protected function registerMigrateOrganise() |
|
36 | - { |
|
37 | - $this->app->singleton('command.migrate.organise', function ($app) { |
|
38 | - return new MigrateOrganise($app['files'], $app['migrator']); |
|
39 | - }); |
|
40 | - } |
|
41 | - |
|
42 | - protected function registerMigrateDisorganise() |
|
43 | - { |
|
44 | - $this->app->singleton('command.migrate.disorganise', function ($app) { |
|
45 | - return new MigrateDisorganise($app['files'], $app['migrator']); |
|
46 | - }); |
|
47 | - } |
|
11 | + public function register() |
|
12 | + { |
|
13 | + parent::register(); |
|
14 | + $this->registerMigrateOrganise(); |
|
15 | + $this->registerMigrateDisorganise(); |
|
16 | + $this->commands('command.migrate.organise', 'command.migrate.disorganise'); |
|
17 | + } |
|
18 | + |
|
19 | + protected function registerCreator() |
|
20 | + { |
|
21 | + $this->app->singleton('migration.creator', function ($app) { |
|
22 | + return new MigrationCreator($app['files']); |
|
23 | + }); |
|
24 | + } |
|
25 | + |
|
26 | + protected function registerMigrator() |
|
27 | + { |
|
28 | + $this->app->singleton('migrator', function ($app) { |
|
29 | + $repository = $app['migration.repository']; |
|
30 | + |
|
31 | + return new Migrator($repository, $app['db'], $app['files']); |
|
32 | + }); |
|
33 | + } |
|
34 | + |
|
35 | + protected function registerMigrateOrganise() |
|
36 | + { |
|
37 | + $this->app->singleton('command.migrate.organise', function ($app) { |
|
38 | + return new MigrateOrganise($app['files'], $app['migrator']); |
|
39 | + }); |
|
40 | + } |
|
41 | + |
|
42 | + protected function registerMigrateDisorganise() |
|
43 | + { |
|
44 | + $this->app->singleton('command.migrate.disorganise', function ($app) { |
|
45 | + return new MigrateDisorganise($app['files'], $app['migrator']); |
|
46 | + }); |
|
47 | + } |
|
48 | 48 | } |
@@ -18,14 +18,14 @@ discard block |
||
18 | 18 | |
19 | 19 | protected function registerCreator() |
20 | 20 | { |
21 | - $this->app->singleton('migration.creator', function ($app) { |
|
21 | + $this->app->singleton('migration.creator', function($app) { |
|
22 | 22 | return new MigrationCreator($app['files']); |
23 | 23 | }); |
24 | 24 | } |
25 | 25 | |
26 | 26 | protected function registerMigrator() |
27 | 27 | { |
28 | - $this->app->singleton('migrator', function ($app) { |
|
28 | + $this->app->singleton('migrator', function($app) { |
|
29 | 29 | $repository = $app['migration.repository']; |
30 | 30 | |
31 | 31 | return new Migrator($repository, $app['db'], $app['files']); |
@@ -34,14 +34,14 @@ discard block |
||
34 | 34 | |
35 | 35 | protected function registerMigrateOrganise() |
36 | 36 | { |
37 | - $this->app->singleton('command.migrate.organise', function ($app) { |
|
37 | + $this->app->singleton('command.migrate.organise', function($app) { |
|
38 | 38 | return new MigrateOrganise($app['files'], $app['migrator']); |
39 | 39 | }); |
40 | 40 | } |
41 | 41 | |
42 | 42 | protected function registerMigrateDisorganise() |
43 | 43 | { |
44 | - $this->app->singleton('command.migrate.disorganise', function ($app) { |
|
44 | + $this->app->singleton('command.migrate.disorganise', function($app) { |
|
45 | 45 | return new MigrateDisorganise($app['files'], $app['migrator']); |
46 | 46 | }); |
47 | 47 | } |
@@ -6,14 +6,14 @@ |
||
6 | 6 | |
7 | 7 | class MigrationCreator extends MC |
8 | 8 | { |
9 | - protected function getPath($name, $path) |
|
10 | - { |
|
11 | - $path = $path.'/'.date('Y').'/'.date('m'); |
|
9 | + protected function getPath($name, $path) |
|
10 | + { |
|
11 | + $path = $path.'/'.date('Y').'/'.date('m'); |
|
12 | 12 | |
13 | - if (! $this->files->exists($path)) { |
|
14 | - $this->files->makeDirectory($path, 0775, true); |
|
15 | - } |
|
13 | + if (! $this->files->exists($path)) { |
|
14 | + $this->files->makeDirectory($path, 0775, true); |
|
15 | + } |
|
16 | 16 | |
17 | - return $path.'/'.$this->getDatePrefix().'_'.$name.'.php'; |
|
18 | - } |
|
17 | + return $path.'/'.$this->getDatePrefix().'_'.$name.'.php'; |
|
18 | + } |
|
19 | 19 | } |
@@ -10,7 +10,7 @@ |
||
10 | 10 | { |
11 | 11 | $path = $path.'/'.date('Y').'/'.date('m'); |
12 | 12 | |
13 | - if (! $this->files->exists($path)) { |
|
13 | + if ( ! $this->files->exists($path)) { |
|
14 | 14 | $this->files->makeDirectory($path, 0775, true); |
15 | 15 | } |
16 | 16 |
@@ -70,7 +70,7 @@ |
||
70 | 70 | $datePath = $this->migrator->getDateFolderStructure($migration); |
71 | 71 | |
72 | 72 | // Create folder if it does not already exist |
73 | - if (! $this->files->exists($basePath.'/'.$datePath)) { |
|
73 | + if ( ! $this->files->exists($basePath.'/'.$datePath)) { |
|
74 | 74 | $this->files->makeDirectory($basePath.'/'.$datePath, 0775, true); |
75 | 75 | } |
76 | 76 |
@@ -8,76 +8,76 @@ |
||
8 | 8 | |
9 | 9 | class MigrateOrganise extends BaseCommand |
10 | 10 | { |
11 | - /** |
|
12 | - * The console command name. |
|
13 | - * |
|
14 | - * @var string |
|
15 | - */ |
|
16 | - protected $name = 'migrate:organise'; |
|
11 | + /** |
|
12 | + * The console command name. |
|
13 | + * |
|
14 | + * @var string |
|
15 | + */ |
|
16 | + protected $name = 'migrate:organise'; |
|
17 | 17 | |
18 | - /** |
|
19 | - * The console command description. |
|
20 | - * |
|
21 | - * @var string |
|
22 | - */ |
|
23 | - protected $description = 'Move migrations into a yyyy/mm folder structure'; |
|
18 | + /** |
|
19 | + * The console command description. |
|
20 | + * |
|
21 | + * @var string |
|
22 | + */ |
|
23 | + protected $description = 'Move migrations into a yyyy/mm folder structure'; |
|
24 | 24 | |
25 | - /** |
|
26 | - * The migrator instance. |
|
27 | - * |
|
28 | - * @var \Jaybizzle\MigrationsOrganiser\Migrator |
|
29 | - */ |
|
30 | - protected $migrator; |
|
25 | + /** |
|
26 | + * The migrator instance. |
|
27 | + * |
|
28 | + * @var \Jaybizzle\MigrationsOrganiser\Migrator |
|
29 | + */ |
|
30 | + protected $migrator; |
|
31 | 31 | |
32 | - /** |
|
33 | - * The filesystem instance. |
|
34 | - * |
|
35 | - * @var \Illuminate\Filesystem\Filesystem |
|
36 | - */ |
|
37 | - protected $files; |
|
32 | + /** |
|
33 | + * The filesystem instance. |
|
34 | + * |
|
35 | + * @var \Illuminate\Filesystem\Filesystem |
|
36 | + */ |
|
37 | + protected $files; |
|
38 | 38 | |
39 | - /** |
|
40 | - * Create a new migrator instance. |
|
41 | - * |
|
42 | - * @param \Illuminate\Filesystem\Filesystem $files |
|
43 | - * @param \Illuminate\Database\Migrations\Migrator $migrator |
|
44 | - */ |
|
45 | - public function __construct(Filesystem $files, Migrator $migrator) |
|
46 | - { |
|
47 | - parent::__construct(); |
|
48 | - $this->migrator = $migrator; |
|
49 | - $this->files = $files; |
|
50 | - } |
|
39 | + /** |
|
40 | + * Create a new migrator instance. |
|
41 | + * |
|
42 | + * @param \Illuminate\Filesystem\Filesystem $files |
|
43 | + * @param \Illuminate\Database\Migrations\Migrator $migrator |
|
44 | + */ |
|
45 | + public function __construct(Filesystem $files, Migrator $migrator) |
|
46 | + { |
|
47 | + parent::__construct(); |
|
48 | + $this->migrator = $migrator; |
|
49 | + $this->files = $files; |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * Create date folder structure and move migrations into. |
|
54 | - * |
|
55 | - * @return void |
|
56 | - */ |
|
57 | - public function fire() |
|
58 | - { |
|
59 | - $basePath = $this->getMigrationPath(); |
|
60 | - $migrations = $this->migrator->getMigrationFiles($basePath, false); |
|
61 | - $count = count($migrations); |
|
52 | + /** |
|
53 | + * Create date folder structure and move migrations into. |
|
54 | + * |
|
55 | + * @return void |
|
56 | + */ |
|
57 | + public function fire() |
|
58 | + { |
|
59 | + $basePath = $this->getMigrationPath(); |
|
60 | + $migrations = $this->migrator->getMigrationFiles($basePath, false); |
|
61 | + $count = count($migrations); |
|
62 | 62 | |
63 | - if ($count == 0) { |
|
64 | - $this->comment('No migrations to move'); |
|
63 | + if ($count == 0) { |
|
64 | + $this->comment('No migrations to move'); |
|
65 | 65 | |
66 | - return; |
|
67 | - } |
|
66 | + return; |
|
67 | + } |
|
68 | 68 | |
69 | - foreach ($migrations as $migration_name => $migration_path) { |
|
70 | - $datePath = $this->migrator->getDateFolderStructure($migration_name); |
|
69 | + foreach ($migrations as $migration_name => $migration_path) { |
|
70 | + $datePath = $this->migrator->getDateFolderStructure($migration_name); |
|
71 | 71 | |
72 | - // Create folder if it does not already exist |
|
73 | - if (! $this->files->exists($basePath.'/'.$datePath)) { |
|
74 | - $this->files->makeDirectory($basePath.'/'.$datePath, 0775, true); |
|
75 | - } |
|
72 | + // Create folder if it does not already exist |
|
73 | + if (! $this->files->exists($basePath.'/'.$datePath)) { |
|
74 | + $this->files->makeDirectory($basePath.'/'.$datePath, 0775, true); |
|
75 | + } |
|
76 | 76 | |
77 | - // Move the migration into its new folder |
|
78 | - $this->files->move($basePath.'/'.$migration_name.'.php', $basePath.'/'.$datePath.$migration_name.'.php'); |
|
79 | - } |
|
77 | + // Move the migration into its new folder |
|
78 | + $this->files->move($basePath.'/'.$migration_name.'.php', $basePath.'/'.$datePath.$migration_name.'.php'); |
|
79 | + } |
|
80 | 80 | |
81 | - $this->info('Migrations organised successfully ('.$count.' migrations moved)'); |
|
82 | - } |
|
81 | + $this->info('Migrations organised successfully ('.$count.' migrations moved)'); |
|
82 | + } |
|
83 | 83 | } |
@@ -18,7 +18,7 @@ |
||
18 | 18 | /** |
19 | 19 | * Get all of the migration files in a given path. |
20 | 20 | * |
21 | - * @param string $path |
|
21 | + * @param string $paths |
|
22 | 22 | * @param bool $recursive |
23 | 23 | * |
24 | 24 | * @return array |
@@ -9,71 +9,71 @@ |
||
9 | 9 | class Migrator extends M |
10 | 10 | { |
11 | 11 | |
12 | - /** |
|
13 | - * Get all of the migration files in a given path. |
|
14 | - * |
|
15 | - * @param string $path |
|
16 | - * @param bool $recursive |
|
17 | - * |
|
18 | - * @return array |
|
19 | - */ |
|
20 | - public function getMigrationFiles($paths = [], $recursive = true) |
|
21 | - { |
|
22 | - if ($recursive) { |
|
23 | - $paths = $this->getRecursiveFolders($paths); |
|
24 | - } |
|
12 | + /** |
|
13 | + * Get all of the migration files in a given path. |
|
14 | + * |
|
15 | + * @param string $path |
|
16 | + * @param bool $recursive |
|
17 | + * |
|
18 | + * @return array |
|
19 | + */ |
|
20 | + public function getMigrationFiles($paths = [], $recursive = true) |
|
21 | + { |
|
22 | + if ($recursive) { |
|
23 | + $paths = $this->getRecursiveFolders($paths); |
|
24 | + } |
|
25 | 25 | |
26 | - $files = parent::getMigrationFiles($paths); |
|
26 | + $files = parent::getMigrationFiles($paths); |
|
27 | 27 | |
28 | - return $files; |
|
29 | - } |
|
28 | + return $files; |
|
29 | + } |
|
30 | 30 | |
31 | - /** |
|
32 | - * Get all subdirectories located in an array of folders |
|
33 | - * |
|
34 | - * @param array $folders |
|
35 | - * |
|
36 | - * @return array |
|
37 | - */ |
|
38 | - public function getRecursiveFolders($folders) |
|
39 | - { |
|
40 | - if (! is_array($folders)) { |
|
41 | - $folders = [$folders]; |
|
42 | - } |
|
31 | + /** |
|
32 | + * Get all subdirectories located in an array of folders |
|
33 | + * |
|
34 | + * @param array $folders |
|
35 | + * |
|
36 | + * @return array |
|
37 | + */ |
|
38 | + public function getRecursiveFolders($folders) |
|
39 | + { |
|
40 | + if (! is_array($folders)) { |
|
41 | + $folders = [$folders]; |
|
42 | + } |
|
43 | 43 | |
44 | - $paths = []; |
|
44 | + $paths = []; |
|
45 | 45 | |
46 | - foreach ($folders as $folder) { |
|
47 | - $iter = new Iterator( |
|
48 | - new DirectoryIterator($folder, DirectoryIterator::SKIP_DOTS), |
|
49 | - Iterator::SELF_FIRST, |
|
50 | - Iterator::CATCH_GET_CHILD // Ignore "Permission denied" |
|
51 | - ); |
|
46 | + foreach ($folders as $folder) { |
|
47 | + $iter = new Iterator( |
|
48 | + new DirectoryIterator($folder, DirectoryIterator::SKIP_DOTS), |
|
49 | + Iterator::SELF_FIRST, |
|
50 | + Iterator::CATCH_GET_CHILD // Ignore "Permission denied" |
|
51 | + ); |
|
52 | 52 | |
53 | - $subPaths = array($folder); |
|
54 | - foreach ($iter as $path => $dir) { |
|
55 | - if ($dir->isDir()) { |
|
56 | - $subPaths[] = $path; |
|
57 | - } |
|
58 | - } |
|
53 | + $subPaths = array($folder); |
|
54 | + foreach ($iter as $path => $dir) { |
|
55 | + if ($dir->isDir()) { |
|
56 | + $subPaths[] = $path; |
|
57 | + } |
|
58 | + } |
|
59 | 59 | |
60 | - $paths = array_merge($paths, $subPaths); |
|
61 | - } |
|
60 | + $paths = array_merge($paths, $subPaths); |
|
61 | + } |
|
62 | 62 | |
63 | - return $paths; |
|
64 | - } |
|
63 | + return $paths; |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * Add date folders to migrations path. |
|
68 | - * |
|
69 | - * @param string $file |
|
70 | - * |
|
71 | - * @return string |
|
72 | - */ |
|
73 | - public function getDateFolderStructure($file) |
|
74 | - { |
|
75 | - $parts = explode('_', $file); |
|
66 | + /** |
|
67 | + * Add date folders to migrations path. |
|
68 | + * |
|
69 | + * @param string $file |
|
70 | + * |
|
71 | + * @return string |
|
72 | + */ |
|
73 | + public function getDateFolderStructure($file) |
|
74 | + { |
|
75 | + $parts = explode('_', $file); |
|
76 | 76 | |
77 | - return $parts[0].'/'.$parts[1].'/'; |
|
78 | - } |
|
77 | + return $parts[0].'/'.$parts[1].'/'; |
|
78 | + } |
|
79 | 79 | } |
@@ -37,7 +37,7 @@ |
||
37 | 37 | */ |
38 | 38 | public function getRecursiveFolders($folders) |
39 | 39 | { |
40 | - if (! is_array($folders)) { |
|
40 | + if ( ! is_array($folders)) { |
|
41 | 41 | $folders = [$folders]; |
42 | 42 | } |
43 | 43 |
@@ -9,118 +9,118 @@ |
||
9 | 9 | |
10 | 10 | class MigrateDisorganise extends BaseCommand |
11 | 11 | { |
12 | - /** |
|
13 | - * The console command name. |
|
14 | - * |
|
15 | - * @var string |
|
16 | - */ |
|
17 | - protected $name = 'migrate:disorganise'; |
|
18 | - |
|
19 | - /** |
|
20 | - * The console command description. |
|
21 | - * |
|
22 | - * @var string |
|
23 | - */ |
|
24 | - protected $description = 'Move migrations from a yyyy/mm folder structure back to the base migrations folder'; |
|
25 | - |
|
26 | - /** |
|
27 | - * The migrator instance. |
|
28 | - * |
|
29 | - * @var \Jaybizzle\MigrationsOrganiser\Migrator |
|
30 | - */ |
|
31 | - protected $migrator; |
|
32 | - |
|
33 | - /** |
|
34 | - * The filesystem instance. |
|
35 | - * |
|
36 | - * @var \Illuminate\Filesystem\Filesystem |
|
37 | - */ |
|
38 | - protected $files; |
|
39 | - |
|
40 | - /** |
|
41 | - * The basePath for the migrations. |
|
42 | - */ |
|
43 | - protected $basePath; |
|
44 | - |
|
45 | - /** |
|
46 | - * Create a new migrator instance. |
|
47 | - * |
|
48 | - * @param \Illuminate\Filesystem\Filesystem $files |
|
49 | - * @param \Illuminate\Database\Migrations\Migrator $migrator |
|
50 | - */ |
|
51 | - public function __construct(Filesystem $files, Migrator $migrator) |
|
52 | - { |
|
53 | - parent::__construct(); |
|
54 | - $this->migrator = $migrator; |
|
55 | - $this->files = $files; |
|
56 | - } |
|
57 | - |
|
58 | - /** |
|
59 | - * Create date folder structure and move migrations into. |
|
60 | - * |
|
61 | - * @return void |
|
62 | - */ |
|
63 | - public function fire() |
|
64 | - { |
|
65 | - $this->basePath = $this->getMigrationPath(); |
|
66 | - $migrations = $this->migrator->getMigrationFiles($this->basePath); |
|
67 | - $count = count($migrations); |
|
68 | - |
|
69 | - if ($count == 0) { |
|
70 | - $this->comment('No migrations to move'); |
|
71 | - |
|
72 | - return; |
|
73 | - } |
|
74 | - |
|
75 | - foreach ($migrations as $migration_name => $migration_path) { |
|
76 | - $datePath = $this->migrator->getDateFolderStructure($migration_name); |
|
77 | - // Move the migration into base migration folder |
|
78 | - $this->files->move($this->basePath.'/'.$datePath.$migration_name.'.php', $this->basePath.'/'.$migration_name.'.php'); |
|
79 | - } |
|
80 | - |
|
81 | - $this->info('Migrations disorganised successfully ('.$count.' migrations moved)'); |
|
82 | - $this->cleanup(); |
|
83 | - } |
|
84 | - |
|
85 | - /** |
|
86 | - * Decide whether or not to delete directories. |
|
87 | - * |
|
88 | - * @return void |
|
89 | - */ |
|
90 | - public function cleanup() |
|
91 | - { |
|
92 | - if ($this->option('force')) { |
|
93 | - $this->deleteDirs(); |
|
94 | - } elseif ($this->confirm('Delete all subdirectories in migrations folder?', true)) { |
|
95 | - $this->deleteDirs(); |
|
96 | - } |
|
97 | - } |
|
98 | - |
|
99 | - /** |
|
100 | - * Delete subdirectories in the migrations folder. |
|
101 | - * |
|
102 | - * @return void |
|
103 | - */ |
|
104 | - public function deleteDirs() |
|
105 | - { |
|
106 | - $dirs = $this->files->directories($this->basePath); |
|
107 | - |
|
108 | - foreach ($dirs as $dir) { |
|
109 | - $this->files->deleteDirectory($dir); |
|
110 | - } |
|
111 | - |
|
112 | - $this->info('Subdirectories deleted'); |
|
113 | - } |
|
114 | - |
|
115 | - /** |
|
116 | - * Get the console command options. |
|
117 | - * |
|
118 | - * @return array |
|
119 | - */ |
|
120 | - protected function getOptions() |
|
121 | - { |
|
122 | - return [ |
|
123 | - ['force', null, InputOption::VALUE_NONE, 'Force the operation to delete migration folder subdirectories without prompt.'], |
|
124 | - ]; |
|
125 | - } |
|
12 | + /** |
|
13 | + * The console command name. |
|
14 | + * |
|
15 | + * @var string |
|
16 | + */ |
|
17 | + protected $name = 'migrate:disorganise'; |
|
18 | + |
|
19 | + /** |
|
20 | + * The console command description. |
|
21 | + * |
|
22 | + * @var string |
|
23 | + */ |
|
24 | + protected $description = 'Move migrations from a yyyy/mm folder structure back to the base migrations folder'; |
|
25 | + |
|
26 | + /** |
|
27 | + * The migrator instance. |
|
28 | + * |
|
29 | + * @var \Jaybizzle\MigrationsOrganiser\Migrator |
|
30 | + */ |
|
31 | + protected $migrator; |
|
32 | + |
|
33 | + /** |
|
34 | + * The filesystem instance. |
|
35 | + * |
|
36 | + * @var \Illuminate\Filesystem\Filesystem |
|
37 | + */ |
|
38 | + protected $files; |
|
39 | + |
|
40 | + /** |
|
41 | + * The basePath for the migrations. |
|
42 | + */ |
|
43 | + protected $basePath; |
|
44 | + |
|
45 | + /** |
|
46 | + * Create a new migrator instance. |
|
47 | + * |
|
48 | + * @param \Illuminate\Filesystem\Filesystem $files |
|
49 | + * @param \Illuminate\Database\Migrations\Migrator $migrator |
|
50 | + */ |
|
51 | + public function __construct(Filesystem $files, Migrator $migrator) |
|
52 | + { |
|
53 | + parent::__construct(); |
|
54 | + $this->migrator = $migrator; |
|
55 | + $this->files = $files; |
|
56 | + } |
|
57 | + |
|
58 | + /** |
|
59 | + * Create date folder structure and move migrations into. |
|
60 | + * |
|
61 | + * @return void |
|
62 | + */ |
|
63 | + public function fire() |
|
64 | + { |
|
65 | + $this->basePath = $this->getMigrationPath(); |
|
66 | + $migrations = $this->migrator->getMigrationFiles($this->basePath); |
|
67 | + $count = count($migrations); |
|
68 | + |
|
69 | + if ($count == 0) { |
|
70 | + $this->comment('No migrations to move'); |
|
71 | + |
|
72 | + return; |
|
73 | + } |
|
74 | + |
|
75 | + foreach ($migrations as $migration_name => $migration_path) { |
|
76 | + $datePath = $this->migrator->getDateFolderStructure($migration_name); |
|
77 | + // Move the migration into base migration folder |
|
78 | + $this->files->move($this->basePath.'/'.$datePath.$migration_name.'.php', $this->basePath.'/'.$migration_name.'.php'); |
|
79 | + } |
|
80 | + |
|
81 | + $this->info('Migrations disorganised successfully ('.$count.' migrations moved)'); |
|
82 | + $this->cleanup(); |
|
83 | + } |
|
84 | + |
|
85 | + /** |
|
86 | + * Decide whether or not to delete directories. |
|
87 | + * |
|
88 | + * @return void |
|
89 | + */ |
|
90 | + public function cleanup() |
|
91 | + { |
|
92 | + if ($this->option('force')) { |
|
93 | + $this->deleteDirs(); |
|
94 | + } elseif ($this->confirm('Delete all subdirectories in migrations folder?', true)) { |
|
95 | + $this->deleteDirs(); |
|
96 | + } |
|
97 | + } |
|
98 | + |
|
99 | + /** |
|
100 | + * Delete subdirectories in the migrations folder. |
|
101 | + * |
|
102 | + * @return void |
|
103 | + */ |
|
104 | + public function deleteDirs() |
|
105 | + { |
|
106 | + $dirs = $this->files->directories($this->basePath); |
|
107 | + |
|
108 | + foreach ($dirs as $dir) { |
|
109 | + $this->files->deleteDirectory($dir); |
|
110 | + } |
|
111 | + |
|
112 | + $this->info('Subdirectories deleted'); |
|
113 | + } |
|
114 | + |
|
115 | + /** |
|
116 | + * Get the console command options. |
|
117 | + * |
|
118 | + * @return array |
|
119 | + */ |
|
120 | + protected function getOptions() |
|
121 | + { |
|
122 | + return [ |
|
123 | + ['force', null, InputOption::VALUE_NONE, 'Force the operation to delete migration folder subdirectories without prompt.'], |
|
124 | + ]; |
|
125 | + } |
|
126 | 126 | } |