jam-cloud/README

48 lines
2.0 KiB
Plaintext
Raw Normal View History

2012-07-29 15:09:49 +00:00
jam-db
======
2012-07-29 18:56:09 +00:00
Schema migrations for the jam-db database. Uses the [pg_migrate tool](https://github.com/sethcall/pg_migrate) tool. The github page of pg_migrate also has some documentation and rationale behind this approach of migrations.
2012-07-29 15:09:49 +00:00
Overview
--------
2012-07-29 18:56:09 +00:00
jam-db defines the migrations that comprise the jam-db database. It uses pg_migrate to package up the migrations iinto a gem or (TODO) jar. You can then use those packaged up versions of the schemas in downstream projects.
2012-07-29 15:09:49 +00:00
2012-07-29 18:56:09 +00:00
The main reason the 'pg_migrate' approach is taken is to make to possible to use the database like an interface, freed from any one project or language.
Environmenti
2012-07-29 15:09:49 +00:00
-----------
* [rvm](https://rvm.io/) with ruby 1.9.3 installed and activated. rvm needs to be activated in your shell (the installation process does this)
* bash . If on windows, use git bash or cygwin. Bash is used as the build script technology. (could change very easily)
2012-07-29 17:39:46 +00:00
* NOT YET: $IVY defined as path to the [apache ivy jar](http://ant.apache.org/ivy/download.cgi). Download the latest ivy from here, extract somewhere, and create an IVY environment variable with a path to the ivy.jar. For example, in my bash.profile: `export IVY=/Users/seth/workspace/apache-ivy-2.3.0-rc1/ivy-2.3.0-rc1.jar`
2012-07-29 15:09:49 +00:00
2012-07-29 17:39:46 +00:00
Building
--------
2012-07-29 18:56:09 +00:00
# one-time: if you just installed rvm, cd into this project's base directory. rvm will ask you to trust the .rvmrc. Do so.
# type:
./build # this will clean your 'target' directory, and rebuild from scratch. It takes seconds.
2012-07-29 17:39:46 +00:00
Using
-----
In a ruby project, create in your gemfile something like:
`
https 'https://rubygems.org'
gem 'jam_db', :path => '~/workspace/jam-db/target/ruby_package'
`
2012-07-29 18:56:09 +00:00
Then, to cause a migration, do something like:
# make sure you have the jam_db gem
bundle install
2012-07-29 15:09:49 +00:00
2012-07-29 18:56:09 +00:00
# migrate the database (assumes you've created the 'jam' database already).
bundle exec jam_db --connopts="dbname:jam host:localhost user:postgres password:postgres" --verbose
2012-07-29 15:09:49 +00:00
2012-07-29 18:56:09 +00:00
# you can see if it worked by typing:
2012-07-29 15:09:49 +00:00
2012-07-29 18:56:09 +00:00
psql jam
> select * from pgmigrate.pg_migrate;
2012-07-29 15:09:49 +00:00