add db creation and migration for development, update readme
This commit is contained in:
parent
079cec3467
commit
277562e51c
|
@ -17,8 +17,8 @@ This is the app running on https://api.travis-ci.org/
|
||||||
|
|
||||||
### Database setup
|
### Database setup
|
||||||
|
|
||||||
1. `rake db:create db:migrate`
|
1. `bundle exec rake db:create`
|
||||||
2. for testing 'RAILS_ENV=test bundle exec rake db:create db:migrate --trace'
|
2. for testing 'RAILS_ENV=test bundle exec rake db:create --trace'
|
||||||
1. Clone `travis-logs` and copy the `logs` database (assume the PostgreSQL user is `postgres`):
|
1. Clone `travis-logs` and copy the `logs` database (assume the PostgreSQL user is `postgres`):
|
||||||
```sh-session
|
```sh-session
|
||||||
cd ..
|
cd ..
|
||||||
|
@ -31,7 +31,7 @@ pg_dump -t logs travis_logs_development | psql -U postgres travis_development
|
||||||
|
|
||||||
Repeat the database steps for `RAILS_ENV=test`.
|
Repeat the database steps for `RAILS_ENV=test`.
|
||||||
```sh-session
|
```sh-session
|
||||||
RAILS_ENV=test rake db:create db:structure:load
|
RAILS_ENV=test bundle exec rake db:create
|
||||||
pushd ../travis-logs
|
pushd ../travis-logs
|
||||||
RAILS_ENV=test rvm jruby do bundle exec rake db:migrate
|
RAILS_ENV=test rvm jruby do bundle exec rake db:migrate
|
||||||
psql -c "DROP TABLE IF EXISTS logs CASCADE" -U postgres travis_test
|
psql -c "DROP TABLE IF EXISTS logs CASCADE" -U postgres travis_test
|
||||||
|
|
14
Rakefile
14
Rakefile
|
@ -4,12 +4,18 @@ require 'travis/migrations'
|
||||||
task default: :spec
|
task default: :spec
|
||||||
|
|
||||||
namespace :db do
|
namespace :db do
|
||||||
desc 'Create the test database'
|
if ENV["RAILS_ENV"] == 'test'
|
||||||
|
desc 'Create and migrate the test database'
|
||||||
task :create do
|
task :create do
|
||||||
sh 'createdb travis_test' rescue nil
|
sh 'createdb travis_test' rescue nil
|
||||||
sh 'mkdir spec/support/db'
|
sh "psql -q travis_test < #{Gem.loaded_specs['travis-migrations'].full_gem_path}/db/structure.sql"
|
||||||
sh "cp #{Gem.loaded_specs['travis-migrations'].full_gem_path}/db/structure.sql spec/support/db/structure.sql"
|
end
|
||||||
sh 'psql -q travis_test < spec/support/db/structure.sql'
|
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
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user