@@ 10-63 (lines=54) @@ | ||
7 | use MuhmdRaouf\LaravelParatest\Database\Schema\Builder; |
|
8 | use MuhmdRaouf\LaravelParatest\Database\Schema\GrammarFactory; |
|
9 | ||
10 | class DbCreateCommand extends Command |
|
11 | { |
|
12 | /** |
|
13 | * The name and signature of the console command. |
|
14 | * |
|
15 | * @var string |
|
16 | */ |
|
17 | protected $signature = 'db:create |
|
18 | {--dry-run} |
|
19 | {--database= : The database name to test} |
|
20 | '; |
|
21 | ||
22 | /** |
|
23 | * The console command description. |
|
24 | * |
|
25 | * @var string |
|
26 | */ |
|
27 | protected $description = 'Creates the database.'; |
|
28 | ||
29 | /** |
|
30 | * Create a new command instance. |
|
31 | * |
|
32 | * @return void |
|
33 | */ |
|
34 | public function __construct() |
|
35 | { |
|
36 | parent::__construct(); |
|
37 | } |
|
38 | ||
39 | /** |
|
40 | * Execute the console command. |
|
41 | * |
|
42 | * @return mixed |
|
43 | */ |
|
44 | public function handle(GrammarFactory $grammars) |
|
45 | { |
|
46 | if (app()->environment('testing')) { |
|
47 | $isDryRun = ConfigHelper::isDryRun($this->option('dry-run')); |
|
48 | $configs = ConfigHelper::generateConfig($this->option('database')); |
|
49 | ||
50 | $builder = new Builder( |
|
51 | ConfigHelper::makeConnector($configs, $isDryRun, $this->output), |
|
52 | $grammars |
|
53 | ); |
|
54 | ||
55 | $builder->createDatabase($configs); |
|
56 | ||
57 | $database = $configs['database']; |
|
58 | $this->info("Database $database created successfully."); |
|
59 | } else { |
|
60 | $this->warn('You are not in testing environment.'); |
|
61 | } |
|
62 | } |
|
63 | } |
|
64 |
@@ 10-63 (lines=54) @@ | ||
7 | use MuhmdRaouf\LaravelParatest\Database\Schema\Builder; |
|
8 | use MuhmdRaouf\LaravelParatest\Database\Schema\GrammarFactory; |
|
9 | ||
10 | class DbDropCommand extends Command |
|
11 | { |
|
12 | /** |
|
13 | * The name and signature of the console command. |
|
14 | * |
|
15 | * @var string |
|
16 | */ |
|
17 | protected $signature = 'db:drop |
|
18 | {--dry-run} |
|
19 | {--database= : The database name} |
|
20 | '; |
|
21 | ||
22 | /** |
|
23 | * The console command description. |
|
24 | * |
|
25 | * @var string |
|
26 | */ |
|
27 | protected $description = 'Drops the database.'; |
|
28 | ||
29 | /** |
|
30 | * Create a new command instance. |
|
31 | * |
|
32 | * @return void |
|
33 | */ |
|
34 | public function __construct() |
|
35 | { |
|
36 | parent::__construct(); |
|
37 | } |
|
38 | ||
39 | /** |
|
40 | * Execute the console command. |
|
41 | * |
|
42 | * @return mixed |
|
43 | */ |
|
44 | public function handle(GrammarFactory $grammars) |
|
45 | { |
|
46 | if (app()->environment('testing')) { |
|
47 | $isDryRun = ConfigHelper::isDryRun($this->option('dry-run')); |
|
48 | $configs = ConfigHelper::generateConfig($this->option('database')); |
|
49 | ||
50 | $builder = new Builder( |
|
51 | ConfigHelper::makeConnector($configs, $isDryRun, $this->output), |
|
52 | $grammars |
|
53 | ); |
|
54 | ||
55 | $builder->dropDatabase($configs); |
|
56 | ||
57 | $database = $configs['database']; |
|
58 | $this->info("Database $database drop successfully."); |
|
59 | } else { |
|
60 | $this->warn('You are not in testing environment.'); |
|
61 | } |
|
62 | } |
|
63 | } |
|
64 |
@@ 10-63 (lines=54) @@ | ||
7 | use MuhmdRaouf\LaravelParatest\Database\Schema\Builder; |
|
8 | use MuhmdRaouf\LaravelParatest\Database\Schema\GrammarFactory; |
|
9 | ||
10 | class DbReCreateCommand extends Command |
|
11 | { |
|
12 | /** |
|
13 | * The name and signature of the console command. |
|
14 | * |
|
15 | * @var string |
|
16 | */ |
|
17 | protected $signature = 'db:recreate |
|
18 | {--dry-run} |
|
19 | '; |
|
20 | ||
21 | /** |
|
22 | * The console command description. |
|
23 | * |
|
24 | * @var string |
|
25 | */ |
|
26 | protected $description = 'Re-creates the database.'; |
|
27 | ||
28 | /** |
|
29 | * Create a new command instance. |
|
30 | * |
|
31 | * @return void |
|
32 | */ |
|
33 | public function __construct() |
|
34 | { |
|
35 | parent::__construct(); |
|
36 | } |
|
37 | ||
38 | /** |
|
39 | * Execute the console command. |
|
40 | * |
|
41 | * @return mixed |
|
42 | */ |
|
43 | public function handle(GrammarFactory $grammars) |
|
44 | { |
|
45 | if (app()->environment('testing')) { |
|
46 | $isDryRun = ConfigHelper::isDryRun($this->option('dry-run')); |
|
47 | $configs = ConfigHelper::generateConfig($this->option('database')); |
|
48 | ||
49 | $builder = new Builder( |
|
50 | ConfigHelper::makeConnector($configs, $isDryRun, $this->output), |
|
51 | $grammars |
|
52 | ); |
|
53 | ||
54 | $builder->recreateDatabase($configs); |
|
55 | ||
56 | ||
57 | $database = $configs['database']; |
|
58 | $this->info("Database $database re-created successfully."); |
|
59 | } else { |
|
60 | $this->warn('You are not in testing environment.'); |
|
61 | } |
|
62 | } |
|
63 | } |
|
64 |