mirror of
https://github.com/coollabsio/coolify.git
synced 2026-10-05 21:47:10 -04:00
feat(database): add sqlite as a standalone database type
This commit is contained in:
@@ -12,4 +12,5 @@ enum NewDatabaseTypes: string
|
||||
case KEYDB = 'keydb';
|
||||
case DRAGONFLY = 'dragonfly';
|
||||
case CLICKHOUSE = 'clickhouse';
|
||||
case SQLITE = 'sqlite';
|
||||
}
|
||||
|
||||
@@ -19,4 +19,5 @@ enum NewResourceTypes: string
|
||||
case KEYDB = 'keydb';
|
||||
case DRAGONFLY = 'dragonfly';
|
||||
case CLICKHOUSE = 'clickhouse';
|
||||
case SQLITE = 'sqlite';
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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 = '<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' => '* * * * *',
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user