This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
Hi all, I need an help from you.
Basically I have a scheduled command in my Plugin.php registration file. The code is as follows:
public function registerSchedule($schedule)
{
$schedule->call(function () {
$yesterdayDate = Carbon::now()->sub(new DateInterval('P1D'));
\Db::table("accommodation_unavailabilities")
->where("saved_from", "RENTAL_REQUEST")
->whereDate("saved_on", "<=", $yesterdayDate->toDateString())
->whereNull("paid")
->delete();
})->everyMinute();
}
The command gets called every minute, but I have the problem that the code generates the following error:
development.ERROR: InvalidArgumentException: Database (storage/database.sqlite) does not exist. in /var/www/casavacanzanelsalento/vendor/laravel/framework/src/Illuminate/Database/Connectors/SQLiteConnector.php:34
Stack trace:
#0 /var/www/casavacanzanelsalento/vendor/laravel/framework/src/Illuminate/Database/Connectors/ConnectionFactory.php(221): Illuminate\Database\Connectors\SQLiteConnector->connect(Array)
#1 [internal function]: Illuminate\Database\Connectors\ConnectionFactory->Illuminate\Database\Connectors\{closure}()
...
...
Next Illuminate\Database\QueryException: Database (storage/database.sqlite) does not exist. (SQL: delete from "_accommodation_unavailabilities" where "saved_from" = RENTAL_REQUEST and strftime('%Y-%m-%d', "saved_on") <= 2021-02-15 and "paid" is null) in /var/www/casavacanzanelsalento/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664
Stack trace:
#0 /var/www/casavacanzanelsalento/vendor/laravel/framework/src/Illuminate/Database/Connection.php(624): Illuminate\Database\Connection->runQueryCallback('delete from "le...', Array, Object(Closure))
#1 /var/www/casavacanzanelsalento/vendor/laravel/framework/src/Illuminate/Database/Connection.php(490): Illuminate\Database\Connection->run('delete from "le...', Array, Object(Closure))
#2 /var/www/casavacanzanelsalento/vendor/laravel/framework/src/Illuminate/Database/Connection.php(435): Illuminate\Database\Connection->affectingStatement('delete from "le...', Array)
...
...
The same happens if I try to use the models entities. The same code works if I use it in an AJAX handler.
If I run the following command:
php artisan schedule:run
Everything works just fine.
Have any of you faced this error before? How can I solve this?
Thank you and best regards, Leonardo
Last updated
I solved this issue. The problem is that for some reason, the scheduled task doesn't resolve correctly the path to the sqlite database, which is defined using a relative path in the config/database.php file. To solve this issue I modified the entry in the configuration file to be an absolute path "/<path-to-october-installation/storage/database.sqlite". This has resolved the issue.
1-2 of 2