lib/beerdb/cli/main.rb in beerdb-0.7.2 vs lib/beerdb/cli/main.rb in beerdb-0.8.0

- old
+ new

@@ -54,21 +54,32 @@ command :create do |c| c.syntax = 'beerdb create [options]' c.description = 'Create DB schema' + + c.option '--extras', 'Extra tables (drinks,bookmarks,users)' + c.action do |args, options| LogUtils::Logger.root.level = :warn if options.quiet.present? LogUtils::Logger.root.level = :debug if options.verbose.present? myopts.merge_commander_options!( options.__hash__ ) connect_to_db( myopts ) - - LogDb.create - WorldDb.create - BeerDb.create + + if options.extras.present? + # quick hack: only create extra tables + BeerDb::CreateUsers.new.up + BeerDb::CreateBookmarks.new.up + BeerDb::CreateDrinks.new.up + else + LogDb.create + WorldDb.create + BeerDb.create + end + puts 'Done.' end # action end # command create command :setup do |c| @@ -173,9 +184,10 @@ connect_to_db( myopts ) # NB: server (HTTP service) not included in standard default require require 'beerdb/server' + ### fix: add ActiveRecord rack Middleware to close connection!! how? BeerDb::Server.run! puts 'Done.' end end # command load