Sha256: da6d30e0494a0fcb4b322e7ef5f5bee182f5533d8dc90494aa0d54f405773acc

Contents?: true

Size: 1.57 KB

Versions: 5

Compression:

Stored size: 1.57 KB

Contents

#!/usr/bin/env ruby

require 'rubygems'
require_relative '../lib/taps/version'

gem 'sequel', Taps::Version.sequel_version

$LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'

require 'taps/schema'

cmd = ARGV.shift.to_s.strip
database_url = ARGV.shift.to_s.strip

def show_usage_and_exit
  puts <<EOTXT
  schema console <database_url>
  schema dump <database_url>
  schema dump_table <database_url> <table>
  schema indexes <database_url>
  schema indexes_individual <database_url>
  schema reset_db_sequences <database_url>
  schema load <database_url> <schema_file>
  schema load_indexes <database_url> <indexes_file>
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.to_s.strip
  indexes = begin
              File.read(filename)
            rescue StandardError
              show_usage_and_exit
            end
  Taps::Schema.load_indexes(database_url, indexes)
when 'load'
  filename = ARGV.shift.to_s.strip
  schema = begin
             File.read(filename)
           rescue StandardError
             show_usage_and_exit
           end
  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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
taps2-0.6.10 bin/schema2
taps2-0.6.9 bin/schema2
taps2-0.6.8 bin/schema2
taps2-0.6.7 bin/schema2
taps2-0.6.6 bin/schema2