diff --git a/.styleci.yml b/.styleci.yml index 5d07e31ea..8806a5402 100644 --- a/.styleci.yml +++ b/.styleci.yml @@ -12,7 +12,3 @@ disabled: - phpdoc_order - phpdoc_separation - phpdoc_types - -finder: - exclude: - - "stubs" diff --git a/src/Console/ConsoleServiceProvider.php b/src/Console/ConsoleServiceProvider.php index 1386460ef..3b00caae9 100644 --- a/src/Console/ConsoleServiceProvider.php +++ b/src/Console/ConsoleServiceProvider.php @@ -9,7 +9,6 @@ namespace Flarum\Console; -use Flarum\Database\Console\GenerateMigrationCommand; use Flarum\Database\Console\MigrateCommand; use Flarum\Database\Console\ResetCommand; use Flarum\Foundation\AbstractServiceProvider; @@ -26,7 +25,6 @@ class ConsoleServiceProvider extends AbstractServiceProvider $this->container->singleton('flarum.console.commands', function () { return [ CacheClearCommand::class, - GenerateMigrationCommand::class, InfoCommand::class, MigrateCommand::class, ResetCommand::class, diff --git a/src/Database/Console/GenerateMigrationCommand.php b/src/Database/Console/GenerateMigrationCommand.php deleted file mode 100644 index 938446a41..000000000 --- a/src/Database/Console/GenerateMigrationCommand.php +++ /dev/null @@ -1,104 +0,0 @@ -creator = $creator; - } - - /** - * {@inheritdoc} - */ - protected function configure() - { - $this - ->setName('generate:migration') - ->setDescription('Generate a migration') - ->addArgument( - 'name', - InputArgument::REQUIRED, - 'The name of the migration.' - ) - ->addOption( - 'extension', - null, - InputOption::VALUE_REQUIRED, - 'The extension to generate the migration for.' - ) - ->addOption( - 'create', - null, - InputOption::VALUE_REQUIRED, - 'The table to be created.' - ) - ->addOption( - 'table', - null, - InputOption::VALUE_REQUIRED, - 'The table to migrate.' - ); - } - - /** - * {@inheritdoc} - */ - protected function fire() - { - $name = $this->input->getArgument('name'); - - $extension = $this->input->getOption('extension'); - - $table = $this->input->getOption('table'); - - $create = $this->input->getOption('create'); - - if (! $table && is_string($create)) { - $table = $create; - } - - $this->writeMigration($name, $extension, $table, $create); - } - - /** - * Write the migration file to disk. - * - * @param string $name - * @param string $extension - * @param string $table - * @param bool $create - * @return string - */ - protected function writeMigration($name, $extension, $table, $create) - { - $path = $this->creator->create($name, $extension, $table, $create); - - $file = pathinfo($path, PATHINFO_FILENAME); - - $this->info("Created migration: $file"); - } -} diff --git a/src/Database/MigrationCreator.php b/src/Database/MigrationCreator.php deleted file mode 100644 index 13225dd13..000000000 --- a/src/Database/MigrationCreator.php +++ /dev/null @@ -1,146 +0,0 @@ -files = $files; - $this->paths = $paths; - } - - /** - * Create a new migration for the given extension. - * - * @param string $name - * @param string $extension - * @param string $table - * @param bool $create - * @return string - */ - public function create($name, $extension = null, $table = null, $create = false) - { - $migrationPath = $this->getMigrationPath($extension); - - $path = $this->getPath($name, $migrationPath); - - $stub = $this->getStub($table, $create); - - $this->files->put($path, $this->populateStub($stub, $table)); - - return $path; - } - - /** - * Get the migration stub file. - * - * @param string $table - * @param bool $create - * @return string - */ - protected function getStub($table, $create) - { - if (is_null($table)) { - return $this->files->get($this->getStubPath().'/blank.stub'); - } - - // We also have stubs for creating new tables and modifying existing tables - // to save the developer some typing when they are creating a new tables - // or modifying existing tables. We'll grab the appropriate stub here. - $stub = $create ? 'create.stub' : 'update.stub'; - - return $this->files->get($this->getStubPath()."/{$stub}"); - } - - /** - * Populate the place-holders in the migration stub. - * - * @param string $stub - * @param string $table - * @return string - */ - protected function populateStub($stub, $table) - { - $replacements = [ - '{{table}}' => $table - ]; - - return str_replace(array_keys($replacements), array_values($replacements), $stub); - } - - /** - * Get the full path name to the migration directory. - * - * @param string $extension - * @return string - */ - protected function getMigrationPath($extension) - { - if ($extension) { - return $this->paths->vendor.'/'.$extension.'/migrations'; - } else { - return __DIR__.'/../../migrations'; - } - } - - /** - * Get the full path name to the migration. - * - * @param string $name - * @param string $path - * @return string - */ - protected function getPath($name, $path) - { - return $path.'/'.$this->getDatePrefix().'_'.$name.'.php'; - } - - /** - * Get the date prefix for the migration. - * - * @return string - */ - protected function getDatePrefix() - { - return date('Y_m_d_His'); - } - - /** - * Get the path to the stubs. - * - * @return string - */ - protected function getStubPath() - { - return __DIR__.'/../../stubs/migrations'; - } -} diff --git a/stubs/migrations/blank.stub b/stubs/migrations/blank.stub deleted file mode 100644 index c7fd6efc0..000000000 --- a/stubs/migrations/blank.stub +++ /dev/null @@ -1,13 +0,0 @@ - function (Builder $schema) { - // - }, - - 'down' => function (Builder $schema) { - // - } -]; diff --git a/stubs/migrations/create.stub b/stubs/migrations/create.stub deleted file mode 100644 index e6a4750cc..000000000 --- a/stubs/migrations/create.stub +++ /dev/null @@ -1,16 +0,0 @@ - function (Builder $schema) { - $schema->create('{{table}}', function (Blueprint $table) { - $table->increments('id'); - }); - }, - - 'down' => function (Builder $schema) { - $schema->drop('{{table}}'); - } -]; diff --git a/stubs/migrations/update.stub b/stubs/migrations/update.stub deleted file mode 100644 index 017d1ada7..000000000 --- a/stubs/migrations/update.stub +++ /dev/null @@ -1,18 +0,0 @@ - function (Builder $schema) { - $schema->table('{{table}}', function (Blueprint $table) { - // - }); - }, - - 'down' => function (Builder $schema) { - $schema->table('{{table}}', function (Blueprint $table) { - // - }); - } -];