From 33e6bc696aed6b26a91c64acd117de2dc3cb227e Mon Sep 17 00:00:00 2001 From: Edson Medina Date: Wed, 27 Jul 2016 13:23:00 +0100 Subject: [PATCH 1/3] Added mention to removeIndexByName() Only `removeIndex()` was mentioned in the docs. It took me quite a while to figure out that it expected the field names (and not the index names), so I'm adding the reference. --- docs/migrations.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/migrations.rst b/docs/migrations.rst index d41c175f1..367154e1e 100644 --- a/docs/migrations.rst +++ b/docs/migrations.rst @@ -1091,6 +1091,9 @@ call this method for each index. { $table = $this->table('users'); $table->removeIndex(array('email')); + + // alternatively, you can delete an index by its name, ie: + $table->removeIndexByName('idx_users_email'); } /** From 6815c1af9720fdc6035fc71dabb0d1357d260ea9 Mon Sep 17 00:00:00 2001 From: Ben Getsug Date: Wed, 14 Sep 2016 16:14:54 -0500 Subject: [PATCH 2/3] pass console input to environment to allow for subsequent passage to adapters --- src/Phinx/Migration/Manager.php | 1 + src/Phinx/Migration/Manager/Environment.php | 32 +++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/src/Phinx/Migration/Manager.php b/src/Phinx/Migration/Manager.php index 3f4264d86..a5379c574 100644 --- a/src/Phinx/Migration/Manager.php +++ b/src/Phinx/Migration/Manager.php @@ -489,6 +489,7 @@ public function getEnvironment($name) // create an environment instance and cache it $environment = new Environment($name, $this->getConfig()->getEnvironment($name)); $this->environments[$name] = $environment; + $environment->setInput($this->getInput()); $environment->setOutput($this->getOutput()); return $environment; diff --git a/src/Phinx/Migration/Manager/Environment.php b/src/Phinx/Migration/Manager/Environment.php index c70df4cc8..a3a081ec1 100644 --- a/src/Phinx/Migration/Manager/Environment.php +++ b/src/Phinx/Migration/Manager/Environment.php @@ -32,6 +32,7 @@ use Phinx\Db\Adapter\AdapterInterface; use Phinx\Migration\MigrationInterface; use Phinx\Seed\SeedInterface; +use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; class Environment @@ -46,6 +47,11 @@ class Environment */ protected $options; + /** + * @var InputInterface + */ + protected $input; + /** * @var OutputInterface */ @@ -196,6 +202,28 @@ public function getOptions() return $this->options; } + /** + * Sets the console input. + * + * @param InputInterface $input + * @return Environment + */ + public function setInput(InputInterface $input) + { + $this->input = $input; + return $this; + } + + /** + * Gets the console input. + * + * @return InputInterface + */ + public function getInput() + { + return $this->input; + } + /** * Sets the console output. * @@ -312,6 +340,10 @@ public function getAdapter() ->getWrapper($this->options['wrapper'], $adapter); } + if ($this->getInput()) { + $adapter->setInput($this->getInput()); + } + if ($this->getOutput()) { $adapter->setOutput($this->getOutput()); } From f7a607f74e8b5fbeeeb4200151e4874594748dbc Mon Sep 17 00:00:00 2001 From: Ben Getsug Date: Thu, 15 Sep 2016 15:32:37 -0500 Subject: [PATCH 3/3] adding a test --- tests/Phinx/Migration/Manager/EnvironmentTest.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/Phinx/Migration/Manager/EnvironmentTest.php b/tests/Phinx/Migration/Manager/EnvironmentTest.php index 01a3f990f..75326504a 100644 --- a/tests/Phinx/Migration/Manager/EnvironmentTest.php +++ b/tests/Phinx/Migration/Manager/EnvironmentTest.php @@ -211,4 +211,11 @@ public function testExecutingAChangeMigrationDown() $this->environment->executeMigration($migration, MigrationInterface::DOWN); } + + public function testGettingInputObject() + { + $this->environment->setInput($this->getMock('\Symfony\Component\Console\Input\InputInterface')); + $inputObject = $this->environment->getInput(); + $this->assertInstanceOf('\Symfony\Component\Console\Input\InputInterface', $inputObject); + } }