Description: Support db schema upgrade
 The rally db command provides the separate upgrade subcommand to
 upgrade schema of existing database. This change provides the option to
 use the upgrade command instead of the create command so that users can
 use the sync class for schema upgrade.
Author: Takashi Kajinami <tkajinam@redhat.com>
Date: Tue, 10 Jan 2023 13:50:48 +0900
Change-Id: I778381879c9aa6c790423262c90142a6b383c252
Origin: upstream, https://review.opendev.org/c/openstack/puppet-rally/+/869629
Last-Update: 2023-05-02

diff --git a/manifests/db/sync.pp b/manifests/db/sync.pp
index e115428..ac4082c 100644
--- a/manifests/db/sync.pp
+++ b/manifests/db/sync.pp
@@ -9,14 +9,24 @@
 #   in the command line between 'rally-manage' and 'db create'.
 #   Defaults to '--config-file /etc/rally/rally.conf'
 #
+# [*upgrade*]
+#   (Optional) Run rally db upgrade command instead of rally db create command.
+#   Defaults to false
+#
 class rally::db::sync(
   $extra_params = '--config-file /etc/rally/rally.conf',
+  $upgrade      = false,
 ) {
 
   include rally::deps
 
+  $subcommand = $upgrade ? {
+    true    => 'upgrade',
+    default => 'create'
+  }
+
   exec { 'rally-manage db_sync':
-    command     => "rally ${extra_params} db create",
+    command     => "rally ${extra_params} db ${subcommand}",
     path        => '/usr/bin',
     user        => 'root',
     refreshonly => true,
