@@ -118,6 +118,7 @@ protected function execute(InputInterface $input, OutputInterface $output) {
118118 'db-host ' => $ this ->config ['db ' ]['host ' ],
119119 'db-name ' => $ this ->config ['db ' ]['name ' ],
120120 'db-user ' => $ this ->config ['db ' ]['user ' ],
121+ 'db-port ' => $ this ->config ['db ' ]['port ' ],
121122 'db-pass ' => isset ($ this ->config ['db ' ]['pass ' ]) ? $ this ->config ['db ' ]['pass ' ] : '' ,
122123 );
123124 foreach ($ this ->getDefinition ()->getOptions () as $ option ) {
@@ -146,6 +147,18 @@ protected function execute(InputInterface $input, OutputInterface $output) {
146147 }
147148 }
148149
150+ // Temporary solution to recreate databases until Drupal console provides commands for this.
151+ $ db = array (
152+ 'name ' => $ override ['db-name ' ],
153+ 'type ' => $ override ['db-type ' ],
154+ 'host ' => $ override ['db-host ' ],
155+ 'user ' => $ override ['db-user ' ],
156+ 'pass ' => $ override ['db-pass ' ],
157+ 'port ' => $ override ['db-port ' ],
158+ );
159+ $ this ->sqlDrop ($ db );
160+ $ this ->sqlCreate ($ db );
161+
149162 // If we're installing from a dump that's not already in
150163 // our local destination, copy it to our local destination.
151164 if (!empty ($ this ->filename )) {
@@ -209,7 +222,56 @@ protected function execute(InputInterface $input, OutputInterface $output) {
209222 }
210223 }
211224
225+ }
226+
227+ /**
228+ * Temporary function to drop databases.
229+ */
230+ protected function sqlDrop ($ db ) {
231+ $ command = sprintf ('mysql --user=%s --password=%s --host=%s --port=%s -e"DROP DATABASE IF EXISTS %s" ' ,
232+ $ db ['user ' ],
233+ $ db ['pass ' ],
234+ $ db ['host ' ],
235+ $ db ['port ' ],
236+ $ db ['name ' ]
237+ );
238+
239+ $ this ->io ->commentBlock ($ command );
212240
241+ // Run.
242+ $ shellProcess = $ this ->getShellProcess ();
243+
244+ if ($ shellProcess ->exec ($ command , TRUE )) {
245+ //$this->io->writeln($shellProcess->getOutput());
246+ }
247+ else {
248+ throw new CommandException ($ shellProcess ->getOutput ());
249+ }
250+ }
251+
252+ /**
253+ * Temporary function to create databases.
254+ */
255+ protected function sqlCreate ($ db ) {
256+ $ command = sprintf ('mysql --user=%s --password=%s --host=%s --port=%s -e"CREATE DATABASE IF NOT EXISTS %s" ' ,
257+ $ db ['user ' ],
258+ $ db ['pass ' ],
259+ $ db ['host ' ],
260+ $ db ['port ' ],
261+ $ db ['name ' ]
262+ );
263+
264+ $ this ->io ->commentBlock ($ command );
265+
266+ // Run.
267+ $ shellProcess = $ this ->getShellProcess ();
268+
269+ if ($ shellProcess ->exec ($ command , TRUE )) {
270+ //$this->io->writeln($shellProcess->getOutput());
271+ }
272+ else {
273+ throw new CommandException ($ shellProcess ->getOutput ());
274+ }
213275 }
214276
215277 /**
0 commit comments