Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

feat(database): support sqlite in migration, cloning and server transfer

peaklabs-dev2cb4c3b50178
diff --git a/app/Actions/Shared/MigrateResourceToDestination.php b/app/Actions/Shared/MigrateResourceToDestination.php
index 7e3df4bff4..b0979e1677 100644
--- a/app/Actions/Shared/MigrateResourceToDestination.php
+++ b/app/Actions/Shared/MigrateResourceToDestination.php
@@ -21,6 +21,7 @@ use App\Models\StandaloneMongodb;
use App\Models\StandaloneMysql;
use App\Models\StandalonePostgresql;
use App\Models\StandaloneRedis;
+use App\Models\StandaloneSqlite;
use App\Models\SwarmDocker;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Bus;
@@ -35,7 +36,7 @@ class MigrateResourceToDestination
* @return array{async: bool, volume_jobs: int, message: string}
*/
public function handle(
- Application|Service|StandalonePostgresql|StandaloneRedis|StandaloneMongodb|StandaloneMysql|StandaloneMariadb|StandaloneKeydb|StandaloneDragonfly|StandaloneClickhouse $resource,
+ Application|Service|StandalonePostgresql|StandaloneRedis|StandaloneMongodb|StandaloneMysql|StandaloneMariadb|StandaloneKeydb|StandaloneDragonfly|StandaloneClickhouse|StandaloneSqlite $resource,
StandaloneDocker|SwarmDocker $destination,
bool $migrateVolumes = true,
): array {
@@ -133,7 +134,7 @@ class MigrateResourceToDestination
}
public function applyDestination(
- Application|Service|StandalonePostgresql|StandaloneRedis|StandaloneMongodb|StandaloneMysql|StandaloneMariadb|StandaloneKeydb|StandaloneDragonfly|StandaloneClickhouse $resource,
+ Application|Service|StandalonePostgresql|StandaloneRedis|StandaloneMongodb|StandaloneMysql|StandaloneMariadb|StandaloneKeydb|StandaloneDragonfly|StandaloneClickhouse|StandaloneSqlite $resource,
StandaloneDocker|SwarmDocker $destination,
): void {
$payload = [
@@ -169,7 +170,7 @@ class MigrateResourceToDestination
}
protected function stopResource(
- Application|Service|StandalonePostgresql|StandaloneRedis|StandaloneMongodb|StandaloneMysql|StandaloneMariadb|StandaloneKeydb|StandaloneDragonfly|StandaloneClickhouse $resource,
+ Application|Service|StandalonePostgresql|StandaloneRedis|StandaloneMongodb|StandaloneMysql|StandaloneMariadb|StandaloneKeydb|StandaloneDragonfly|StandaloneClickhouse|StandaloneSqlite $resource,
): void {
try {
if ($resource instanceof Application) {
@@ -191,7 +192,7 @@ class MigrateResourceToDestination
* @return array<int, VolumeCloneJob|HostPathCloneJob>
*/
protected function buildVolumeJobs(
- Application|Service|StandalonePostgresql|StandaloneRedis|StandaloneMongodb|StandaloneMysql|StandaloneMariadb|StandaloneKeydb|StandaloneDragonfly|StandaloneClickhouse $resource,
+ Application|Service|StandalonePostgresql|StandaloneRedis|StandaloneMongodb|StandaloneMysql|StandaloneMariadb|StandaloneKeydb|StandaloneDragonfly|StandaloneClickhouse|StandaloneSqlite $resource,
$sourceServer,
$targetServer,
): array {
@@ -231,7 +232,7 @@ class MigrateResourceToDestination
* @return Collection<int, LocalPersistentVolume>
*/
protected function collectPersistentVolumes(
- Application|Service|StandalonePostgresql|StandaloneRedis|StandaloneMongodb|StandaloneMysql|StandaloneMariadb|StandaloneKeydb|StandaloneDragonfly|StandaloneClickhouse $resource,
+ Application|Service|StandalonePostgresql|StandaloneRedis|StandaloneMongodb|StandaloneMysql|StandaloneMariadb|StandaloneKeydb|StandaloneDragonfly|StandaloneClickhouse|StandaloneSqlite $resource,
) {
if ($resource instanceof Service) {
$volumes = collect();
@@ -265,7 +266,7 @@ class MigrateResourceToDestination
}
protected function resaveFileStorages(
- Application|Service|StandalonePostgresql|StandaloneRedis|StandaloneMongodb|StandaloneMysql|StandaloneMariadb|StandaloneKeydb|StandaloneDragonfly|StandaloneClickhouse $resource,
+ Application|Service|StandalonePostgresql|StandaloneRedis|StandaloneMongodb|StandaloneMysql|StandaloneMariadb|StandaloneKeydb|StandaloneDragonfly|StandaloneClickhouse|StandaloneSqlite $resource,
): void {
$fileStorages = collect();
diff --git a/app/Jobs/FinalizeResourceMigrationJob.php b/app/Jobs/FinalizeResourceMigrationJob.php
index b517656f37..91b113a546 100644
--- a/app/Jobs/FinalizeResourceMigrationJob.php
+++ b/app/Jobs/FinalizeResourceMigrationJob.php
@@ -14,6 +14,7 @@ use App\Models\StandaloneMongodb;
use App\Models\StandaloneMysql;
use App\Models\StandalonePostgresql;
use App\Models\StandaloneRedis;
+use App\Models\StandaloneSqlite;
use App\Models\SwarmDocker;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeEncrypted;
@@ -30,7 +31,7 @@ class FinalizeResourceMigrationJob implements ShouldBeEncrypted, ShouldQueue
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public function __construct(
- public Application|Service|StandalonePostgresql|StandaloneRedis|StandaloneMongodb|StandaloneMysql|StandaloneMariadb|StandaloneKeydb|StandaloneDragonfly|StandaloneClickhouse $resource,
+ public Application|Service|StandalonePostgresql|StandaloneRedis|StandaloneMongodb|StandaloneMysql|StandaloneMariadb|StandaloneKeydb|StandaloneDragonfly|StandaloneClickhouse|StandaloneSqlite $resource,
public StandaloneDocker|SwarmDocker $destination,
) {
$this->onQueue('high');
diff --git a/app/Livewire/Project/CloneMe.php b/app/Livewire/Project/CloneMe.php
index ad032779b3..4771e4195d 100644
--- a/app/Livewire/Project/CloneMe.php
+++ b/app/Livewire/Project/CloneMe.php
@@ -190,6 +190,8 @@ class CloneMe extends Component
$newName = 'keydb-data-'.$newDatabase->uuid;
} elseif (str_starts_with($originalName, 'dragonfly-data-')) {
$newName = 'dragonfly-data-'.$newDatabase->uuid;
+ } elseif (str_starts_with($originalName, 'sqlite-data-')) {
+ $newName = 'sqlite-data-'.$newDatabase->uuid;
} else {
if (str_starts_with($volume->name, $database->uuid)) {
$newName = str($volume->name)->replace($database->uuid, $newDatabase->uuid);
diff --git a/app/Livewire/Project/Shared/ResourceOperations.php b/app/Livewire/Project/Shared/ResourceOperations.php
index 61b4b2d2ed..61f539cde6 100644
--- a/app/Livewire/Project/Shared/ResourceOperations.php
+++ b/app/Livewire/Project/Shared/ResourceOperations.php
@@ -19,6 +19,7 @@ use App\Models\StandaloneMongodb;
use App\Models\StandaloneMysql;
use App\Models\StandalonePostgresql;
use App\Models\StandaloneRedis;
+use App\Models\StandaloneSqlite;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Validation\ValidationException;
use Livewire\Component;
@@ -116,7 +117,8 @@ class ResourceOperations extends Component
$this->resource->getMorphClass() === StandaloneRedis::class ||
$this->resource->getMorphClass() === StandaloneKeydb::class ||
$this->resource->getMorphClass() === StandaloneDragonfly::class ||
- $this->resource->getMorphClass() === StandaloneClickhouse::class
+ $this->resource->getMorphClass() === StandaloneClickhouse::class ||
+ $this->resource->getMorphClass() === StandaloneSqlite::class
) {
$uuid = new_public_id();
$new_resource = $this->resource->replicate([
@@ -161,6 +163,8 @@ class ResourceOperations extends Component
$newName = 'keydb-data-'.$new_resource->uuid;
} elseif (str_starts_with($originalName, 'dragonfly-data-')) {
$newName = 'dragonfly-data-'.$new_resource->uuid;
+ } elseif (str_starts_with($originalName, 'sqlite-data-')) {
+ $newName = 'sqlite-data-'.$new_resource->uuid;
} else {
if (str_starts_with($volume->name, $this->resource->uuid)) {
$newName = str($volume->name)->replace($this->resource->uuid, $new_resource->uuid);
diff --git a/app/Services/ServerTransfer/ServerTransferImporter.php b/app/Services/ServerTransfer/ServerTransferImporter.php
index 995555954b..a254f255cf 100644
--- a/app/Services/ServerTransfer/ServerTransferImporter.php
+++ b/app/Services/ServerTransfer/ServerTransferImporter.php
@@ -33,6 +33,7 @@ use App\Models\StandaloneMongodb;
use App\Models\StandaloneMysql;
use App\Models\StandalonePostgresql;
use App\Models\StandaloneRedis;
+use App\Models\StandaloneSqlite;
use App\Models\SwarmDocker;
use App\Models\Tag;
use App\Models\Team;
@@ -57,6 +58,7 @@ class ServerTransferImporter
'StandaloneKeydb' => StandaloneKeydb::class,
'StandaloneDragonfly' => StandaloneDragonfly::class,
'StandaloneClickhouse' => StandaloneClickhouse::class,
+ 'StandaloneSqlite' => StandaloneSqlite::class,
];
/** @var array<string, PrivateKey> */