add db creation and migration for development, update readme
This commit is contained in:
parent
079cec3467
commit
277562e51c
|
@ -7,7 +7,7 @@ This is the app running on https://api.travis-ci.org/
|
||||||
1. PostgreSQL 9.3 or higher
|
1. PostgreSQL 9.3 or higher
|
||||||
1. Redis
|
1. Redis
|
||||||
1. RabbitMQ
|
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
|
## Installation
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
|
18
Rakefile
18
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'
|
||||||
task :create do
|
desc 'Create and migrate the test database'
|
||||||
sh 'createdb travis_test' rescue nil
|
task :create do
|
||||||
sh 'mkdir spec/support/db'
|
sh 'createdb travis_test' rescue nil
|
||||||
sh "cp #{Gem.loaded_specs['travis-migrations'].full_gem_path}/db/structure.sql spec/support/db/structure.sql"
|
sh "psql -q travis_test < #{Gem.loaded_specs['travis-migrations'].full_gem_path}/db/structure.sql"
|
||||||
sh 'psql -q travis_test < spec/support/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
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user