小编Hem*_*mar的帖子

Laravel 迁移创建自定义外键

我正在 laravel 中创建迁移,有时我需要在数据库中创建自定义外键名称。我已经搜索过这个解决方案,但没有与我的问题类似的内容。

\n

我想添加列names包含birth_city_id、birth_state_id 和birth_country_id 的表添加列。除此之外,我还想添加 Death_city_id、death_state_id、death_county_id。

\n

错误:

\n
Migrating: 2021_11_21_130238_create_names_table\n\n   Illuminate\\Database\\QueryException \n\n  SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near \')\' at line 1 (SQL: alter table `names` add constraint `birth_city_id` foreign key (`city_id`) references `cities` ())\n\n  at vendor/laravel/framework/src/Illuminate/Database/Connection.php:703\n    699\xe2\x96\x95         // If an exception occurs when attempting to run a query, …
Run Code Online (Sandbox Code Playgroud)

php migration laravel laravel-migrations laravel-8

1
推荐指数
1
解决办法
1949
查看次数

cpanel 共享主机上的 Laravel 计划作业无法正常工作

我已经在我的应用程序中实现了 Laravel 队列,但在共享托管中使用 cPanel 调度 cron 作业时遇到了问题。

共享主机上的目录结构是:

  • 项目
  • 公共_html

project/app/console/kernel.php 我在那里更新了计划命令。

/**
 * Define the application's command schedule.
 *
 * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
 * @return void
 */
protected function schedule(Schedule $schedule)
{
     $schedule->command('queue:work --stop-when-empty')
              ->everyMinute();
}
Run Code Online (Sandbox Code Playgroud)

cpanel cron 中的命令

/usr/local/bin/php /home/shope/public_html/ php artisan schedule:run >> /dev/null 2>&1
Run Code Online (Sandbox Code Playgroud)

注意:当在终端中运行 Schedule 命令时,这在我的本地计算机上运行良好。

php artisan schedule:run
Run Code Online (Sandbox Code Playgroud)

输出:

Running scheduled command: '/usr/bin/php7.4' 'artisan' queue:work --stop-when-empty > '/dev/null' 2>&1
Run Code Online (Sandbox Code Playgroud)

cron cpanel laravel

0
推荐指数
1
解决办法
865
查看次数

标签 统计

laravel ×2

cpanel ×1

cron ×1

laravel-8 ×1

laravel-migrations ×1

migration ×1

php ×1