Class: DynamicMigrations::Postgres::Server::Database
- Inherits:
-
Object
- Object
- DynamicMigrations::Postgres::Server::Database
- Includes:
- ConfiguredExtensions, ConfiguredSchemas, Connection, EnumsLoader, ExtensionsLoader, KeysAndUniqueConstraintsLoader, LoadedExtensions, LoadedSchemas, LoadedSchemasBuilder, StructureLoader, TriggersAndFunctionsLoader, ValidationsLoader
- Defined in:
- lib/dynamic_migrations/postgres/server/database.rb,
lib/dynamic_migrations/postgres/server/database/schema.rb,
lib/dynamic_migrations/postgres/server/database/source.rb,
lib/dynamic_migrations/postgres/server/database/connection.rb,
lib/dynamic_migrations/postgres/server/database/differences.rb,
lib/dynamic_migrations/postgres/server/database/schema/enum.rb,
lib/dynamic_migrations/postgres/server/database/enums_loader.rb,
lib/dynamic_migrations/postgres/server/database/schema/enums.rb,
lib/dynamic_migrations/postgres/server/database/schema/table.rb,
lib/dynamic_migrations/postgres/server/database/schema/tables.rb,
lib/dynamic_migrations/postgres/server/database/loaded_schemas.rb,
lib/dynamic_migrations/postgres/server/database/schema/function.rb,
lib/dynamic_migrations/postgres/server/database/schema/functions.rb,
lib/dynamic_migrations/postgres/server/database/structure_loader.rb,
lib/dynamic_migrations/postgres/server/database/extensions_loader.rb,
lib/dynamic_migrations/postgres/server/database/loaded_extensions.rb,
lib/dynamic_migrations/postgres/server/database/configured_schemas.rb,
lib/dynamic_migrations/postgres/server/database/schema/table/index.rb,
lib/dynamic_migrations/postgres/server/database/validations_loader.rb,
lib/dynamic_migrations/postgres/server/database/schema/table/column.rb,
lib/dynamic_migrations/postgres/server/database/schema/table/columns.rb,
lib/dynamic_migrations/postgres/server/database/schema/table/indexes.rb,
lib/dynamic_migrations/postgres/server/database/schema/table/trigger.rb,
lib/dynamic_migrations/postgres/server/database/configured_extensions.rb,
lib/dynamic_migrations/postgres/server/database/schema/table/triggers.rb,
lib/dynamic_migrations/postgres/server/database/loaded_schemas_builder.rb,
lib/dynamic_migrations/postgres/server/database/schema/table/validation.rb,
lib/dynamic_migrations/postgres/server/database/schema/table/primary_key.rb,
lib/dynamic_migrations/postgres/server/database/schema/table/validations.rb,
lib/dynamic_migrations/postgres/server/database/differences/to_migrations.rb,
lib/dynamic_migrations/postgres/server/database/triggers_and_functions_loader.rb,
lib/dynamic_migrations/postgres/server/database/schema/table/unique_constraint.rb,
lib/dynamic_migrations/postgres/server/database/schema/table/unique_constraints.rb,
lib/dynamic_migrations/postgres/server/database/differences/to_migrations/schemas.rb,
lib/dynamic_migrations/postgres/server/database/keys_and_unique_constraints_loader.rb,
lib/dynamic_migrations/postgres/server/database/schema/table/foreign_key_constraint.rb,
lib/dynamic_migrations/postgres/server/database/differences/to_migrations/extensions.rb,
lib/dynamic_migrations/postgres/server/database/schema/table/foreign_key_constraints.rb,
lib/dynamic_migrations/postgres/server/database/differences/to_migrations/schemas/enums.rb,
lib/dynamic_migrations/postgres/server/database/differences/to_migrations/schemas/tables.rb,
lib/dynamic_migrations/postgres/server/database/differences/to_migrations/schemas/functions.rb,
lib/dynamic_migrations/postgres/server/database/differences/to_migrations/schemas/tables/columns.rb,
lib/dynamic_migrations/postgres/server/database/differences/to_migrations/schemas/tables/indexes.rb,
lib/dynamic_migrations/postgres/server/database/differences/to_migrations/schemas/tables/triggers.rb,
lib/dynamic_migrations/postgres/server/database/differences/to_migrations/schemas/tables/primary_key.rb,
lib/dynamic_migrations/postgres/server/database/differences/to_migrations/schemas/tables/validations.rb,
lib/dynamic_migrations/postgres/server/database/differences/to_migrations/schemas/tables/unique_constraints.rb,
lib/dynamic_migrations/postgres/server/database/differences/to_migrations/schemas/tables/foreign_key_constraints.rb
Overview
This class represents a postgres database. A database can contain many different schemas.
Defined Under Namespace
Modules: ConfiguredExtensions, ConfiguredSchemas, Connection, EnumsLoader, ExtensionsLoader, KeysAndUniqueConstraintsLoader, LoadedExtensions, LoadedSchemas, LoadedSchemasBuilder, StructureLoader, TriggersAndFunctionsLoader, ValidationsLoader Classes: Differences, ExpectedServerError, Schema, Source
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
Instance Method Summary collapse
- #differences ⇒ Object
-
#initialize(server, name) ⇒ Database
constructor
initialize a new object to represent a postgres database.
- #refresh_caches ⇒ Object
-
#schema(schema_name, source) ⇒ Object
if
sourceis :configuration then returns the configured schema with the provided name, ifsourceis :database then returns the loaded schema with the provided name, errors are raised if the requested schema does not exist or an unexpectedsourcevalue is provided.
Methods included from ExtensionsLoader
Methods included from EnumsLoader
Methods included from LoadedExtensions
#add_loaded_extension, #has_loaded_extension?, #loaded_extensions
Methods included from ConfiguredExtensions
#add_configured_extension, #configured_extensions, #has_configured_extension?
Methods included from LoadedSchemasBuilder
#recursively_load_database_structure
Methods included from ConfiguredSchemas
#add_configured_schema, #configured_schema, #configured_schemas, #configured_schemas_hash, #has_configured_schema?
Methods included from LoadedSchemas
#add_loaded_schema, #has_loaded_schema?, #loaded_schema, #loaded_schemas, #loaded_schemas_hash
Methods included from TriggersAndFunctionsLoader
Methods included from KeysAndUniqueConstraintsLoader
#create_database_keys_and_unique_constraints_cache, #fetch_keys_and_unique_constraints, #refresh_database_keys_and_unique_constraints_cache
Methods included from ValidationsLoader
#create_database_validations_cache, #fetch_validations, #refresh_database_validations_cache
Methods included from StructureLoader
#create_database_structure_cache, #fetch_schema_names, #fetch_structure, #fetch_table_names, #refresh_database_structure_cache
Methods included from Connection
#connect, #connected?, #connection, #disconnect, #with_connection
Constructor Details
#initialize(server, name) ⇒ Database
initialize a new object to represent a postgres database
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/dynamic_migrations/postgres/server/database.rb', line 29 def initialize server, name raise ExpectedServerError, server unless server.is_a? Server raise ExpectedSymbolError, name unless name.is_a? Symbol @server = server @name = name @configured_schemas = {} @loaded_schemas = {} @configured_extensions = {} @loaded_extensions = {} end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
26 27 28 |
# File 'lib/dynamic_migrations/postgres/server/database.rb', line 26 def name @name end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
25 26 27 |
# File 'lib/dynamic_migrations/postgres/server/database.rb', line 25 def server @server end |
Instance Method Details
#differences ⇒ Object
55 56 57 |
# File 'lib/dynamic_migrations/postgres/server/database.rb', line 55 def differences Differences.new(self) end |
#refresh_caches ⇒ Object
59 60 61 62 63 |
# File 'lib/dynamic_migrations/postgres/server/database.rb', line 59 def refresh_caches refresh_database_structure_cache refresh_database_keys_and_unique_constraints_cache refresh_database_validations_cache end |
#schema(schema_name, source) ⇒ Object
if source is :configuration then returns the configured schema with the provided name, if source is :database then returns the loaded schema with the provided name, errors are raised if the requested schema does not exist or an unexpected source value is provided
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/dynamic_migrations/postgres/server/database.rb', line 44 def schema schema_name, source case source when :configuration configured_schema schema_name when :database loaded_schema schema_name else raise InvalidSourceError, source end end |