#!/usr/bin/env ruby require 'rubygems' gem 'sequel', '~> 3.10.0' $:.unshift File.dirname(__FILE__) + '/../lib' require 'taps/schema' cmd = ARGV.shift.strip rescue '' database_url = ARGV.shift.strip rescue '' def show_usage_and_exit puts < schema dump schema dump_table schema indexes schema indexes_individual schema reset_db_sequences schema load schema load_indexes EOTXT exit(1) end case cmd when 'dump' puts Taps::Schema.dump(database_url) when 'dump_table' table = ARGV.shift.strip puts Taps::Schema.dump_table(database_url, table) when 'indexes' puts Taps::Schema.indexes(database_url) when 'indexes_individual' puts Taps::Schema.indexes_individual(database_url) when 'load_indexes' filename = ARGV.shift.strip rescue '' indexes = File.read(filename) rescue show_usage_and_exit Taps::Schema.load_indexes(database_url, indexes) when 'load' filename = ARGV.shift.strip rescue '' schema = File.read(filename) rescue show_usage_and_exit Taps::Schema.load(database_url, schema) when 'reset_db_sequences' Taps::Schema.reset_db_sequences(database_url) when 'console' $db = Sequel.connect(database_url) require 'irb' require 'irb/completion' IRB.start else show_usage_and_exit end