add db creation and migration for development, update readme
This commit is contained in:
parent
6ab0ec3c3a
commit
64f97a89d2
|
@ -7,7 +7,7 @@ This is the app running on https://api.travis-ci.org/
|
|||
1. PostgreSQL 9.3 or higher
|
||||
1. Redis
|
||||
1. RabbitMQ
|
||||
1. Nginx *NB: If working on Ubuntu please install Nginx manually from source. [This guide](http://www.rackspace.com/knowledge_center/article/ubuntu-and-debian-installing-nginx-from-source) is helpful but make sure you install the [latest stable version](https://www.nginx.com/resources/wiki/start/topics/tutorials/install/#stable), include the user name on your ubuntu machine when compiling (add `--user=[yourusername]` as an option when running `./configure`), and don't follow any subsequent server configuration steps. Travis-api will start and configure its own nginx server when run locally.
|
||||
1. Nginx *NB: If working on Ubuntu please install Nginx manually from source. [This guide](http://www.rackspace.com/knowledge_center/article/ubuntu-and-debian-installing-nginx-from-source) is helpful but make sure you install the [latest stable version](https://www.nginx.com/resources/wiki/start/topics/tutorials/install/#stable), include the user name on your ubuntu machine when compiling (add `--user=[yourusername]` as an option when running `./configure`), and don't follow any subsequent server configuration steps. Travis-api will start and configure its own nginx server when run locally.
|
||||
|
||||
## Installation
|
||||
|
||||
|
@ -17,8 +17,8 @@ This is the app running on https://api.travis-ci.org/
|
|||
|
||||
### Database setup
|
||||
|
||||
1. `rake db:create db:migrate`
|
||||
2. for testing 'RAILS_ENV=test bundle exec rake db:create db:migrate --trace'
|
||||
1. `bundle exec rake db:create`
|
||||
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`):
|
||||
```sh-session
|
||||
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`.
|
||||
```sh-session
|
||||
RAILS_ENV=test rake db:create db:structure:load
|
||||
RAILS_ENV=test bundle exec rake db:create
|
||||
pushd ../travis-logs
|
||||
RAILS_ENV=test rvm jruby do bundle exec rake db:migrate
|
||||
psql -c "DROP TABLE IF EXISTS logs CASCADE" -U postgres travis_test
|
||||
|
|
18
Rakefile
18
Rakefile
|
@ -4,12 +4,18 @@ require 'travis/migrations'
|
|||
task default: :spec
|
||||
|
||||
namespace :db do
|
||||
desc 'Create the test database'
|
||||
task :create do
|
||||
sh 'createdb travis_test' rescue nil
|
||||
sh 'mkdir spec/support/db'
|
||||
sh "cp #{Gem.loaded_specs['travis-migrations'].full_gem_path}/db/structure.sql spec/support/db/structure.sql"
|
||||
sh 'psql -q travis_test < spec/support/db/structure.sql'
|
||||
if ENV["RAILS_ENV"] == 'test'
|
||||
desc 'Create and migrate the test database'
|
||||
task :create do
|
||||
sh 'createdb travis_test' rescue nil
|
||||
sh "psql -q travis_test < #{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
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user