public function create()
{
$database = $this->option('database');
$this->runner->connection($database);
$this->createTable();
$engine = $this->option('engine');
$this->info('Creating Database Tables...');
$tables = $this->argument('tables') ? $this->argument('tables') : [];
if ($this->option('tag')) {
$tags = explode(',', $this->option('tag'));
foreach ($tags as $tag) {
$tag_tables = $this->tags->get($tag);
$tables = array_merge($tables, $tag_tables);
}
}
$tables = array_unique($tables);
$tabs = $tables;
foreach ($tabs as $table) {
if ($this->loader->exists($table)) {
if (!$this->option('nodeps')) {
$deps = $this->dependency->resolveDependencyList($table);
foreach ($deps as $dep) {
$tables[] = $dep['to_table'];
}
}
} else {
throw new \Exception("{$table} definition doesn't exist.");
}
}
$command = $this;
$this->runner->up(array_unique($tables), $engine, function ($msg) use($command) {
$command->error($msg);
});
$this->info('Creating Foreign Key Constraints...');
$this->runner->foreigns();
$this->info('DONE.');
return true;
}