#!/usr/bin/env ruby require 'rubygems' gem 'activerecord', '= 2.2.2' require File.dirname(__FILE__) + '/../lib/taps/schema' cmd = ARGV.shift.strip rescue '' database_url = ARGV.shift.strip rescue '' def show_usage_and_exit puts < schema indexes schema reset_db_sequences schema load schema load_indexes EOTXT exit(1) end if cmd == 'dump' puts Taps::Schema.dump_without_indexes(database_url) elsif cmd == 'indexes' puts Taps::Schema.indexes(database_url) elsif cmd == 'load_indexes' filename = ARGV.shift.strip rescue '' indexes = File.read(filename) rescue show_usage_and_exit Taps::Schema.load_indexes(database_url, indexes) elsif cmd == 'load' filename = ARGV.shift.strip rescue '' schema = File.read(filename) rescue show_usage_and_exit Taps::Schema.load(database_url, schema) elsif cmd == 'reset_db_sequences' Taps::Schema.reset_db_sequences(database_url) else show_usage_and_exit end