Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Prompt to backup first and log commands

  • Loading branch information...
commit 200c738c3bf0ca008f078202c88a929d7cd9ba49 1 parent 4e557b4
@jwheare authored
Showing with 9 additions and 2 deletions.
  1. +9 −2 core/dbmigrationscript.class.php
View
11 core/dbmigrationscript.class.php
@@ -14,10 +14,17 @@ public function run () {
if (count($migrations)) {
$this->out("Loading migrations:\n");
natcasesort($migrations);
+ // Prompt
+ $this->out("\n" . implode("\n$migrationDir/", $migrations) . "\n\nAre you happy to run these SQL migrations on the `" . MYSQL_DB . "` database now?\nProbably wise to backup your database first.\n[Y/n]: ");
+ $input = strtolower(trim(fgets(STDIN)));
+ if ($input && ($input[0] == 'n' || $input == 0)) {
+ $this->end();
+ }
foreach ($migrations as $migration) {
try {
- $this->out("$migration\n");
- service('db')->execute(file_get_contents("$migrationDir/$migration"));
+ $commands = file_get_contents("$migrationDir/$migration");
+ $this->out("\n$migration\n$commands\n");
+ service('db')->execute($commands);
} catch (PDOException $e) {
if ($e->errorInfo[1] != 1060) { // Duplicate column
throw $e;
Please sign in to comment.
Something went wrong with that request. Please try again.