Sha256: 193aa7ceda8b78e86eb90ce9195ed03706f2c2f3a8081ab091dccaf9ae3e3080

Contents?: true

Size: 1.36 KB

Versions: 3

Compression:

Stored size: 1.36 KB

Contents

#!/usr/bin/env ruby

require 'rubygems'
gem 'sequel', '~> 3.13.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 <<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.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

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
taps-0.3.11 bin/schema
dkastner-taps-0.3.11 bin/schema
taps-0.3.10 bin/schema