yiisoft / yii2-mongodb

Yii 2 MongoDB extension
http://www.yiiframework.com
BSD 3-Clause "New" or "Revised" License
325 stars 191 forks source link

yii2 momgodb migrate bug #214

Closed fancyecommerce closed 7 years ago

fancyecommerce commented 7 years ago
[root@localhost drop]# ./yii mongodb-migrate  --interactive=0 --migrationPath=@fecshop/migrations/mongodb
Yii Migration Tool (based on Yii v2.0.12)

Total 1 new migration to be applied:
    m170228_072455_fecshop_tables

*** applying m170228_072455_fecshop_tables
PHP Compile Error 'yii\base\ErrorException' with message 'require_once(): Failed opening required 'Array/m170228_072455_fecshop_tables.php' (include_path='.:')'

in /www/web/drop/vendor/yiisoft/yii2-mongodb/console/controllers/MigrateController.php:136

Stack trace:
#0 [internal function]: yii\base\ErrorHandler->handleFatalError()
#1 {main}
[root@localhost drop]# ./yii mongodb-migrate  --interactive=0 --migrationPath=@fecshop/migrations/mongodb

code: /www/web/drop/vendor/yiisoft/yii2-mongodb/console/controllers/MigrateController.php:136

/**
     * Creates a new migration instance.
     * @param string $class the migration class name
     * @return \yii\mongodb\Migration the migration instance
     */
    protected function createMigration($class)
    {
        $class = trim($class, '\\');
        if (strpos($class, '\\') === false) {
            $file = $this->migrationPath . DIRECTORY_SEPARATOR . $class . '.php';
            require_once($file);
        }

        return new $class(['db' => $this->db]);
    }

vard_dump( $this->migrationPath);

array(1) {
  [0]=>
  string(62) "/www/web/drop/vendor/fancyecommerce/fecshop/migrations/mongodb"
}

change code with:

 protected function createMigration($class)
    {
        $class = trim($class, '\\');
        if (strpos($class, '\\') === false) {

            $file = $this->migrationPath[0] . DIRECTORY_SEPARATOR . $class . '.php';
            require_once($file);
        }

        return new $class(['db' => $this->db]);
    }

success!!!!

[root@localhost drop]# ./yii mongodb-migrate  --interactive=0 --migrationPath=@fecshop/migrations/mongodb
Yii Migration Tool (based on Yii v2.0.12)

Total 1 new migration to be applied:
    m170228_072455_fecshop_tables

*** applying m170228_072455_fecshop_tables
*** applied m170228_072455_fecshop_tables (time: 0.172s)

1 migration was applied.

Migrated up successfully.
[root@localhost drop]# 
fancyecommerce commented 7 years ago

my composer.json

"require": {  
    "php": ">=5.4.0",
    "yiisoft/yii2": ">=2.0.11" ,
    "fancyecommerce/fec_admin":">=1.3.6.7",
    "yiisoft/yii2-mongodb": "~2.1.0" ,
    "skeeks/yii2-assets-auto-compress": "*",
    "hightman/xunsearch": "*@beta"
  },  
fancyecommerce commented 7 years ago

my php version is php5.4 use php-mongodb extensions

but in php7 with php-mongodb extensions,The above error does not occur

fancyecommerce commented 7 years ago

My e-commerce project :https://github.com/fecshop , thank you.

klimov-paul commented 7 years ago

Duplicates #213

fancyecommerce commented 7 years ago

Can you post a new version of the modified code? Load the new library version, I do not need to install the time to manually modify the