Module: WatchTower::Server::Database
Instance Method Summary collapse
- #is_connected? ⇒ Boolean
- #is_migrated? ⇒ Boolean
-
#start!(options = {}) ⇒ Object
Start the database server.
-
#stop!(options = {}) ⇒ Object
Stop the database server.
Instance Method Details
#is_connected? ⇒ Boolean
46 47 48 |
# File 'lib/watch_tower/server/database.rb', line 46 def is_connected? ActiveRecord::Base.connected? end |
#is_migrated? ⇒ Boolean
50 51 52 53 |
# File 'lib/watch_tower/server/database.rb', line 50 def is_migrated? ActiveRecord::Migrator.current_version == ActiveRecord::Migrator.migrations(MIGRATIONS_PATH).last.version end |
#start!(options = {}) ⇒ Object
Start the database server
see #connect! see #migrate!
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/watch_tower/server/database.rb', line 15 def start!( = {}) LOG.debug("#{__FILE__}:#{__LINE__}: Starting the database server.") # Connect to the Database connect! # Migrate the database migrate! rescue DatabaseConfigNotFoundError raise ConfigNotFound, "Database configurations are missing, please edit #{Config.config_file} and try again." rescue ::ActiveRecord::ConnectionNotEstablished => e raise DatabaseError, "There was an error connecting to the database: #{error}" end |
#stop!(options = {}) ⇒ Object
Stop the database server
see #disconnect!
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/watch_tower/server/database.rb', line 35 def stop!( = {}) # Disconnect from the database disconnect! rescue DatabaseConfigNotFoundError raise ConfigNotFound, "Database configurations are missing, please edit #{Config.config_file} and try again." rescue ::ActiveRecord::ConnectionNotEstablished => e raise DatabaseError, "There was an error connecting to the database: #{error}" end |