lib/hanami/model/migrator/postgres_adapter.rb in hanami-model-0.7.0 vs lib/hanami/model/migrator/postgres_adapter.rb in hanami-model-1.0.0.beta1
- old
+ new
@@ -20,20 +20,23 @@
# @since 0.4.0
# @api private
PASSWORD = 'PGPASSWORD'.freeze
+ # @since 1.0.0.beta1
+ # @api private
+ DB_CREATION_ERROR = 'createdb: database creation failed. If the database exists, ' \
+ 'then its console may be open. See this issue for more details: ' \
+ 'https://github.com/hanami/model/issues/250'.freeze
+
# @since 0.4.0
# @api private
- def create # rubocop:disable Metrics/MethodLength
+ def create
set_environment_variables
call_db_command('createdb') do |error_message|
message = if error_message.match(/already exists/) # rubocop:disable Performance/RedundantMatch
- "createdb: database creation failed. If the database exists, \
- then its console may be open. See this issue for more details:\
- https://github.com/hanami/model/issues/250\
- "
+ DB_CREATION_ERROR
else
error_message
end
raise MigrationError.new(message)