Class: OpalORM::DatabaseManager
- Inherits:
-
Thor
- Object
- Thor
- OpalORM::DatabaseManager
- Defined in:
- lib/opal_orm/cli.rb
Instance Method Summary collapse
Instance Method Details
#generate(file_name, *table_names) ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/opal_orm/cli.rb', line 37 def generate(file_name, *table_names) OpalORM::SchemaManager.generate(file_name, *table_names) rescue FileExistsError => e puts e. puts "Aborting." rescue ForeignKeyMissingError => e puts e. puts "Aborting." end |
#new(db_name) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/opal_orm/cli.rb', line 14 def new(db_name) Util.ensure_db_dir name_with_ext = "#{db_name}.db" db_file_path = File.join(Util.db_path, name_with_ext) puts "Creating db/#{name_with_ext} ..." DBConnection.open(db_file_path) if File.exist?(db_file_path) Util.ensure_db_dir puts Util.db_path Util.save_config({db_name: name_with_ext}) puts "#{name_with_ext} successfully created." end end |