tonydspaniard / yiinitializr-advanced

Yii Framework project structure boilerplate for advanced application requirements
67 stars 30 forks source link

consolemigration #15

Closed DrMabuse23 closed 10 years ago

DrMabuse23 commented 10 years ago

Hi Antonio, i use the migration but i got this error.

Apply the above migration? (yes|no) [no]:yes
*** applying m130701_104660_create_table_user
PHP Error[2]: include(m130701_104660_create_table_user.php): failed to open stream: No such file or directory
    in file /Users/brewing/webserver/yii-prototype/common/lib/vendor/yiisoft/yii/framework/YiiBase.php at line 427
#0 /Users/brewing/webserver/yii-prototype/common/lib/vendor/yiisoft/yii/framework/YiiBase.php(427): autoload()
#1 unknown(0): autoload()
#2 /Users/brewing/webserver/yii-prototype/common/lib/vendor/yiisoft/yii/framework/cli/commands/MigrateCommand.php(429): spl_autoload_call()
#3 /Users/brewing/webserver/yii-prototype/common/lib/vendor/yiisoft/yii/framework/cli/commands/MigrateCommand.php(384): MigrateCommand->instantiateMigration()
#4 /Users/brewing/webserver/yii-prototype/common/lib/vendor/yiisoft/yii/framework/cli/commands/MigrateCommand.php(109): MigrateCommand->migrateUp()
#5 unknown(0): MigrateCommand->actionUp()
#6 /Users/brewing/webserver/yii-prototype/common/lib/vendor/yiisoft/yii/framework/console/CConsoleCommand.php(172): ReflectionMethod->invokeArgs()
#7 /Users/brewing/webserver/yii-prototype/common/lib/vendor/yiisoft/yii/framework/console/CConsoleCommandRunner.php(71): MigrateCommand->run()
#8 /Users/brewing/webserver/yii-prototype/common/lib/Yiinitializr/Composer/Callback.php(153): CConsoleCommandRunner->run()
#9 /Users/brewing/webserver/yii-prototype/common/lib/Yiinitializr/Composer/Callback.php(111): runHook()
#10 phar:///Users/brewing/webserver/yii-prototype/composer.phar/src/Composer/Script/EventDispatcher.php(140): postUpdate()
#11 phar:///Users/brewing/webserver/yii-prototype/composer.phar/src/Composer/Script/EventDispatcher.php(117): Composer\Script\EventDispatcher->executeEventPhpScript()
#12 phar:///Users/brewing/webserver/yii-prototype/composer.phar/src/Composer/Script/EventDispatcher.php(88): Composer\Script\EventDispatcher->doDispatch()
#13 phar:///Users/brewing/webserver/yii-prototype/composer.phar/src/Composer/Installer.php(287): Composer\Script\EventDispatcher->dispatchCommandEvent()
#14 phar:///Users/brewing/webserver/yii-prototype/composer.phar/src/Composer/Command/UpdateCommand.php(103): Composer\Installer->run()
#15 phar:///Users/brewing/webserver/yii-prototype/composer.phar/vendor/symfony/console/Symfony/Component/Console/Command/Command.php(244): Composer\Command\UpdateCommand->execute()
#16 phar:///Users/brewing/webserver/yii-prototype/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php(897): Composer\Command\UpdateCommand->run()
#17 phar:///Users/brewing/webserver/yii-prototype/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php(191): Composer\Console\Application->doRunCommand()
#18 phar:///Users/brewing/webserver/yii-prototype/composer.phar/src/Composer/Console/Application.php(117): Composer\Console\Application->doRun()
#19 phar:///Users/brewing/webserver/yii-prototype/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php(121): Composer\Console\Application->doRun()
#20 phar:///Users/brewing/webserver/yii-prototype/composer.phar/src/Composer/Console/Application.php(83): Composer\Console\Application->run()
#21 phar:///Users/brewing/webserver/yii-prototype/composer.phar/bin/composer(43): Composer\Console\Application->run()
#22 /Users/brewing/webserver/yii-prototype/composer.phar(15): require()

any idea to solve this problem with the autoload() 
DrMabuse23 commented 10 years ago

the migration file

<?php

class m130701_104658_create_table_user extends CDbMigration
{
    public function safeUp()
    {
        $this->createTable('{{user}}', array(
            'id'=>'pk',
            'username'=>'string NOT NULL',
            'password'=>'string NOT NULL',
            'email'=>'string NOT NULL',
            'firstname'=>'string',
            'lastname'=>'string',
            'activation_key'=>'string',
            'created_on'=>'timestamp',
            'updated_on'=>'timestamp',
            'last_visit_on'=>'timestamp',
            'password_set_on'=>'timestamp',
            'email_verified'=>'boolean NOT NULL DEFAULT FALSE',
            'is_active'=>'boolean NOT NULL DEFAULT FALSE',
            'is_disabled'=>'boolean NOT NULL DEFAULT FALSE',
        ));
        $this->createIndex('{{user}}_username_idx', '{{user}}', 'username', true);
        $this->createIndex('{{user}}_email_idx', '{{user}}', 'email', true);
        $this->createIndex('{{user}}_email_verified_idx', '{{user}}', 'email_verified');
        $this->createIndex('{{user}}_is_active_idx', '{{user}}', 'is_active');
        $this->createIndex('{{user}}_is_disabled_idx', '{{user}}', 'is_disabled');
    }

    public function safeDown()
    {
        $this->dropTable('{{user}}');
    }
}
DrMabuse23 commented 10 years ago

console/config/env

<?php
/**
 *
 * @author Antonio Ramirez <amigo.cobos@gmail.com>
 * @link http://www.ramirezcobos.com/
 * @link http://www.2amigos.us/
 * @copyright 2013 2amigOS! Consultation Group LLC
 * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
 */
return array(
    'modules' => array(
        'gii' => array(
            'class' => 'system.gii.GiiModule',
            'password' => 'yii',
            'ipFilters' => array('127.0.0.1','::1'),
        ),
    ),
    'components' => array(
        // configure to suit your needs
        'db' => array(
            'connectionString' =>'mysql:host=localhost;dbname=yii-prototype',
            'username' => 'root',
            'password' => 'root',
            'enableProfiling' => true,
            'enableParamLogging' => true,
            'charset' => 'utf8',
        ),
    ),
    'params' => array(
        'yii.handleErrors'   => true,
        'yii.debug' => true,
        'yii.traceLevel' => 3,
    )
);
tonydspaniard commented 10 years ago

wow @brewing very hard to read this issue code :)

tonydspaniard commented 10 years ago

@brewing

Your migration class name m130701_104660_create_table_user doesn't match the name of the file m130701_104658_create_table_user

DrMabuse23 commented 10 years ago

very fast ....