【发布时间】:2021-11-07 07:39:03
【问题描述】:
我正在尝试将我的表迁移到 laravel 数据库中,但是 artisan 没有找到 migrations 表。
我已经尝试过,从其他 laravel 安装中手动导入结构创建迁移,但错误仍然存在
我还使用 php aritsan migration:install comand 创建了迁移表
但是我注意到,当我运行 php artisan migrate 时,迁移表正在被删除,然后显示该表不存在的错误。
查看下面的完整错误
$ php artisan migrate
Migration table created successfully.
Loading stored database schema: /path/to/laravel/project/database/schema/mysql-schema.sql
Loaded stored database schema. (15.32ms)
Illuminate\Database\QueryException
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'test_db.migrations' doesn't exist (SQL: select `migration` from `migrations` order by `batch` asc, `migration` asc)
at vendor/laravel/framework/src/Illuminate/Database/Connection.php:671
667▕ // If an exception occurs when attempting to run a query, we'll format the error
668▕ // message to include the bindings with SQL, which will make this exception a
669▕ // lot more helpful to the developer instead of just the database's errors.
670▕ catch (Exception $e) {
➜ 671▕ throw new QueryException(
672▕ $query, $this->prepareBindings($bindings), $e
673▕ );
674▕ }
675▕
+31 vendor frames
32 artisan:37
Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
技术细节:
- Laravel 8.6
- MariaDB 15.1
【问题讨论】:
-
你的数据库中是否存在迁移表?
-
是的,但是当我运行 php artisan migrate 时被消除并显示错误。
-
能否也显示第一个迁移代码?
-
摆脱模式转储是第一步
-
这是我使用的第一个,因为在文档中建议,但没有奏效。需要按以下顺序完成:1. php artisan migrate:install, 2. php artisan schema:dump, 3. php artisan migrate。谢谢!