Dear,
I am having some issues with setting up my project using SQLite. I want to be able to run my project using MySQL for my regular application environments by want to run the PHPUnit tests using SQLite. However, I am getting errors when trying to interact with my database when using SQLite.
I have setup the handel methods in ConfigureTenantDatabase and ConfigureTenantConnection as follows:
public function handle(Configuring $event)
{
if (config('database.default') == 'mysql') {
$event->useConnection('mysql', $event->defaults($event->tenant));
return;
}
$directory = database_path('tenant/');
$path = $directory.$event->tenant->getTenantKey().'.sqlite';
if(!file_exists($path)) {
if(!file_exists($directory)) mkdir($directory);
file_put_contents($path, '');
}
$event->useConnection('sqlite', [
'database' => $path,
]);
}
When running on MySQL I have no issues. However when running on SQLite I am getting database related errors such as the following:
SQLSTATE[HY000]: General error: 1 near ".": syntax error (SQL: select "users".*, "C:\xampp\htdocs\17029-buildingvirtuality\database\tenant/BSR0pLZrdtn90o2UHS4no0Y7lO9SxX0u"."sqlite"."project_user"."project_id" as "pivot_project_id", "C:\xampp\htdocs\17029-buildingvirtuality\database\tenant/BSR0pLZrdtn90o2UHS4no0Y7lO9SxX0u"."sqlite"."project_user"."user_id" as "pivot_user_id" from "users" inner join "C:\xampp\htdocs\17029-buildingvirtuality\database\tenant/BSR0pLZrdtn90o2UHS4no0Y7lO9SxX0u"."sqlite"."project_user" on "users"."id" = "C:\xampp\htdocs\17029-buildingvirtuality\database\tenant/BSR0pLZrdtn90o2UHS4no0Y7lO9SxX0u"."sqlite"."project_user"."user_id" where "C:\xampp\htdocs\17029-buildingvirtuality\database\tenant/BSR0pLZrdtn90o2UHS4no0Y7lO9SxX0u"."sqlite"."project_user"."project_id" = 40 and "users"."deleted_at" is null)
(Found when running unit tests and inserting data in the tenant database)
I have no issues with interacting with my main database.
Has anybody else experienced similar issues and/or can point me towards a solution? Thanks in advance for any help!