mirror of
https://github.com/tiennm99/coolify.git
synced 2026-04-17 15:20:40 +00:00
feat(database): add official postgres 18 support
- postgres versions 18 and higher require a different volume mount path, so we need to adjust the path when creating them
This commit is contained in:
@@ -28,9 +28,23 @@ class StandalonePostgresql extends BaseModel
|
||||
protected static function booted()
|
||||
{
|
||||
static::created(function ($database) {
|
||||
// This is really stupid and it took me 1h to figure out why the image was not loading properly. This is exactly the reason why we need to use the action pattern because Model events and Accessors are a fragile mess!
|
||||
$image = (string) ($database->getAttributes()['image'] ?? '');
|
||||
$majorVersion = 0;
|
||||
|
||||
if (preg_match('/:(\d+)/', $image, $matches)) {
|
||||
$majorVersion = (int) $matches[1];
|
||||
}
|
||||
|
||||
// PostgreSQL 18+ uses /var/lib/postgresql as mount path
|
||||
// Older versions use /var/lib/postgresql/data
|
||||
$mountPath = $majorVersion >= 18
|
||||
? '/var/lib/postgresql'
|
||||
: '/var/lib/postgresql/data';
|
||||
|
||||
LocalPersistentVolume::create([
|
||||
'name' => 'postgres-data-'.$database->uuid,
|
||||
'mount_path' => '/var/lib/postgresql/data',
|
||||
'mount_path' => $mountPath,
|
||||
'host_path' => null,
|
||||
'resource_id' => $database->id,
|
||||
'resource_type' => $database->getMorphClass(),
|
||||
|
||||
Reference in New Issue
Block a user