Go to file
Seth Call 080ba4fef7 * VRFS-259: beta signup 2013-03-14 23:22:00 -05:00
up * VRFS-259: beta signup 2013-03-14 23:22:00 -05:00
.gitignore * fixing up gitignore 2013-01-26 19:24:20 -06:00
.pg_migrate Point at 127.0.0.1 to avoid unix sockets 2012-11-17 13:39:24 -06:00
.rvmrc * p327 2012-12-06 06:47:36 -06:00
Gemfile *VRFS-277 jam-db package for debian 2013-01-22 02:36:24 +00:00
Gemfile.lock * oops. meant to make fpm optional but messed up the check for $PACKAGE 2013-01-26 19:23:26 -06:00
README.md minor readme change 2012-11-15 01:31:18 -08:00
build * oops. meant to make fpm optional but messed up the check for $PACKAGE 2013-01-26 19:23:26 -06:00
jenkins *VRFS-277 jam-db package for debian 2013-01-22 02:36:24 +00:00
manifest * VRFS-259: beta signup 2013-03-14 23:21:53 -05: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