Class: MultiCompress::DBDeployment::DictionaryRegistry
- Inherits:
-
Object
- Object
- MultiCompress::DBDeployment::DictionaryRegistry
- Defined in:
- lib/multi_compress/db_deployment.rb
Constant Summary collapse
- IDENTIFIER =
/\A[A-Za-z_][A-Za-z0-9_]*\z/.freeze
Instance Method Summary collapse
-
#initialize(target, options) ⇒ DictionaryRegistry
constructor
A new instance of DictionaryRegistry.
- #to_sql ⇒ Object
Constructor Details
#initialize(target, options) ⇒ DictionaryRegistry
Returns a new instance of DictionaryRegistry.
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 |
# File 'lib/multi_compress/db_deployment.rb', line 212 def initialize(target, ) @target = target @schema = identifier!(.fetch(:schema), target == "postgres" ? "--schema" : "--database") @table = identifier!(.fetch(:table), "--table") @heads_table = identifier!(.fetch(:heads_table), "--heads-table") @owner = [:owner] && identifier!([:owner], "--owner") @migration_role = [:migration_role] && identifier!([:migration_role], "--migration-role") @extension_schema = identifier!(.fetch(:extension_schema, "multi_compress"), "--extension-schema") @payload_table = [:payload_table] && identifier!([:payload_table], "--payload-table") @payload_column = [:payload_column] && identifier!([:payload_column], "--payload-column") @payload_dictionary_id_column = [:payload_dictionary_id_column] && identifier!([:payload_dictionary_id_column], "--payload-dictionary-id-column") = [@payload_table, @payload_column, @payload_dictionary_id_column] unless .all? || .none? raise Error, "--payload-table, --payload-column and --payload-dictionary-id-column must be used together" end if @target == "postgres" && (!@owner || !@migration_role) raise Error, "--owner and --migration-role are required for postgres registry DDL" end rescue KeyError raise Error, @target == "postgres" ? "--schema, --owner and --migration-role are required" : "--database is required" end |
Instance Method Details
#to_sql ⇒ Object
234 235 236 |
# File 'lib/multi_compress/db_deployment.rb', line 234 def to_sql @target == "postgres" ? postgres_sql : mysql_sql end |