jam-cloud/db
Scott Comer b33206683b merged updates 2014-02-24 15:22:26 -06:00
..
up merged updates 2014-02-24 15:22:26 -06:00
.gitignore merging jam-db into db 2013-09-15 17:58:54 +00:00
.pg_migrate merging jam-db into db 2013-09-15 17:58:54 +00:00
.ruby-gemset merging jam-db into db 2013-09-15 17:58:54 +00:00
.ruby-version fix warning related to ruby- prefix in .ruby-version files 2013-12-27 16:28:28 -05:00
Gemfile * pg_migrate bump to 0.1.13 with relaxed thor version 2014-02-18 03:42:42 +00:00
Gemfile.lock * pg_migrate bump to 0.1.13 with relaxed thor version 2014-02-18 03:42:42 +00:00
README.md merging jam-db into db 2013-09-15 17:58:54 +00:00
build * intsall to vendor/bundle 2014-02-02 14:03:31 -06:00
jenkins * VRFS-1016 2014-01-31 14:25:17 -06:00
manifest merged updates 2014-02-24 15:22:26 -06:00

README.md

jam-db

Schema migrations for the jam-db database. Uses the pg_migrate tool tool. The github page of pg_migrate also has some documentation and rationale behind this approach of migrations.

Overview

am-db defines the migrations that comprise the jam-db database. It uses pg_migrate to package up the migrations into a gem or (TODO) jar. You can then use those packaged up versions of the schemas in downstream projects.

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.

Environment

  • rvm 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)
  • Definition of location for your developer workspace. Default is ~/workspace, but if you define an env variable, you can override.
  • pg_migrate_ruby - $ cd [workspace] && git clone https://github.com/sethcall/pg_migrate_ruby
  • The current logged in OS user has access to the 'postgres' database and is a super user in the database. In other words, you want to make sure your current logged in user can do the following at the command line: 'psql postgres'. If you can do that, you should be OK. There are two reasons this may not work for you.
  1. Your current user is not a superuser. If not, do sudo su postgres -c "createuser YOURUSER" and answer 'y' with the first question.
  2. If your user already is a superuser, then the postgres database may not exist yet. In that case, do psql then create database postgres
  • NOT YET: $IVY defined as path to the apache ivy jar. 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

Building

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.

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' ` Then, to cause a migration, do something like:

make sure you have the jam_db gem

bundle install

migrate the database (assumes you've created the 'jam' database already).

bundle exec jam_db up --connopts="dbname:jam host:localhost user:postgres password:postgres" --verbose

you can see if it worked by typing:

psql jam

select * from pgmigrate.pg_migrate;

If your database is screwed up, do this:

dropdb jam createdb jam migrate.sh

END