umbrellio-sequel-plugins 0.14.0.189 → 0.15.0.198

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b688c9d1ddd0f922dd1693468f55753e7da46870ccce5e10d3469fde44f5be3e
4
- data.tar.gz: 2ded32d88f5f3a9cbaec17a23d8a38b5352fbe70a3f9262f716e3f3a9000b369
3
+ metadata.gz: b159522b1cb01dea723411ba97da921347c22c98999f23da63df0c1a0a205154
4
+ data.tar.gz: 7bd434016e9d2e5aa93a271e7540f88cee8b2943575739b79a8491a653bcb0c4
5
5
  SHA512:
6
- metadata.gz: 640c600487ea05fe25f00b9f36ac8ab40c695886e814b2b5a6f449d4d905391a64480b073addc96523b602ee1140060524187a7a428d60615e53da603db89641
7
- data.tar.gz: be83d96ec8c3cd7bb635b6e349502e83485f9de0ade3d217f65c8efca80b01241efd2ed4b3f34cb23b022b8bae37669df35b1957622772cb1defee1078229fb8
6
+ metadata.gz: e37d16419fd9356d677ee852013947061f3749b3e117fcd7c897b62f2b8dcbd65d0dc4517bde5c87bb781d34780556f899199eaa6dd618d4a2ebc93e1ff56155
7
+ data.tar.gz: 610c27188c8fe14536e143b181455d8a558acd48c7e3b99b6699c61ef26601ea0d264493d50aa75ffc7e38991c225f4e2181eac91c0300b71f56357f4852acb5
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- umbrellio-sequel-plugins (0.14.0)
4
+ umbrellio-sequel-plugins (0.15.0)
5
5
  sequel
6
6
  symbiont-ruby
7
7
 
@@ -20,7 +20,7 @@ namespace :sequel do
20
20
  missing_migrations = applied_migrations - filesystem_migrations
21
21
 
22
22
  if missing_migrations.any?
23
- missing_migrations.each do |migration|
23
+ missing_migrations.sort.reverse_each do |migration|
24
24
  DB.log_info("Rolling back migration #{migration}...")
25
25
  migrator.undo(migration)
26
26
  end
@@ -9,45 +9,86 @@ class Rails::Command::DbconsoleCommand < Rails::Command::Base
9
9
  def perform
10
10
  require "rake"
11
11
  Rake.with_application(&:load_rakefile) # Needed to initialize Rails.application
12
- Rails::DBConsole.start(options)
12
+ start!
13
13
  end
14
- end
15
-
16
- class Rails::DBConsole
17
- DBConfig = Struct.new(:configuration_hash, :adapter, :database)
18
14
 
19
15
  private
20
16
 
21
- def db_config
22
- @db_config ||= DBConfig.new(configuration_hash, adapter, database)
17
+ # See ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.dbconsole
18
+ def start!
19
+ ENV["PGUSER"] = pg_config[:username] if pg_config[:username]
20
+ ENV["PGHOST"] = pg_config[:host] if pg_config[:host]
21
+ ENV["PGPORT"] = pg_config[:port].to_s if pg_config[:port]
22
+
23
+ if pg_config[:password] && options[:include_password]
24
+ ENV["PGPASSWORD"] = pg_config[:password].to_s
25
+ end
26
+
27
+ ENV["PGSSLMODE"] = pg_config[:sslmode].to_s if pg_config[:sslmode]
28
+ ENV["PGSSLCERT"] = pg_config[:sslcert].to_s if pg_config[:sslcert]
29
+ ENV["PGSSLKEY"] = pg_config[:sslkey].to_s if pg_config[:sslkey]
30
+ ENV["PGSSLROOTCERT"] = pg_config[:sslrootcert].to_s if pg_config[:sslrootcert]
31
+
32
+ if pg_config[:variables]
33
+ ENV["PGOPTIONS"] = pg_config[:variables].filter_map do |name, value|
34
+ "-c #{name}=#{value.to_s.gsub(/[ \\]/, '\\\\\0')}" unless value.in?([":default", :default])
35
+ end.join(" ")
36
+ end
37
+
38
+ find_cmd_and_exec("psql", database)
23
39
  end
24
40
 
25
- def configuration_hash
26
- return @configuration_hash if defined?(@configuration_hash)
41
+ def pg_config
42
+ @pg_config ||= begin
43
+ rails_db_config = Rails.application.config.database_configuration
27
44
 
28
- rails_db_config = Rails.application.config.database_configuration
45
+ sequel_configuration = SequelRails::Configuration.new
46
+ SequelRails.configuration = sequel_configuration.merge!(raw: rails_db_config)
29
47
 
30
- sequel_configuration = SequelRails::Configuration.new
31
- SequelRails.configuration = sequel_configuration.merge!(raw: rails_db_config)
48
+ storage = SequelRails::Storage.adapter_for(Rails.env)
49
+ config = storage.config.with_indifferent_access
32
50
 
33
- storage = SequelRails::Storage.adapter_for(Rails.env)
34
- config = storage.config.with_indifferent_access
51
+ if @options[:server]
52
+ server_config = config.fetch(:servers).fetch(@options[:server])
53
+ config.merge!(server_config)
54
+ end
35
55
 
36
- if @options[:server]
37
- server_config = config.fetch(:servers).fetch(@options[:server])
38
- config.merge!(server_config)
56
+ config
39
57
  end
40
-
41
- @configuration_hash = config
42
58
  end
43
59
 
44
- def adapter
45
- mapping = SequelRails::DbConfig::ADAPTER_MAPPING.invert
46
- value = configuration_hash.fetch(:adapter)
47
- mapping[value] || value
60
+ # See ActiveRecord::ConnectionAdapters::AbstractAdapter.find_cmd_and_exec
61
+ def find_cmd_and_exec(commands, *args) # rubocop:disable Metrics/MethodLength
62
+ commands = Array(commands)
63
+
64
+ dirs_on_path = ENV["PATH"].to_s.split(File::PATH_SEPARATOR)
65
+ unless (ext = RbConfig::CONFIG["EXEEXT"]).empty?
66
+ commands = commands.map { |cmd| "#{cmd}#{ext}" }
67
+ end
68
+
69
+ full_path_command = nil
70
+ found = commands.detect do |cmd|
71
+ dirs_on_path.detect do |path|
72
+ full_path_command = File.join(path, cmd)
73
+ begin
74
+ stat = File.stat(full_path_command)
75
+ rescue SystemCallError
76
+ else
77
+ stat.file? && stat.executable?
78
+ end
79
+ end
80
+ end
81
+
82
+ if found
83
+ exec(*[full_path_command, *args].compact)
84
+ else
85
+ abort(
86
+ "Couldn't find database client: #{commands.join(', ')}. Check your $PATH and try again.",
87
+ )
88
+ end
48
89
  end
49
90
 
50
91
  def database
51
- @options[:database] || configuration_hash.fetch(:database)
92
+ options[:database] || pg_config.fetch(:database)
52
93
  end
53
94
  end
@@ -4,7 +4,7 @@ lib = File.expand_path("lib", __dir__)
4
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- gem_version = "0.14.0"
7
+ gem_version = "0.15.0"
8
8
 
9
9
  if ENV.fetch("PUBLISH_JOB", nil)
10
10
  release_version = "#{gem_version}.#{ENV.fetch("GITHUB_RUN_NUMBER")}"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: umbrellio-sequel-plugins
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.0.189
4
+ version: 0.15.0.198
5
5
  platform: ruby
6
6
  authors:
7
7
  - Team Umbrellio
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-10 00:00:00.000000000 Z
11
+ date: 2024-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sequel