From a33fd9a36e8f42f1d3cbc8958f9c86aab88f69a4 Mon Sep 17 00:00:00 2001 From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com> Date: Thu, 24 Sep 2026 18:11:15 +0200 Subject: [PATCH] feat(database): add sqlite as a standalone database type --- app/Enums/NewDatabaseTypes.php | 1 + app/Enums/NewResourceTypes.php | 1 + app/Livewire/Project/Service/FileStorage.php | 3 ++- .../Project/Shared/ConfigurationChecker.php | 3 ++- app/Livewire/Project/Shared/Danger.php | 3 ++- app/Livewire/Project/Shared/GetLogs.php | 3 ++- app/Livewire/Project/Shared/Logs.php | 3 ++- app/Models/Environment.php | 9 ++++++++- app/Models/Project.php | 9 ++++++++- app/Models/Server.php | 2 ++ app/Models/StandaloneDocker.php | 8 +++++++- app/Models/SwarmDocker.php | 8 +++++++- bootstrap/helpers/constants.php | 4 +++- bootstrap/helpers/databases.php | 18 ++++++++++++++++++ bootstrap/helpers/shared.php | 3 ++- 15 files changed, 67 insertions(+), 11 deletions(-) diff --git a/app/Enums/NewDatabaseTypes.php b/app/Enums/NewDatabaseTypes.php index 3563146ff1..8ab3682598 100644 --- a/app/Enums/NewDatabaseTypes.php +++ b/app/Enums/NewDatabaseTypes.php @@ -12,4 +12,5 @@ enum NewDatabaseTypes: string case KEYDB = 'keydb'; case DRAGONFLY = 'dragonfly'; case CLICKHOUSE = 'clickhouse'; + case SQLITE = 'sqlite'; } diff --git a/app/Enums/NewResourceTypes.php b/app/Enums/NewResourceTypes.php index d806a46ed0..4fee12e131 100644 --- a/app/Enums/NewResourceTypes.php +++ b/app/Enums/NewResourceTypes.php @@ -19,4 +19,5 @@ enum NewResourceTypes: string case KEYDB = 'keydb'; case DRAGONFLY = 'dragonfly'; case CLICKHOUSE = 'clickhouse'; + case SQLITE = 'sqlite'; } diff --git a/app/Livewire/Project/Service/FileStorage.php b/app/Livewire/Project/Service/FileStorage.php index cd209f6ae9..9ad6e4d2f4 100644 --- a/app/Livewire/Project/Service/FileStorage.php +++ b/app/Livewire/Project/Service/FileStorage.php @@ -15,6 +15,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 Livewire\Attributes\On; use Livewire\Attributes\Validate; @@ -26,7 +27,7 @@ class FileStorage extends Component public LocalFileVolume $fileStorage; - public ServiceApplication|StandaloneRedis|StandalonePostgresql|StandaloneMongodb|StandaloneMysql|StandaloneMariadb|StandaloneKeydb|StandaloneDragonfly|StandaloneClickhouse|ServiceDatabase|Application $resource; + public ServiceApplication|StandaloneRedis|StandalonePostgresql|StandaloneMongodb|StandaloneMysql|StandaloneMariadb|StandaloneKeydb|StandaloneDragonfly|StandaloneClickhouse|StandaloneSqlite|ServiceDatabase|Application $resource; public string $fs_path; diff --git a/app/Livewire/Project/Shared/ConfigurationChecker.php b/app/Livewire/Project/Shared/ConfigurationChecker.php index fb3360c184..fd6e7f618e 100644 --- a/app/Livewire/Project/Shared/ConfigurationChecker.php +++ b/app/Livewire/Project/Shared/ConfigurationChecker.php @@ -12,6 +12,7 @@ use App\Models\StandaloneMongodb; use App\Models\StandaloneMysql; use App\Models\StandalonePostgresql; use App\Models\StandaloneRedis; +use App\Models\StandaloneSqlite; use Illuminate\Contracts\View\View; use Livewire\Component; @@ -25,7 +26,7 @@ class ConfigurationChecker extends Component public array $missingRequiredEnvironmentVariableNames = []; - public Application|Service|StandaloneRedis|StandalonePostgresql|StandaloneMongodb|StandaloneMysql|StandaloneMariadb|StandaloneKeydb|StandaloneDragonfly|StandaloneClickhouse $resource; + public Application|Service|StandaloneRedis|StandalonePostgresql|StandaloneMongodb|StandaloneMysql|StandaloneMariadb|StandaloneKeydb|StandaloneDragonfly|StandaloneClickhouse|StandaloneSqlite $resource; public function getListeners(): array { diff --git a/app/Livewire/Project/Shared/Danger.php b/app/Livewire/Project/Shared/Danger.php index 7fb477fd6c..e9b3cffa22 100644 --- a/app/Livewire/Project/Shared/Danger.php +++ b/app/Livewire/Project/Shared/Danger.php @@ -72,7 +72,8 @@ class Danger extends Component 'standalone-mariadb', 'standalone-keydb', 'standalone-dragonfly', - 'standalone-clickhouse' => $this->resource->name ?? 'Database', + 'standalone-clickhouse', + 'standalone-sqlite' => $this->resource->name ?? 'Database', 'service' => $this->resource->name ?? 'Service', 'service-application' => $this->resource->name ?? 'Service Application', 'service-database' => $this->resource->name ?? 'Service Database', diff --git a/app/Livewire/Project/Shared/GetLogs.php b/app/Livewire/Project/Shared/GetLogs.php index 3da0c75876..6a1d3b8760 100644 --- a/app/Livewire/Project/Shared/GetLogs.php +++ b/app/Livewire/Project/Shared/GetLogs.php @@ -16,6 +16,7 @@ use App\Models\StandaloneMongodb; use App\Models\StandaloneMysql; use App\Models\StandalonePostgresql; use App\Models\StandaloneRedis; +use App\Models\StandaloneSqlite; use App\Support\ValidationPatterns; use Illuminate\Foundation\Auth\Access\AuthorizesRequests; use Illuminate\Support\Facades\Process; @@ -37,7 +38,7 @@ class GetLogs extends Component public string $errors = ''; #[Locked] - public Application|Service|StandalonePostgresql|StandaloneRedis|StandaloneMongodb|StandaloneMysql|StandaloneMariadb|StandaloneKeydb|StandaloneDragonfly|StandaloneClickhouse|null $resource = null; + public Application|Service|StandalonePostgresql|StandaloneRedis|StandaloneMongodb|StandaloneMysql|StandaloneMariadb|StandaloneKeydb|StandaloneDragonfly|StandaloneClickhouse|StandaloneSqlite|null $resource = null; #[Locked] public ServiceApplication|ServiceDatabase|null $servicesubtype = null; diff --git a/app/Livewire/Project/Shared/Logs.php b/app/Livewire/Project/Shared/Logs.php index 24306a7bcd..2b7c21836a 100644 --- a/app/Livewire/Project/Shared/Logs.php +++ b/app/Livewire/Project/Shared/Logs.php @@ -12,6 +12,7 @@ use App\Models\StandaloneMongodb; use App\Models\StandaloneMysql; use App\Models\StandalonePostgresql; use App\Models\StandaloneRedis; +use App\Models\StandaloneSqlite; use Illuminate\Support\Collection; use Livewire\Component; @@ -19,7 +20,7 @@ class Logs extends Component { public ?string $type = null; - 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 Collection $servers; diff --git a/app/Models/Environment.php b/app/Models/Environment.php index e98f13d21f..0120461040 100644 --- a/app/Models/Environment.php +++ b/app/Models/Environment.php @@ -64,6 +64,7 @@ class Environment extends BaseModel $this->clickhouses()->count() == 0 && $this->mariadbs()->count() == 0 && $this->mongodbs()->count() == 0 && + $this->sqlites()->count() == 0 && $this->services()->count() == 0; } @@ -117,6 +118,11 @@ class Environment extends BaseModel return $this->hasMany(StandaloneClickhouse::class); } + public function sqlites() + { + return $this->hasMany(StandaloneSqlite::class); + } + public function databases() { $postgresqls = $this->postgresqls; @@ -127,8 +133,9 @@ class Environment extends BaseModel $keydbs = $this->keydbs; $dragonflies = $this->dragonflies; $clickhouses = $this->clickhouses; + $sqlites = $this->sqlites; - return $postgresqls->concat($redis)->concat($mongodbs)->concat($mysqls)->concat($mariadbs)->concat($keydbs)->concat($dragonflies)->concat($clickhouses); + return $postgresqls->concat($redis)->concat($mongodbs)->concat($mysqls)->concat($mariadbs)->concat($keydbs)->concat($dragonflies)->concat($clickhouses)->concat($sqlites); } public function project() diff --git a/app/Models/Project.php b/app/Models/Project.php index 65c21c1e78..7df5ecad50 100644 --- a/app/Models/Project.php +++ b/app/Models/Project.php @@ -130,6 +130,11 @@ class Project extends BaseModel return $this->hasManyThrough(StandaloneClickhouse::class, Environment::class); } + public function sqlites() + { + return $this->hasManyThrough(StandaloneSqlite::class, Environment::class); + } + public function mongodbs() { return $this->hasManyThrough(StandaloneMongodb::class, Environment::class); @@ -156,6 +161,7 @@ class Project extends BaseModel $this->clickhouses()->count() == 0 && $this->mariadbs()->count() == 0 && $this->mongodbs()->count() == 0 && + $this->sqlites()->count() == 0 && $this->services()->count() == 0; } @@ -168,7 +174,8 @@ class Project extends BaseModel ->concat($this->mariadbs()->with($with)->get()) ->concat($this->keydbs()->with($with)->get()) ->concat($this->dragonflies()->with($with)->get()) - ->concat($this->clickhouses()->with($with)->get()); + ->concat($this->clickhouses()->with($with)->get()) + ->concat($this->sqlites()->with($with)->get()); } public function navigateTo() diff --git a/app/Models/Server.php b/app/Models/Server.php index 20952d5598..8268d44c9b 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -1194,6 +1194,7 @@ $siteAddress { $keydbs = StandaloneKeydb::where($destinationCondition)->get(); $dragonflies = StandaloneDragonfly::where($destinationCondition)->get(); $clickhouses = StandaloneClickhouse::where($destinationCondition)->get(); + $sqlites = StandaloneSqlite::where($destinationCondition)->get(); return $postgresqls ->concat($redis) @@ -1203,6 +1204,7 @@ $siteAddress { ->concat($keydbs) ->concat($dragonflies) ->concat($clickhouses) + ->concat($sqlites) ->filter(fn ($item) => data_get($item, 'name') !== 'coolify-db'); } diff --git a/app/Models/StandaloneDocker.php b/app/Models/StandaloneDocker.php index e7e0a8c108..27483542da 100644 --- a/app/Models/StandaloneDocker.php +++ b/app/Models/StandaloneDocker.php @@ -111,6 +111,11 @@ class StandaloneDocker extends BaseModel return $this->morphMany(StandaloneClickhouse::class, 'destination'); } + public function sqlites() + { + return $this->morphMany(StandaloneSqlite::class, 'destination'); + } + public function server() { return $this->belongsTo(Server::class); @@ -163,8 +168,9 @@ class StandaloneDocker extends BaseModel $keydbs = $this->keydbs; $dragonflies = $this->dragonflies; $clickhouses = $this->clickhouses; + $sqlites = $this->sqlites; - return $postgresqls->concat($redis)->concat($mongodbs)->concat($mysqls)->concat($mariadbs)->concat($keydbs)->concat($dragonflies)->concat($clickhouses); + return $postgresqls->concat($redis)->concat($mongodbs)->concat($mysqls)->concat($mariadbs)->concat($keydbs)->concat($dragonflies)->concat($clickhouses)->concat($sqlites); } public function attachedTo() diff --git a/app/Models/SwarmDocker.php b/app/Models/SwarmDocker.php index 02b8381d99..ec4a0568e0 100644 --- a/app/Models/SwarmDocker.php +++ b/app/Models/SwarmDocker.php @@ -51,6 +51,11 @@ class SwarmDocker extends BaseModel return $this->morphMany(StandaloneClickhouse::class, 'destination'); } + public function sqlites() + { + return $this->morphMany(StandaloneSqlite::class, 'destination'); + } + public function mongodbs() { return $this->morphMany(StandaloneMongodb::class, 'destination'); @@ -118,8 +123,9 @@ class SwarmDocker extends BaseModel $keydbs = $this->keydbs; $dragonflies = $this->dragonflies; $clickhouses = $this->clickhouses; + $sqlites = $this->sqlites; - return $postgresqls->concat($redis)->concat($mongodbs)->concat($mysqls)->concat($mariadbs)->concat($keydbs)->concat($dragonflies)->concat($clickhouses); + return $postgresqls->concat($redis)->concat($mongodbs)->concat($mysqls)->concat($mariadbs)->concat($keydbs)->concat($dragonflies)->concat($clickhouses)->concat($sqlites); } public function attachedTo() diff --git a/bootstrap/helpers/constants.php b/bootstrap/helpers/constants.php index 79049e8c71..4ab7d74698 100644 --- a/bootstrap/helpers/constants.php +++ b/bootstrap/helpers/constants.php @@ -8,9 +8,10 @@ use App\Models\StandaloneMongodb; use App\Models\StandaloneMysql; use App\Models\StandalonePostgresql; use App\Models\StandaloneRedis; +use App\Models\StandaloneSqlite; const REDACTED = ''; -const DATABASE_TYPES = ['postgresql', 'redis', 'mongodb', 'mysql', 'mariadb', 'keydb', 'dragonfly', 'clickhouse']; +const DATABASE_TYPES = ['postgresql', 'redis', 'mongodb', 'mysql', 'mariadb', 'keydb', 'dragonfly', 'clickhouse', 'sqlite']; const STANDALONE_DATABASE_MODELS = [ 'postgresql' => StandalonePostgresql::class, 'redis' => StandaloneRedis::class, @@ -20,6 +21,7 @@ const STANDALONE_DATABASE_MODELS = [ 'keydb' => StandaloneKeydb::class, 'dragonfly' => StandaloneDragonfly::class, 'clickhouse' => StandaloneClickhouse::class, + 'sqlite' => StandaloneSqlite::class, ]; const VALID_CRON_STRINGS = [ 'every_minute' => '* * * * *', diff --git a/bootstrap/helpers/databases.php b/bootstrap/helpers/databases.php index 03a2e4fa3d..87c359fd07 100644 --- a/bootstrap/helpers/databases.php +++ b/bootstrap/helpers/databases.php @@ -13,6 +13,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\Storage; @@ -181,6 +182,23 @@ function create_standalone_clickhouse($environment_id, StandaloneDocker|SwarmDoc return $database; } +function create_standalone_sqlite($environment_id, StandaloneDocker|SwarmDocker $destination, ?array $otherData = null): StandaloneSqlite +{ + $database = new StandaloneSqlite; + $database->uuid = new_public_id(); + $database->name = 'sqlite-database-'.$database->uuid; + $database->image = 'peakimages/sqlite:3.53.4-v0.1.0'; + $database->environment_id = $environment_id; + $database->destination_id = $destination->id; + $database->destination_type = $destination->getMorphClass(); + if ($otherData) { + $database->fill($otherData); + } + $database->save(); + + return $database; +} + function deleteBackupsLocally(string|array|null $filenames, Server $server, bool $throwError = false): void { if (empty($filenames)) { diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.php index 9eee10d6ec..88bdf12038 100644 --- a/bootstrap/helpers/shared.php +++ b/bootstrap/helpers/shared.php @@ -28,6 +28,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\Team; use App\Models\User; @@ -4142,7 +4143,7 @@ function isAssociativeArray($array) * * Theses variables are added in place to the $where_to_add array. */ -function add_coolify_default_environment_variables(StandaloneRedis|StandalonePostgresql|StandaloneMongodb|StandaloneMysql|StandaloneMariadb|StandaloneKeydb|StandaloneDragonfly|StandaloneClickhouse|Application|Service $resource, Collection &$where_to_add, ?Collection $where_to_check = null) +function add_coolify_default_environment_variables(StandaloneRedis|StandalonePostgresql|StandaloneMongodb|StandaloneMysql|StandaloneMariadb|StandaloneKeydb|StandaloneDragonfly|StandaloneClickhouse|StandaloneSqlite|Application|Service $resource, Collection &$where_to_add, ?Collection $where_to_check = null) { // Currently disabled return;