Class: Tapsoob::CLI::Schema
- Inherits:
-
Thor
- Object
- Thor
- Tapsoob::CLI::Schema
- Defined in:
- lib/tapsoob/cli/schema.rb
Instance Method Summary collapse
- #console(database_url) ⇒ Object
- #dump(database_url) ⇒ Object
- #dump_table(database_url, table) ⇒ Object
- #foreign_keys(database_url) ⇒ Object
- #indexes(database_url) ⇒ Object
- #indexes_individual(database_url) ⇒ Object
- #load(database_url, filename = nil) ⇒ Object
- #load_foreign_keys(database_url, filename = nil) ⇒ Object
- #load_indexes(database_url, filename = nil) ⇒ Object
- #reset_db_sequences(database_url) ⇒ Object
Instance Method Details
#console(database_url) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/tapsoob/cli/schema.rb', line 10 def console(database_url) $db = Sequel.connect(database_url) require 'irb' ARGV.clear # otherwise all script parameters get passed to IRB IRB.start end |
#dump(database_url) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/tapsoob/cli/schema.rb', line 21 def dump(database_url) opts = {} opts[:indexes] = [:"indexes"] opts[:foreign_keys] = [:"foreign-keys"] opts[:same_db] = [:"same-db"] puts Tapsoob::Schema.dump(database_url, opts) end |
#dump_table(database_url, table) ⇒ Object
31 32 33 |
# File 'lib/tapsoob/cli/schema.rb', line 31 def dump_table(database_url, table) puts Tapsoob::Schema.dump_table(database_url, table) end |
#foreign_keys(database_url) ⇒ Object
36 37 38 |
# File 'lib/tapsoob/cli/schema.rb', line 36 def foreign_keys(database_url) puts Tapsoob::Schema.foreign_keys(database_url) end |
#indexes(database_url) ⇒ Object
41 42 43 |
# File 'lib/tapsoob/cli/schema.rb', line 41 def indexes(database_url) puts Tapsoob::Schema.indexes(database_url) end |
#indexes_individual(database_url) ⇒ Object
46 47 48 |
# File 'lib/tapsoob/cli/schema.rb', line 46 def indexes_individual(database_url) puts Tapsoob::Schema.indexes_individual(database_url) end |
#load(database_url, filename = nil) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/tapsoob/cli/schema.rb', line 57 def load(database_url, filename = nil) schema = if filename && File.exist?(filename) File.read(filename) else STDIN.read end begin Tapsoob::Schema.load(database_url, schema, ) rescue Exception => e throw e end end |
#load_foreign_keys(database_url, filename = nil) ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/tapsoob/cli/schema.rb', line 72 def load_foreign_keys(database_url, filename = nil) indexes = if filename && File.exist?(filename) File.read(filename) else STDIN.read end begin Tapsoob::Schema.load_foreign_keys(database_url, indexes) rescue Exception => e throw e end end |
#load_indexes(database_url, filename = nil) ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/tapsoob/cli/schema.rb', line 87 def load_indexes(database_url, filename = nil) indexes = if filename && File.exist?(filename) File.read(filename) else STDIN.read end begin Tapsoob::Schema.load_indexes(database_url, indexes) rescue Exception => e throw e end end |
#reset_db_sequences(database_url) ⇒ Object
51 52 53 |
# File 'lib/tapsoob/cli/schema.rb', line 51 def reset_db_sequences(database_url) Tapsoob::Schema.reset_db_sequences(database_url) end |