我正在 laravel 中创建迁移,有时我需要在数据库中创建自定义外键名称。我已经搜索过这个解决方案,但没有与我的问题类似的内容。
\n我想添加列names包含birth_city_id、birth_state_id 和birth_country_id 的表添加列。除此之外,我还想添加 Death_city_id、death_state_id、death_county_id。
错误:
\nMigrating: 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) 我已经在我的应用程序中实现了 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)