deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@redhat.com
Subject [PATCH core 4/4] Core: Don't run migrations when server starts
Date Fri, 08 Feb 2013 08:16:24 GMT
From: Michal Fojtik <mfojtik@redhat.com>

Users can now run migrations using:

- bin/deltacloud-db-upgrade
- rake db:migrate

Signed-off-by: Michal fojtik <mfojtik@redhat.com>
---
 server/Rakefile                  | 10 ++++++++++
 server/bin/deltacloud-db-upgrade | 13 +++++++++++++
 server/lib/db.rb                 |  4 +---
 3 files changed, 24 insertions(+), 3 deletions(-)
 create mode 100755 server/bin/deltacloud-db-upgrade

diff --git a/server/Rakefile b/server/Rakefile
index 5494148..5938b9e 100644
--- a/server/Rakefile
+++ b/server/Rakefile
@@ -46,6 +46,16 @@ Gem::PackageTask.new(spec) do |pkg|
   pkg.need_tar = true
 end
 
+namespace :db do
+  desc 'Execute the database migrations'
+  task 'migrate' do
+    ENV['API_VERBOSE'] = 'true'
+    load File.join(File.dirname(__FILE__), 'lib', 'db.rb')
+    db = Deltacloud.database
+    Sequel::Migrator.apply(db, File.join(File.dirname(__FILE__), 'db', 'migrations'))
+  end
+end
+
 namespace :mock do
   namespace :fixtures do
     desc "Setup Mock driver fixtures"
diff --git a/server/bin/deltacloud-db-upgrade b/server/bin/deltacloud-db-upgrade
new file mode 100755
index 0000000..2698350
--- /dev/null
+++ b/server/bin/deltacloud-db-upgrade
@@ -0,0 +1,13 @@
+#!/usr/bin/env ruby
+
+ENV['API_VERBOSE'] = 'true'
+
+load File.join(File.dirname(__FILE__), '..', 'lib', 'db.rb')
+
+# Initialize the database
+#
+db = Deltacloud.initialize_database
+
+# Apply the migrations
+#
+Sequel::Migrator.apply(db, File.join(File.dirname(__FILE__), '..', 'db', 'migrations'))
diff --git a/server/lib/db.rb b/server/lib/db.rb
index 33217a3..9e24b7e 100644
--- a/server/lib/db.rb
+++ b/server/lib/db.rb
@@ -93,8 +93,6 @@ module Deltacloud
       column :volume_config, :string
       column :volume_image, :string
     }
-
-    Sequel::Migrator.apply(db, File.join(File.dirname(__FILE__), 'db', 'migrations'))
+    db
   end
-
 end
-- 
1.8.1


Mime
View raw message