M
M
Maybe_V2016-05-30 01:13:02
Yii
Maybe_V, 2016-05-30 01:13:02

How to fix a migration error?

I want to activate migration in yii2. Before that I created a migration:

class m160529_212620_user extends Migration
{
    public function up(){

        $this->createTable('user',[
            'id' => $this->primaryKey(),
            'name' => $this->string()->notNull(),
            'last_name' => $this->string(),
        ] );

    }

    public function down()
    {
        echo "m160529_212620_user cannot be reverted.\n";

        return false;
    }

To execute it in the terminal, I issue the following command, ./yii migratе but it throws the following error:
Yii Migration Tool (based on Yii v2.0.8)

PHP Fatal Error 'yii\base\ErrorException' with message 'Class 'PDO' not found'
in /home/vitaliy/hosts/myuseyii.dev/vendor/yiisoft/yii2/db/Connection.php:631
Stack trace:
#0 [internal function]: yii\base\ErrorHandler->handleFatalError()
#1 {main}

What to do ?? I checked everything in php.ini:
extension=pdo.dll
extension=php_pdo_mysql.dll

uncommented. Just in case, I reinstalled PDO again, but it still does not create a migration!
How can this be fixed?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey, 2016-05-30
@prokopov-vi

Apache and the console seem to use different php.ini files.
Look for another config.
php -i | grep Configuration

P
palichmmm, 2017-04-15
@palichmmm

to solve this problem, you need to specify where the php.ini configuration file is located
php -c [path]/php.ini yii migrate [email protected]/rbac/migrations if it does not work, then you
have not specified the path to php.ini correctly
naturally in php.ini itself there should be lines:
...
extension=pdo.so
extension=pdo_mysql.so
...
my working command in the console looked like this:
php -c ../../php.ini yii migrate -- [email protected]/rbac/migrations
I specified the path relative to the place where I was ... that is, I went up two levels.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question