Sha256: f615d1b5ae2874ea75507e61a2f7c3c50ccae234737eaa6e875dbf8a9e2682d2
Contents?: true
Size: 1.43 KB
Versions: 13
Compression:
Stored size: 1.43 KB
Contents
# :nocov: # rubocop:todo Metrics/BlockLength Hanami.app.register_provider :persistence, namespace: true do prepare do require "rom-changeset" require "rom/core" require "rom/sql" Sequel::Database.extension :constant_sql_override, :pg_enum Sequel.database_timezone = :utc Sequel.application_timezone = :local configuration = ROM::Configuration.new :sql, target["settings"].database_url configuration.plugin :sql, relations: :instrumentation do |plugin_config| plugin_config.notifications = target["notifications"] end configuration.plugin :sql, relations: :auto_restrictions database = configuration.gateways[:default].connection database.set_constant_sql Sequel::CURRENT_TIMESTAMP, "(CURRENT_TIMESTAMP AT TIME ZONE 'UTC')" register "config", configuration register "db", database Sequel::Migrator.is_current? database, Hanami.app.root.join("db/migrate") rescue NoMethodError, Sequel::Migrator::Error => error message = error.message Hanami.logger.error message unless error.is_a?(NoMethodError) && message.include?("migration") end start do configuration = target["persistence.config"] configuration.auto_registration( target.root.join("lib/<%= settings.project_path %>/persistence"), namespace: "<%= settings.project_namespaced_class %>::Persistence" ) register "rom", ROM.container(configuration) end end # rubocop:enable Metrics/BlockLength
Version data entries
13 entries across 13 versions & 1 rubygems