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(ServiceDatabase): add support for TimescaleDB detection and database type identification

Andras Bacsaiec30426a2ff7
diff --git a/app/Models/ServiceDatabase.php b/app/Models/ServiceDatabase.php
index d595721d85..3a249059c2 100644
--- a/app/Models/ServiceDatabase.php
+++ b/app/Models/ServiceDatabase.php
@@ -84,6 +84,10 @@ class ServiceDatabase extends BaseModel
$image = str($this->image)->before(':');
if ($image->contains('supabase/postgres')) {
$finalImage = 'supabase/postgres';
+ } elseif ($image->contains('timescale')) {
+ $finalImage = 'postgresql';
+ } elseif ($image->contains('pgvector')) {
+ $finalImage = 'postgresql';
} elseif ($image->contains('postgres') || $image->contains('postgis')) {
$finalImage = 'postgresql';
} else {
diff --git a/bootstrap/helpers/constants.php b/bootstrap/helpers/constants.php
index 382e2d0159..f588b6c00f 100644
--- a/bootstrap/helpers/constants.php
+++ b/bootstrap/helpers/constants.php
@@ -47,6 +47,8 @@ const DATABASE_DOCKER_IMAGES = [
'neo4j',
'influxdb',
'clickhouse/clickhouse-server',
+ 'timescaledb/timescaledb',
+ 'pgvector/pgvector',
];
const SPECIFIC_SERVICES = [
'quay.io/minio/minio',
diff --git a/tests/Unit/TimescaleDbDetectionTest.php b/tests/Unit/TimescaleDbDetectionTest.php
new file mode 100644
index 0000000000..70c4ed1c14
--- /dev/null
+++ b/tests/Unit/TimescaleDbDetectionTest.php
@@ -0,0 +1,80 @@
+<?php
+
+use App\Models\ServiceDatabase;
+
+use function PHPUnit\Framework\assertTrue;
+
+test('timescaledb is detected as database with postgres environment variables', function () {
+ $image = 'timescale/timescaledb';
+ $serviceConfig = [
+ 'image' => 'timescale/timescaledb',
+ 'environment' => [
+ 'POSTGRES_DB=$POSTGRES_DB',
+ 'POSTGRES_USER=$SERVICE_USER_POSTGRES',
+ 'POSTGRES_PASSWORD=$SERVICE_PASSWORD_POSTGRES',
+ ],
+ 'volumes' => [
+ 'timescaledb-data:/var/lib/postgresql/data',
+ ],
+ ];
+
+ $isDatabase = isDatabaseImage($image, $serviceConfig);
+
+ assertTrue($isDatabase, 'TimescaleDB with POSTGRES_PASSWORD should be detected as database');
+});
+
+test('timescaledb is detected as database without service config', function () {
+ $image = 'timescale/timescaledb';
+
+ $isDatabase = isDatabaseImage($image);
+
+ assertTrue($isDatabase, 'TimescaleDB image should be in DATABASE_DOCKER_IMAGES constant');
+});
+
+test('timescaledb-ha is detected as database', function () {
+ $image = 'timescale/timescaledb-ha';
+
+ $isDatabase = isDatabaseImage($image);
+
+ assertTrue($isDatabase, 'TimescaleDB HA image should be in DATABASE_DOCKER_IMAGES constant');
+});
+
+test('timescaledb databaseType returns postgresql', function () {
+ $database = new ServiceDatabase;
+ $database->setRawAttributes(['image' => 'timescale/timescaledb:latest', 'custom_type' => null]);
+ $database->syncOriginal();
+
+ $type = $database->databaseType();
+
+ expect($type)->toBe('standalone-postgresql');
+});
+
+test('timescaledb-ha databaseType returns postgresql', function () {
+ $database = new ServiceDatabase;
+ $database->setRawAttributes(['image' => 'timescale/timescaledb-ha:pg17', 'custom_type' => null]);
+ $database->syncOriginal();
+
+ $type = $database->databaseType();
+
+ expect($type)->toBe('standalone-postgresql');
+});
+
+test('timescaledb backup solution is available', function () {
+ $database = new ServiceDatabase;
+ $database->setRawAttributes(['image' => 'timescale/timescaledb:latest', 'custom_type' => null]);
+ $database->syncOriginal();
+
+ $isAvailable = $database->isBackupSolutionAvailable();
+
+ assertTrue($isAvailable, 'TimescaleDB should have backup solution available');
+});
+
+test('timescaledb-ha backup solution is available', function () {
+ $database = new ServiceDatabase;
+ $database->setRawAttributes(['image' => 'timescale/timescaledb-ha:pg17', 'custom_type' => null]);
+ $database->syncOriginal();
+
+ $isAvailable = $database->isBackupSolutionAvailable();
+
+ assertTrue($isAvailable, 'TimescaleDB HA should have backup solution available');
+});