Permalink
Browse files

db:migrate for ccng

Change-Id: Id3b6e1432f9caa86b63e76efbbc01a9ea6281630
  • Loading branch information...
1 parent 88e1ea2 commit ae1291560388ff4dfe71081df2eb1de0d015cfb7 @pbozeman pbozeman committed Dec 8, 2012
Showing with 23 additions and 6 deletions.
  1. +4 −2 Gemfile
  2. +19 −2 Rakefile
  3. +0 −2 lib/cloud_controller/runner.rb
View
@@ -17,6 +17,10 @@ gem "httpclient"
gem "steno", "~> 1.0.0"
gem 'stager-client', '~> 0.0.02', :git => 'https://github.com/cloudfoundry/stager-client.git', :ref => '04c2aee9'
+# These are outside the test group in order to run rake tasks
+gem "rspec"
+gem "ci_reporter"
+
group :production do
gem "pg"
end
@@ -27,8 +31,6 @@ group :development do
end
group :test do
- gem "rspec"
- gem "ci_reporter"
gem "simplecov"
gem "simplecov-rcov"
gem "sqlite3"
View
@@ -1,6 +1,12 @@
# Copyright (c) 2009-2012 VMware, Inc.
require "rspec/core/rake_task"
require "ci/reporter/rake/rspec"
+require "yaml"
+require "sequel"
+require "steno"
+require "vcap/config"
+require "cloud_controller/config"
+require "cloud_controller/db"
ENV['CI_REPORTS'] = File.join("spec", "artifacts", "reports")
@@ -42,8 +48,6 @@ task :coverage do
end
namespace :db do
- # TODO: add migration support
-
desc "Create a Sequel migration in ./db/migrate"
task :create_migration do
name = ENV["NAME"]
@@ -65,4 +69,17 @@ end
EOF
end
end
+
+ desc "Perform Sequel migration to database"
+ task :migrate do
+ migrations = File.expand_path("../db/migrations", __FILE__)
+
+ config_file = ENV["CLOUD_CONTROLLER_NG_CONFIG"]
+ config_file ||= File.expand_path("../config/cloud_controller.yml", __FILE__)
+
+ config = VCAP::CloudController::Config.from_file(config_file)
+ db_logger = Steno.logger("cc.db.migrations")
+ db = VCAP::CloudController::DB.connect(db_logger, config[:db])
+ VCAP::CloudController::DB.apply_migrations(db)
+ end
end
@@ -102,7 +102,6 @@ def run!
config = @config.dup
if run_migrations
- DB.apply_migrations(db)
populate_framework_and_runtimes
end
@@ -123,7 +122,6 @@ def run!
VCAP::CloudController.health_manager_respondent = VCAP::CloudController::HealthManagerRespondent.new(config)
map "/" do
- DB.apply_migrations(db) if (run_migrations && development?)
run VCAP::CloudController::Controller.new(config)
end
end

0 comments on commit ae12915

Please sign in to comment.