Sha256: f9ed39209e838ac5f11f8429fefb31e9c4dd02e0e4dadfe30fbc8c72daf5d57a

Contents?: true

Size: 1.36 KB

Versions: 7

Compression:

Stored size: 1.36 KB

Contents

#!/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 <<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

7 entries across 7 versions & 1 rubygems

Version Path
taps-0.3.6 bin/schema
taps-0.3.5 bin/schema
taps-0.3.4 bin/schema
taps-0.3.3 bin/schema
taps-0.3.2 bin/schema
taps-0.3.1 bin/schema
taps-0.3.0 bin/schema