Skip to content

Commit

Permalink
Merge pull request #36 from bizley/list-parameters-2.x
Browse files Browse the repository at this point in the history
List parameters 2.x
  • Loading branch information
Bizley authored Oct 11, 2018
2 parents 0b79e48 + ebf0fa3 commit 62fadeb
Show file tree
Hide file tree
Showing 91 changed files with 161 additions and 151 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,23 @@ Add the package to your composer.json:

{
"require": {
"bizley/migration": "~3.0.0"
"bizley/migration": "^3.0"
}
}

and run `composer update` or alternatively run `composer require bizley/migration:~3.0.0`
and run `composer update` or alternatively run `composer require bizley/migration:^3.0`

## Installation for PHP < 7.1

Add the package to your composer.json:

{
"require": {
"bizley/migration": "~2.3.0"
"bizley/migration": "^2.3"
}
}

and run `composer update` or alternatively run `composer require bizley/migration:~2.3.0`
and run `composer update` or alternatively run `composer require bizley/migration:^2.3`

## Configuration

Expand Down
71 changes: 39 additions & 32 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,34 +1,41 @@
{
"name": "bizley/migration",
"description": "Migration generator for Yii 2.",
"type": "yii2-extension",
"keywords": ["yii2", "migration", "migrate", "generator", "console"],
"license": "Apache-2.0",
"authors": [
{
"name": "Pawel Bizley Brzozowski",
"email": "pawel@positive.codes"
}
],
"support": {
"source": "https://github.com/bizley/yii2-migration"
},
"require": {
"ext-mbstring": "*",
"php": ">=5.4.0 <7.1.0",
"yiisoft/yii2": ">=2.0.11 <2.1.0"
},
"require-dev": {
"phpunit/phpunit": "~4.8.36",
"roave/security-advisories": "dev-master"
},
"autoload": {
"psr-4": {"bizley\\migration\\": ""}
},
"repositories": [
{
"type": "composer",
"url": "https://asset-packagist.org"
}
]
"name": "bizley/migration",
"description": "Migration generator for Yii 2.",
"type": "yii2-extension",
"keywords": ["yii2", "migration", "migrate", "generator", "console"],
"license": "Apache-2.0",
"authors": [
{
"name": "Pawel Bizley Brzozowski",
"email": "pawel@positive.codes"
}
],
"support": {
"source": "https://github.com/bizley/yii2-migration"
},
"require": {
"ext-mbstring": "*",
"php": ">=5.4.0 <7.1.0",
"yiisoft/yii2": ">=2.0.11 <2.1.0"
},
"require-dev": {
"phpunit/phpunit": "~4.8.36",
"roave/security-advisories": "dev-master"
},
"autoload": {
"psr-4": {
"bizley\\migration\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"bizley\\tests\\": "tests/"
}
},
"repositories": [
{
"type": "composer",
"url": "https://asset-packagist.org"
}
]
}
8 changes: 4 additions & 4 deletions Generator.php → src/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public function getTableSchema()
protected function getTablePrimaryKey()
{
$data = [];
if (method_exists($this->db->schema, 'getTablePrimaryKey')) {
if (method_exists($this->db->schema, 'getTablePrimaryKey')) { // requires Yii 2.0.13
/* @var $constraint \yii\db\Constraint */
$constraint = $this->db->schema->getTablePrimaryKey($this->tableName, true);
if ($constraint) {
Expand All @@ -129,7 +129,7 @@ protected function getTablePrimaryKey()

/**
* Returns columns structure.
* @param $indexes TableIndex[]
* @param TableIndex[] $indexes
* @return TableColumn[]
* @throws InvalidConfigException
*/
Expand Down Expand Up @@ -173,7 +173,7 @@ protected function getTableColumns($indexes = [])
protected function getTableForeignKeys()
{
$data = [];
if (method_exists($this->db->schema, 'getTableForeignKeys')) {
if (method_exists($this->db->schema, 'getTableForeignKeys')) { // requires Yii 2.0.13
$fks = $this->db->schema->getTableForeignKeys($this->tableName, true);
/* @var $fk \yii\db\ForeignKeyConstraint */
foreach ($fks as $fk) {
Expand Down Expand Up @@ -212,7 +212,7 @@ protected function getTableForeignKeys()
protected function getTableIndexes()
{
$data = [];
if (method_exists($this->db->schema, 'getTableIndexes')) {
if (method_exists($this->db->schema, 'getTableIndexes')) { // requires Yii 2.0.13
$idxs = $this->db->schema->getTableIndexes($this->tableName, true);
/* @var $idx \yii\db\IndexConstraint */
foreach ($idxs as $idx) {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

use bizley\migration\Generator;
use bizley\migration\Updater;
use Closure;
use Exception;
use Yii;
use yii\base\Action;
use yii\base\InvalidConfigException;
Expand All @@ -22,13 +20,13 @@
* Generates migration file based on the existing database table and previous migrations.
*
* @author Paweł Bizley Brzozowski
* @version 2.3.2
* @version 2.3.3
* @license Apache 2.0
* https://github.com/bizley/yii2-migration
*/
class MigrationController extends Controller
{
protected $version = '2.3.2';
protected $version = '2.3.3';

/**
* @var string Default command action.
Expand All @@ -48,7 +46,6 @@ class MigrationController extends Controller
* Migration namespace should be resolvable as a path alias if prefixed with @, e.g. if you specify the namespace
* 'app\migrations', the code Yii::getAlias('@app/migrations') should be able to return the file path to
* the directory this namespace refers to.
* Namespaced migrations have been added in Yii 2.0.10.
* Alias -n
* @since 1.1
*/
Expand Down Expand Up @@ -76,9 +73,8 @@ class MigrationController extends Controller
public $useTablePrefix = 1;

/**
* @var Connection|array|string DB connection object or the application component ID of the DB connection to use
* when creating migrations.
* Starting from Yii 2.0.3, this can also be a configuration array for creating the object.
* @var Connection|array|string DB connection object, configuration array, or the application component ID of
* the DB connection to use when generating migrations.
*/
public $db = 'db';

Expand All @@ -91,7 +87,7 @@ class MigrationController extends Controller
public $migrationTable = '{{%migration}}';

/**
* @var bool|string|int Whether to only display changes instead of create update migration.
* @var bool|string|int Whether to only display changes instead of creating update migration.
* Alias -s
* @since 2.0
*/
Expand All @@ -100,8 +96,8 @@ class MigrationController extends Controller
/**
* @var bool|string|int Whether to use general column schema instead of database specific.
* Alias -g
* Since 2.3.0 this property is 1 by default.
* @since 2.0
* Since 2.3.0 this property is 1 by default.
*/
public $generalSchema = 1;

Expand All @@ -124,8 +120,8 @@ class MigrationController extends Controller
*/
public function options($actionID)
{
$options = parent::options($actionID);
$createOptions = ['migrationPath', 'migrationNamespace', 'db', 'generalSchema', 'templateFile', 'useTablePrefix', 'fixHistory', 'migrationTable'];
$options = array_merge(parent::options($actionID), ['db']);
$createOptions = ['migrationPath', 'migrationNamespace', 'generalSchema', 'templateFile', 'useTablePrefix', 'fixHistory', 'migrationTable'];
$updateOptions = ['showOnly', 'templateFileUpdate', 'skipMigrations'];
switch ($actionID) {
case 'create':
Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions table/TableColumn.php → src/table/TableColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function getLength()

/**
* Sets length of the column.
* @param $value
* @param int|string $value
*/
public function setLength($value)
{
Expand Down Expand Up @@ -225,7 +225,7 @@ public function prepareSchemaAppend($table, $primaryKey, $autoIncrement)

/**
* Escapes single quotes.
* @param $value
* @param string $value
* @return mixed
*/
public function escapeQuotes($value)
Expand All @@ -235,7 +235,7 @@ public function escapeQuotes($value)

/**
* Removes information of primary key in append property.
* @param $schema
* @param string $schema
* @return null|string
*/
public function removePKAppend($schema)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function getLength()

/**
* Sets length of the column.
* @param $value
* @param int|string $value
*/
public function setLength($value)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function getLength()

/**
* Sets length of the column.
* @param $value
* @param array|int|string $value
*/
public function setLength($value)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function getLength()

/**
* Sets length of the column.
* @param $value
* @param int|string $value
*/
public function setLength($value)
{
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function getLength()

/**
* Sets length of the column.
* @param $value
* @param int|string $value
*/
public function setLength($value)
{
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function getLength()

/**
* Sets length of the column.
* @param $value
* @param array|int|string $value
*/
public function setLength($value)
{
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function getLength()

/**
* Sets length of the column.
* @param $value
* @param int|string $value
*/
public function setLength($value)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function getLength()

/**
* Sets length of the column.
* @param $value
* @param int|string $value
*/
public function setLength($value)
{
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function render($table, $indent = 8)

/**
* Adds column to the key.
* @param $name
* @param string $name
*/
public function addColumn($name)
{
Expand Down
2 changes: 1 addition & 1 deletion table/TableStructure.php → src/table/TableStructure.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function getSchema()

/**
* Sets schema type based on the currently used schema class.
* @param string $schemaClass
* @param string|null $schemaClass
*/
public function setSchema($schemaClass)
{
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
/config.local.php
config.local.php
8 changes: 4 additions & 4 deletions tests/DbTestCase.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace bizley\migration\tests;
namespace bizley\tests;

use Yii;
use yii\console\Controller;
Expand Down Expand Up @@ -62,8 +62,8 @@ protected static function mockApplication($config = [], $appClass = '\yii\consol
'migrationNamespace' => null,
],
'migrate' => [
'class' => 'bizley\migration\tests\EchoMigrateController',
'migrationNamespaces' => ['bizley\migration\tests\migrations'],
'class' => 'bizley\tests\EchoMigrateController',
'migrationNamespaces' => ['bizley\tests\migrations'],
'migrationPath' => null,
'interactive' => false
],
Expand All @@ -75,7 +75,7 @@ protected static function mockApplication($config = [], $appClass = '\yii\consol
}

/**
* @param $route
* @param string $route
* @param array $params
* @throws \yii\base\InvalidRouteException
* @throws \yii\console\Exception
Expand Down
2 changes: 1 addition & 1 deletion tests/EchoMigrateController.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace bizley\migration\tests;
namespace bizley\tests;

use yii\console\controllers\MigrateController;

Expand Down
4 changes: 2 additions & 2 deletions tests/MockMigrationController.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php

namespace bizley\migration\tests;
namespace bizley\tests;

use bizley\migration\controllers\MigrationController;

/**
* Class MockMigrationController
* @package bizley\migration\tests
* @package bizley\tests
*/
class MockMigrationController extends MigrationController
{
Expand Down
3 changes: 2 additions & 1 deletion tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../vendor/yiisoft/yii2/Yii.php';

Yii::setAlias('@bizley/migration', __DIR__ . '/../');
Yii::setAlias('@bizley/migration', __DIR__ . '/../src/');
Yii::setAlias('@bizley/tests', __DIR__);
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace bizley\migration\tests\migrations;
namespace bizley\tests\migrations;

use yii\db\Migration;

Expand Down
2 changes: 1 addition & 1 deletion tests/migrations/m180317_100000_create_table_test_json.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace bizley\migration\tests\migrations;
namespace bizley\tests\migrations;

use yii\db\Migration;

Expand Down
Loading

0 comments on commit 62fadeb

Please sign in to comment.