【发布时间】:2021-10-10 06:15:49
【问题描述】:
我的迁移在本地服务器上按预期工作,但是当我尝试在实时共享托管服务器上部署我的项目并使用 php artisan migrate 后,我收到以下错误。
at vendor/laravel/framework/src/Illuminate/Database/Connection.php:692 688▕ // If an exception occurs when attempting to run a query, we'll format the error 689▕ // message to include the bindings with SQL, which will make this exception a 690▕ // lot more helpful to the developer instead of just the database's errors. 691▕ catch (Exception $e) { ➜ 692▕ throw new QueryException( 693▕ $query, $this->prepareBindings($bindings), $e 694▕ ); 695▕ } 696▕ } +7 vendor frames 8 database/migrations/2021_08_03_215015_create_user_turning_functions_table.php:14 Illuminate\Support\Facades\Facade::__callStatic("unprepared") +21 vendor frames 30 artisan:37 Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput),对象(Symfony\Component\Console\Output\ConsoleOutput))
迁移:
public function up()
{
DB::unprepared("
CREATE OR REPLACE FUNCTION `get_classes`(subjects VARCHAR(140))
RETURNS varchar(200)
BEGIN
DECLARE classes VARCHAR(48);
SET classes='something here';
RETURN classes;
END");
}
public function down()
{
DB::unprepared('DROP FUNCTION IF EXISTS get_classes');
}
我不确定我在哪里出错或在这种情况下我必须做什么?
【问题讨论】:
-
数据库设置一样吗? DB用户是否有权创建函数?
-
是的,所有其他迁移都正常工作,而视图迁移不起作用,因为它有
DB::unprepared("") -
签入
app/database.php并设置`'strict'=>false`然后重试 -
@HardikSisodia 本地服务器和托管服务器版本相同吗?
-
@ThânLƯƠNG 你问的是php版本吗?是的,它是一样的
标签: mysql laravel laravel-8 laravel-migrations