From 30b85e69cd8d6d18301c2fb12e2c5675d4bbaab5 Mon Sep 17 00:00:00 2001 From: Joe Dixon Date: Fri, 22 Jul 2022 16:35:02 +0100 Subject: [PATCH] Update postgres support (#192) --- src/Commands/DatabaseCommand.php | 23 +++++++++++++---------- src/Commands/DatabaseListCommand.php | 2 +- src/Commands/DatabaseShowCommand.php | 2 +- src/Commands/DatabaseUpgradeCommand.php | 15 ++++++++------- 4 files changed, 23 insertions(+), 19 deletions(-) diff --git a/src/Commands/DatabaseCommand.php b/src/Commands/DatabaseCommand.php index 70d1d109..440beef1 100644 --- a/src/Commands/DatabaseCommand.php +++ b/src/Commands/DatabaseCommand.php @@ -44,9 +44,11 @@ public function handle() $public = $this->determineIfPublic(); - if (! $public && + if ( + ! $public && ! $this->networkHasNatGateway($networkId) && - ! Helpers::confirm('A private database will require Vapor to add a NAT gateway to your network (~32 / month). Would you like to proceed', true)) { + ! Helpers::confirm('A private database will require Vapor to add a NAT gateway to your network (~32 / month). Would you like to proceed', true) + ) { Helpers::abort('Action cancelled.'); } @@ -57,7 +59,7 @@ public function handle() $allocatedStorage = $this->determineAllocatedStorage($databaseType); $pause = $databaseType == 'aurora-serverless' && - Helpers::confirm('To reduce your bill, should the database pause during periods of inactivity', false); + Helpers::confirm('To reduce your bill, should the database pause during periods of inactivity', false); $response = $this->vapor->createDatabase( $networkId, @@ -113,10 +115,10 @@ protected function determineDatabaseType($public) 'aurora-serverless' => 'Serverless v1 MySQL 5.7 Aurora Cluster', 'aurora-serverless-v2' => 'Serverless v2 MySQL 8.0 Aurora Cluster', 'rds-pgsql-13.4' => 'Fixed Size PostgreSQL Instance 13.4', - 'rds-pgsql-11.10' => 'Fixed Size PostgreSQL Instance 11.10', - 'aurora-serverless-pgsql' => 'Serverless PostgreSQL Aurora Cluster', + 'aurora-serverless-pgsql' => 'Serverless PostgreSQL 10.7 Aurora Cluster', + 'aurora-serverless-v2-pgsql' => 'Serverless v2 PostgreSQL 14.3 Aurora Cluster', ]), function ($type) use ($public) { - if (in_array($type, ['aurora-serverless', 'aurora-serverless-v2', 'aurora-serverless-pgsql']) && $public) { + if (in_array($type, ['aurora-serverless', 'aurora-serverless-v2', 'aurora-serverless-pgsql', 'aurora-serverless-v2-pgsql']) && $public) { Helpers::abort('Aurora Serverless clusters may not be publicly accessible.'); } }); @@ -138,10 +140,11 @@ protected function determineInstanceClass($type) return; } - if ($type == 'rds' + if ( + $type == 'rds' || $type == 'rds-mysql-5.7' - || $type == 'rds-pgsql-11.10' - || $type == 'rds-pgsql-13.4') { + || $type == 'rds-pgsql-13.4' + ) { return $this->determineRdsInstanceClass(); } } @@ -179,7 +182,7 @@ protected function determineRdsInstanceClass() */ protected function determineAllocatedStorage($type) { - if (in_array($type, ['aurora-serverless', 'aurora-serverless-v2', 'aurora-serverless-pgsql'])) { + if (in_array($type, ['aurora-serverless', 'aurora-serverless-v2', 'aurora-serverless-pgsql', 'aurora-serverless-v2-pgsql'])) { return; } diff --git a/src/Commands/DatabaseListCommand.php b/src/Commands/DatabaseListCommand.php index 1a8544a0..e2f4058a 100644 --- a/src/Commands/DatabaseListCommand.php +++ b/src/Commands/DatabaseListCommand.php @@ -36,7 +36,7 @@ public function handle() $database['cloud_provider']['name'], $database['name'], $database['region'], - in_array($database['type'], ['aurora-serverless', 'aurora-serverless-v2', 'aurora-serverless-pgsql']) + in_array($database['type'], ['aurora-serverless', 'aurora-serverless-v2', 'aurora-serverless-pgsql', 'aurora-serverless-v2-pgsql']) ? 'Serverless' : 'Fixed Size', $database['instance_class'], diff --git a/src/Commands/DatabaseShowCommand.php b/src/Commands/DatabaseShowCommand.php index 72342865..4e826424 100644 --- a/src/Commands/DatabaseShowCommand.php +++ b/src/Commands/DatabaseShowCommand.php @@ -48,7 +48,7 @@ public function handle() $database['cloud_provider']['name'], $database['name'], $database['region'], - in_array($database['type'], ['aurora-serverless', 'aurora-serverless-v2', 'aurora-serverless-pgsql']) ? 'Serverless' : 'Fixed Size', + in_array($database['type'], ['aurora-serverless', 'aurora-serverless-v2', 'aurora-serverless-pgsql', 'aurora-serverless-v2-pgsql']) ? 'Serverless' : 'Fixed Size', $database['instance_class'], $database['storage'].'GB', Str::title(str_replace('_', ' ', $database['status'])), diff --git a/src/Commands/DatabaseUpgradeCommand.php b/src/Commands/DatabaseUpgradeCommand.php index 11194ebc..5252c28e 100644 --- a/src/Commands/DatabaseUpgradeCommand.php +++ b/src/Commands/DatabaseUpgradeCommand.php @@ -19,9 +19,9 @@ class DatabaseUpgradeCommand extends Command 'aurora-serverless' => 'Serverless v1 MySQL 5.7 Aurora Cluster', 'aurora-serverless-v2' => 'Serverless v2 MySQL 8.0 Aurora Cluster', 'rds-pgsql-13.4' => 'Fixed Size PostgreSQL Instance 13.4', - 'rds-pgsql-11.10' => 'Fixed Size PostgreSQL Instance 11.10', 'rds-pgsql' => 'Fixed Size PostgreSQL Instance 10.7', - 'aurora-serverless-pgsql' => 'Serverless PostgreSQL Aurora Cluster', + 'aurora-serverless-pgsql' => 'Serverless PostgreSQL 10.7 Aurora Cluster', + 'aurora-serverless-v2-pgsql' => 'Serverless v2 PostgreSQL 14.3 Aurora Cluster', ]; /** @@ -31,7 +31,6 @@ class DatabaseUpgradeCommand extends Command */ protected $possibleUpgrades = [ 'rds-mysql-5.7' => ['rds'], - 'rds-pgsql' => ['rds-pgsql-11.10'], ]; /** @@ -104,10 +103,12 @@ protected function determineDatabaseType($databaseId) $possibleUpgrades = Arr::get($this->possibleUpgrades, $databaseType, []); if (! empty($possibleUpgrades)) { - return $this->menu('Which type of database would you like to create?', collect($this->databaseTypes) - ->filter(function ($label, $type) use ($possibleUpgrades) { - return in_array($type, $possibleUpgrades); - })->all() + return $this->menu( + 'Which type of database would you like to create?', + collect($this->databaseTypes) + ->filter(function ($label, $type) use ($possibleUpgrades) { + return in_array($type, $possibleUpgrades); + })->all() ); } }