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

General error: 1 no such table: migrations #247

Closed
stancl opened this issue Aug 10, 2019 · 3 comments
Closed

General error: 1 no such table: migrations #247

stancl opened this issue Aug 10, 2019 · 3 comments

Comments

@stancl
Copy link

stancl commented Aug 10, 2019

I'm running this in my setUp() method

$this->loadMigrationsFrom(__DIR__ . '/../src/assets/migrations');

and am getting this error:

Click to expand
1) Stancl\Tenancy\Tests\TenantStorageTest::correct_storage_driver_is_used
Illuminate\Database\QueryException: SQLSTATE[HY000]: General error: 1 no such table: migrations (SQL: select max("batch") as aggregate from "migrations")

/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php:624
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php:333
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:2124
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:2112
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:2598
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:2113
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:2525
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:2475
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Migrations/DatabaseMigrationRepository.php:138
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Migrations/DatabaseMigrationRepository.php:78
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:240
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:217
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/RollbackCommand.php:63
/var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:32
/var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:90
/var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:34
/var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php:576
/var/www/html/vendor/laravel/framework/src/Illuminate/Console/Command.php:183
/var/www/html/vendor/symfony/console/Command/Command.php:255
/var/www/html/vendor/laravel/framework/src/Illuminate/Console/Command.php:170
/var/www/html/vendor/symfony/console/Application.php:921
/var/www/html/vendor/symfony/console/Application.php:273
/var/www/html/vendor/symfony/console/Application.php:149
/var/www/html/vendor/laravel/framework/src/Illuminate/Console/Application.php:90
/var/www/html/vendor/laravel/framework/src/Illuminate/Console/Application.php:182
/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:275
/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Testing/PendingCommand.php:136
/var/www/html/vendor/orchestra/testbench-core/src/Database/MigrateProcessor.php:73
/var/www/html/vendor/orchestra/testbench-core/src/Database/MigrateProcessor.php:56
/var/www/html/vendor/orchestra/testbench-core/src/Concerns/WithLoadMigrationsFrom.php:32
/var/www/html/vendor/orchestra/testbench-core/src/Concerns/Testing.php:83
/var/www/html/vendor/orchestra/testbench-core/src/TestCase.php:51

Caused by
PDOException: SQLSTATE[HY000]: General error: 1 no such table: migrations

/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php:326
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php:657
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php:624
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php:333
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:2124
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:2112
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:2598
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:2113
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:2525
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:2475
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Migrations/DatabaseMigrationRepository.php:138
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Migrations/DatabaseMigrationRepository.php:78
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:240
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:217
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/RollbackCommand.php:63
/var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:32
/var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:90
/var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:34
/var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php:576
/var/www/html/vendor/laravel/framework/src/Illuminate/Console/Command.php:183
/var/www/html/vendor/symfony/console/Command/Command.php:255
/var/www/html/vendor/laravel/framework/src/Illuminate/Console/Command.php:170
/var/www/html/vendor/symfony/console/Application.php:921
/var/www/html/vendor/symfony/console/Application.php:273
/var/www/html/vendor/symfony/console/Application.php:149
/var/www/html/vendor/laravel/framework/src/Illuminate/Console/Application.php:90
/var/www/html/vendor/laravel/framework/src/Illuminate/Console/Application.php:182
/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:275
/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Testing/PendingCommand.php:136
/var/www/html/vendor/orchestra/testbench-core/src/Database/MigrateProcessor.php:73
/var/www/html/vendor/orchestra/testbench-core/src/Database/MigrateProcessor.php:56
/var/www/html/vendor/orchestra/testbench-core/src/Concerns/WithLoadMigrationsFrom.php:32
/var/www/html/vendor/orchestra/testbench-core/src/Concerns/Testing.php:83
/var/www/html/vendor/orchestra/testbench-core/src/TestCase.php:51

You can test it by cloning this pull request and running ./test (you need docker) https://github.com/stancl/tenancy/pull/82/files#diff-d4c8c6dc8769324fc27cfdac19f05cafR28

@crynobone
Copy link
Member

crynobone commented Aug 14, 2019

select max("batch") as aggregate from "migrations")

Based on the error, clearly you are missing the migrate:install command.

Why do you have this issue?

You need to check if you are doing any customisation to the migration setup for "tenancy" support. I don't see that this is a bug with Testbench but rather a usage problem.

@stancl
Copy link
Author

stancl commented Aug 14, 2019

I do have custom commands for migrating tenants, but this is not related to them. Here I'm just trying to load a non-tenant migration and run it in the central database.

@stancl
Copy link
Author

stancl commented Aug 15, 2019

@crynobone Why should $this->loadMigrationsFrom be used instead of Artisan::call('migrate')?

Edit: I already found the cause of this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants