Skip to content

Commit

Permalink
Merge pull request #3 from thyseus/create-all-tables
Browse files Browse the repository at this point in the history
introduce migrate/create-all to generate migrations for all tables in…
  • Loading branch information
Bizley committed Mar 29, 2017
2 parents 256ddb1 + d3a01f2 commit 4f3d313
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/controllers/MigrationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ public function massDecision($type, $table, $actionMethod)
}

/**
* Creates new migration for a given tables.
* Creates new migration for a given table.
* @param string $table Table names separated by commas.
* @throws InvalidParamException
*/
Expand All @@ -432,6 +432,25 @@ public function actionCreate($table)
});
}

/**
* Creates new migrations for every table in your database.
* @throws InvalidParamException
*/
public function actionCreateAll()
{
$tables = $this->db->schema->getTableNames();

if (!$tables) {
return $this->stdout("Your Database does not contain any tables yet.");
}

if ($this->prompt("Are you sure you want to generate " . count($tables) . " migrations? [yes/no]") === 'yes') {
$this->actionCreate(implode(',', $tables));
} else {
$this->stdout("Operation cancelled by user\n");
}
}

/**
* Creates new update migration for a given tables.
* @param string $table Table names separated by commas.
Expand Down

0 comments on commit 4f3d313

Please sign in to comment.