Skip to content
This repository has been archived by the owner on Oct 19, 2023. It is now read-only.

Commit

Permalink
Built in checks to see if table and column exist, closes #11
Browse files Browse the repository at this point in the history
  • Loading branch information
peterjaap committed Jul 11, 2018
1 parent 1d00ec9 commit 4ba7438
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Elgentos/Masquerade/Console/RunCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,18 @@ protected function execute(InputInterface $input, OutputInterface $output)
*/
private function fakeData($table)
{
if (!$this->db->getSchemaBuilder()->hasTable($table['name'])) {
$this->output->writeln('Table ' . $table['name'] . ' does not exist.');
return;
}

foreach ($table['columns'] as $columnName => $columnData) {
if (!$this->db->getSchemaBuilder()->hasColumn($table['name'], $columnName)) {
unset($table['columns'][$columnName]);
$this->output->writeln('Column ' . $columnName . ' in table ' . $table['name'] . ' does not exist; skip it.');
}
}

$this->output->writeln('');
$this->output->writeln('Updating ' . $table['name']);

Expand Down

0 comments on commit 4ba7438

Please sign in to comment.