Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrations & SQL Server 2012 - cannot create migration table #3066

Closed
jreyes-csppr opened this issue Apr 11, 2014 · 5 comments
Closed

Migrations & SQL Server 2012 - cannot create migration table #3066

jreyes-csppr opened this issue Apr 11, 2014 · 5 comments
Labels
status:to be verified Needs to be reproduced and validated. type:bug Bug
Milestone

Comments

@jreyes-csppr
Copy link

When I start a migration, yii migrate/up crashes with the following error: "Exception 'yii\db\Exception' with message 'SQLSTATE[42S02]: [Microsoft][SQL Serv
er Native Client 11.0][SQL Server]Invalid object name 'migration'.
The SQL being executed was: SELECT [version], [apply_time] FROM [migration] ORDE
R BY [version] DESC'

Configuration as follows:

PHP 5.4.20 on Windows Server 2008 R2
MS SQL Server 2012
Yii2 2.0.0-alpha

config/db.php

return [
    'class' => 'yii\db\Connection',
    'dsn'=>'sqlsrv:server=mydomain.com\\sqlexpress;database=Test',
    'username' => 'sa',
    'password' => 'password',
];

create_test_table.php:

use yii\db\Schema;
class m140411_000001_create_test_table extends \yii\db\Migration
{

    // Use safeUp/safeDown to do migration with transaction
    public function up()
    {
        $this->createTable('Test', [
            'ID' => 'pk',
            'Comment' => 'nvarchar(32) NOT NULL',
        ]);

        $this->insert('Test', [
            'Comment' => 'Test Table',
        ]);
    }


    public function down()
    {
        $this->dropTable('Test');
    }
}

yii migrate/up results:

Yii Migration Tool (based on Yii v2.0.0-dev)

Exception 'yii\db\Exception' with message 'SQLSTATE[42S02]: [Microsoft][SQL Serv
er Native Client 11.0][SQL Server]Invalid object name 'migration'.
The SQL being executed was: SELECT [version], [apply_time] FROM [migration] ORDE
R BY [version] DESC'

in C:\inetpub\wwwroot\cspquotes\vendor\yiisoft\yii2\db\Command.php:431

Stack trace:
0 C:\inetpub\wwwroot\cspquotes\vendor\yiisoft\yii2\db\Command.php(318): yii\db\
Command->queryInternal('fetchAll', NULL)
1 C:\inetpub\wwwroot\cspquotes\vendor\yiisoft\yii2\console\controllers\MigrateC
ontroller.php(641): yii\db\Command->queryAll()
2 C:\inetpub\wwwroot\cspquotes\vendor\yiisoft\yii2\console\controllers\MigrateC
ontroller.php(673): yii\console\controllers\MigrateController->getMigrationHisto
ry(-1)
3 C:\inetpub\wwwroot\cspquotes\vendor\yiisoft\yii2\console\controllers\MigrateC
ontroller.php(153): yii\console\controllers\MigrateController->getNewMigrations(
)
4 [internal function]: yii\console\controllers\MigrateController->actionUp(0)
5 C:\inetpub\wwwroot\cspquotes\vendor\yiisoft\yii2\base\InlineAction.php(54): c
all_user_func_array(Array, Array)
6 C:\inetpub\wwwroot\cspquotes\vendor\yiisoft\yii2\base\Controller.php(147): yi
i\base\InlineAction->runWithParams(Array)
7 C:\inetpub\wwwroot\cspquotes\vendor\yiisoft\yii2\console\Controller.php(83):
yii\base\Controller->runAction('up', Array)
8 C:\inetpub\wwwroot\cspquotes\vendor\yiisoft\yii2\base\Module.php(423): yii\co
nsole\Controller->runAction('up', Array)
9 C:\inetpub\wwwroot\cspquotes\vendor\yiisoft\yii2\console\Application.php(160)
: yii\base\Module->runAction('migrate/up', Array)
10 C:\inetpub\wwwroot\cspquotes\vendor\yiisoft\yii2\console\Application.php(136
): yii\console\Application->runAction('migrate/up', Array)
11 C:\inetpub\wwwroot\cspquotes\vendor\yiisoft\yii2\base\Application.php(353):
yii\console\Application->handleRequest(Object(yii\console\Request))
12 C:\inetpub\wwwroot\cspquotes\yii(23): yii\base\Application->run()
13 {main}

So I created the table manually, but it would be nice if this feature worked.

Thanks!

@subdee
Copy link
Contributor

subdee commented Apr 11, 2014

lol you should've put that log in code tags, now all those issues got referenced

@jreyes-csppr
Copy link
Author

Sorry about that, this is the first time I report an issue in Github.

@samdark
Copy link
Member

samdark commented Apr 11, 2014

I've edited all the issues.

@jreyes-csppr
Copy link
Author

Thanks!

@qiangxue
Copy link
Member

I checked in a fix. Could you help test it? Thanks.

@cebe cebe added this to the 2.0 RC milestone Apr 16, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:to be verified Needs to be reproduced and validated. type:bug Bug
Projects
None yet
Development

No branches or pull requests

5 participants