class OpalORM::DatabaseManager

Public Instance Methods

generate(file_name, *table_names) click to toggle source
# 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.message
  puts "Aborting."
rescue ForeignKeyMissingError => e
  puts e.message
  puts "Aborting."
end
new(db_name) click to toggle source
# 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