redmine_plugins_helper 0.12.0 → 0.12.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 85bd7c23357b00ffca2152a68dadbc9419883bd1aa6e492f0a930aa9d8ddaa7c
4
- data.tar.gz: 8b1674506dec4c5fa5746cd97688605885844bd755902b727cac593e3643f46d
3
+ metadata.gz: 0f7d3b510c4a42d1c78bf2d850648ee579a8a3c24adff6a8ba6ba84b91bce6be
4
+ data.tar.gz: bf26964cb5d67e16accf2631477d1f89373c79781d23bff661a85762d3f99a50
5
5
  SHA512:
6
- metadata.gz: 1ad5db26a659560f2d424baccdd909b8aad0b3ea5ef9635bd1b983b2e584322506252999d9bf198e8cab19c063794117c9c62d4a3dbec8c71d32a4e7ad091550
7
- data.tar.gz: fcd2784212814f604140e735068ba3b7feed262d8538a78cde6692d078e34c24119ed72f468c010c5bd14240abdabe59e2673fb3a85f1b110e912b4f1f362c77
6
+ metadata.gz: cf2e3febe40f0d8246a905e0a1583d8cf68354309aa949dde4d6fdeced11a5b96dbdd65a85c9ede5ed1d9b381061f53455a2d4e116c91867fffa8528796311f7
7
+ data.tar.gz: c153f16bb325b0ab9356d110662727ab4e8f84e8d919b6acd4f53cf74d097ec3d7b57e12e159583dbe05681e42f1370f52a7605984d2cd694aafc9df5d84dec7
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Reference: https://stackoverflow.com/questions/62570662/rails-4-ruby-2-7-1-schema-rb-shows-could-not-dump-table-because-of-following-f
4
+
5
+ return unless RUBY_VERSION >= '2.7' && ::Rails.version < '5'
6
+
7
+ module ActiveRecord
8
+ module ConnectionAdapters
9
+ module ColumnDumper
10
+ def prepare_column_options(column, types) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
11
+ spec = {}
12
+ spec[:name] = column.name.inspect
13
+ spec[:type] = column.type.to_s
14
+ spec[:null] = 'false' unless column.null
15
+
16
+ limit = column.limit || types[column.type][:limit]
17
+ spec[:limit] = limit.inspect if limit
18
+ spec[:precision] = column.precision.inspect if column.precision
19
+ spec[:scale] = column.scale.inspect if column.scale
20
+
21
+ default = schema_default(column).dup if column.has_default?
22
+ spec[:default] = default unless default.nil?
23
+
24
+ spec
25
+ end
26
+ end
27
+ end
28
+ end
@@ -2,13 +2,7 @@
2
2
 
3
3
  module RedminePluginsHelper
4
4
  class FixMigrations
5
- def initialize
6
- run
7
- end
8
-
9
- private
10
-
11
- def run
5
+ def perform
12
6
  database_plugins_versions.each do |dbv|
13
7
  check_database_version(dbv)
14
8
  end
@@ -16,6 +10,8 @@ module RedminePluginsHelper
16
10
  Rails.logger.info("Local versions found: #{local_versions.count}")
17
11
  end
18
12
 
13
+ private
14
+
19
15
  def check_database_version(dbv)
20
16
  lv = local_version(dbv[:timestamp])
21
17
  return unless lv && lv.count == 1 && dbv[:plugin] != lv.first[:plugin]
@@ -43,8 +39,8 @@ module RedminePluginsHelper
43
39
 
44
40
  def move_plugin_version(source_version, target_version)
45
41
  Rails.logger.info("Moving #{source_version} to plugin \"#{target_version}\"")
46
- ::ActiveRecord::SchemaMigration.find_by(version: source_version)
47
- .update!(version: target_version)
42
+ ::ActiveRecord::SchemaMigration.where(version: source_version)
43
+ .update_all(version: target_version) # rubocop:disable Rails/SkipsModelValidations
48
44
  end
49
45
 
50
46
  def local_version(timestamp)
@@ -68,7 +64,9 @@ module RedminePluginsHelper
68
64
 
69
65
  def database_plugins_versions
70
66
  @database_plugins_versions ||= ::RedminePluginsHelper::Migration
71
- .from_database.select(&:plugin?).map(&:version)
67
+ .from_database.select(&:plugin?).map do |m|
68
+ { plugin: m.plugin_id, timestamp: m.version, version: m.database_version }
69
+ end
72
70
  end
73
71
 
74
72
  def plugin_version(plugin_id, timestamp)
@@ -3,5 +3,5 @@
3
3
  module RedminePluginsHelper
4
4
  AUTHOR = 'Eduardo Henrique Bogoni'
5
5
  SUMMARY = 'Helper for Redmine plugins'
6
- VERSION = '0.12.0'
6
+ VERSION = '0.12.1'
7
7
  end
@@ -42,7 +42,7 @@ namespace :redmine do
42
42
  namespace :migrate do
43
43
  desc 'Fix migrations moved from a plugin to another'
44
44
  task fix: :environment do
45
- RedminePluginsHelper::FixMigrations.new
45
+ ::RedminePluginsHelper::FixMigrations.new.perform
46
46
  end
47
47
 
48
48
  desc 'Show migrations status of all plugins'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redmine_plugins_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.0
4
+ version: 0.12.1
5
5
  platform: ruby
6
6
  authors:
7
- - 0.12.0
7
+ - 0.12.1
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-15 00:00:00.000000000 Z
11
+ date: 2022-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bigdecimal
@@ -110,6 +110,7 @@ files:
110
110
  - app/assets/stylesheets/plugins_autoload.scss.erb
111
111
  - config/initializers/assets.rb
112
112
  - config/initializers/backport_pg_10_support_to_rails_4.rb
113
+ - config/initializers/ruby_2_7_rails_4_column_dumper.rb
113
114
  - init.rb
114
115
  - lib/enumerator.rb
115
116
  - lib/redmine_plugins_helper.rb