Class: Masamune::Helpers::Postgres
Instance Method Summary
collapse
#postgres_admin
#create_postgres_database_if_not_exists, #load_postgres_schema, #load_postgres_setup_files, #postgres
#define_schema
#define_table
#environment, #environment=
Constructor Details
#initialize(environment) ⇒ Postgres
Returns a new instance of Postgres.
32
33
34
35
|
# File 'lib/masamune/helpers/postgres.rb', line 32
def initialize(environment)
self.environment = environment
clear!
end
|
Instance Method Details
#clear! ⇒ Object
37
38
39
|
# File 'lib/masamune/helpers/postgres.rb', line 37
def clear!
@cache = {}
end
|
#database_exists? ⇒ Boolean
41
42
43
|
# File 'lib/masamune/helpers/postgres.rb', line 41
def database_exists?
@database_exists ||= postgres(exec: 'SELECT version();', fail_fast: false, max_retries: 0).success?
end
|
#table_exists?(table) ⇒ Boolean
45
46
47
48
|
# File 'lib/masamune/helpers/postgres.rb', line 45
def table_exists?(table)
return unless database_exists?
tables.include?(table)
end
|
#table_last_modified_at(table, options = {}) ⇒ Object
50
51
52
53
54
55
56
|
# File 'lib/masamune/helpers/postgres.rb', line 50
def table_last_modified_at(table, options = {})
column = options[:last_modified_at]
return unless column
return unless table_exists?(table)
update_table_last_modified_at(table, column)
@cache[table]
end
|
#tables ⇒ Object
58
59
60
61
|
# File 'lib/masamune/helpers/postgres.rb', line 58
def tables
update_tables
@cache.keys
end
|