/** * Execute the console command */ public function handle() { $generator = new Generator(new Describer($this->db), $this->db); foreach ($generator->tables() as $schema) { $this->callSilent('make:migration:schema', ['name' => 'create_' . $schema['table'] . '_table', '--schema' => (new SchemaArgumentBuilder())->create($schema['columns']), '--model' => false]); } $this->info('Migrations created successfully'); }
/** @test */ public function it_should_return_all_descriptions_for_each_table() { $describer = $this->prophesize('JoshTaylor\\MigrationsGenerator\\Describer'); $postsSchema = [['name' => 'id', 'type' => 'integer']]; $usersSchema = [['name' => 'id', 'type' => 'integer']]; $describer->describe('posts')->shouldBeCalled()->willReturn($postsSchema); $describer->describe('users')->shouldBeCalled()->willReturn($usersSchema); $generator = new Generator($describer->reveal(), $this->database->getDatabaseManager()); $tables = $generator->tables(); $this->assertEquals('posts', $tables->current()['table']); $this->assertEquals($postsSchema, $tables->current()['columns']); $tables->next(); $this->assertEquals('users', $tables->current()['table']); $this->assertEquals($usersSchema, $tables->current()['columns']); }