Class: Proxy::ContainerGateway::Database
- Inherits:
-
Object
- Object
- Proxy::ContainerGateway::Database
- Defined in:
- lib/smart_proxy_container_gateway/database.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
Instance Method Summary collapse
-
#initialize(connection_string, prior_sqlite_db_path = nil) ⇒ Database
constructor
A new instance of Database.
Constructor Details
#initialize(connection_string, prior_sqlite_db_path = nil) ⇒ Database
Returns a new instance of Database.
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/smart_proxy_container_gateway/database.rb', line 7 def initialize(connection_string, prior_sqlite_db_path = nil) Sequel.default_timezone = :local @connection = Sequel.connect(connection_string) if connection_string.start_with?('sqlite://') @connection.run("PRAGMA foreign_keys = ON;") @connection.run("PRAGMA journal_mode = wal;") elsif prior_sqlite_db_path && File.exist?(prior_sqlite_db_path) && (!@connection.table_exists?(:repositories) || @connection[:repositories].count.zero?) migrate_to_postgres(Sequel.sqlite(prior_sqlite_db_path), @connection) File.delete(prior_sqlite_db_path) end migrate end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
5 6 7 |
# File 'lib/smart_proxy_container_gateway/database.rb', line 5 def connection @connection end |