refactor db create, move migrations into dev/test group

This commit is contained in:
carlad 2016-03-23 14:09:29 +01:00
parent f8bee8f801
commit dd82c14f5b
2 changed files with 9 additions and 13 deletions

View File

@ -11,7 +11,6 @@ gem 'travis-amqp', github: 'travis-ci/travis-amqp'
gem 'travis-config', '~> 0.1.0' gem 'travis-config', '~> 0.1.0'
gem 'travis-sidekiqs', github: 'travis-ci/travis-sidekiqs', require: nil gem 'travis-sidekiqs', github: 'travis-ci/travis-sidekiqs', require: nil
gem 'travis-yaml', github: 'travis-ci/travis-yaml' gem 'travis-yaml', github: 'travis-ci/travis-yaml'
gem 'travis-migrations', github: 'travis-ci/travis-migrations'
gem 'mustermann', github: 'rkh/mustermann' gem 'mustermann', github: 'rkh/mustermann'
gem 'sinatra' gem 'sinatra'
gem 'sinatra-contrib', require: nil #github: 'sinatra/sinatra-contrib', require: nil gem 'sinatra-contrib', require: nil #github: 'sinatra/sinatra-contrib', require: nil
@ -37,6 +36,10 @@ gem 'stackprof'
gem 'jemalloc' gem 'jemalloc'
gem 'customerio' gem 'customerio'
group :development, :test do
gem 'travis-migrations', github: 'travis-ci/travis-migrations'
end
group :test do group :test do
gem 'rspec', '~> 2.13' gem 'rspec', '~> 2.13'
gem 'rspec-its' gem 'rspec-its'

View File

@ -1,16 +1,9 @@
namespace :db do namespace :db do
if ENV["RAILS_ENV"] == 'test' env = ENV["RAILS_ENV"]
desc 'Create and migrate the test database' desc "Create and migrate the #{env} database"
task :create do task :create do
sh 'createdb travis_test' rescue nil sh "createdb travis_pro_#{env}" rescue nil
sh "psql -q travis_test < #{Gem.loaded_specs['travis-migrations'].full_gem_path}/db/structure.sql" sh "psql -q travis_pro_#{env} < #{Gem.loaded_specs['travis-migrations'].full_gem_path}/db/structure.sql"
end
else
desc 'Create and migrate the development database'
task :create do
sh 'createdb travis_development' rescue nil
sh "psql -q travis_development < #{Gem.loaded_specs['travis-migrations'].full_gem_path}/db/structure.sql"
end
end end
end end