migration_tools 1.9.0 → 1.10.0

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: 6f478f9c844bb173b7694e644e031854615195974cb1166f64a58b621c7a27c7
4
- data.tar.gz: f4f43cee11b6d5667e31b0f1a2b4b59834c6a0cb78acb5d11400ee8115e7a5d6
3
+ metadata.gz: 2862f79e61fa0bab55c9049a392fb4d975e8ad0d70f5a620854b82088dfc2304
4
+ data.tar.gz: 3db8c3c265bed5358e8da27c4c8eb5570f265341144bf6327a4e5a85d99ad732
5
5
  SHA512:
6
- metadata.gz: 4d263af9575ac963f4d2e526fc0c02ba870f745ced953be1d44d8ab11cd3bb40c98b4e688c5e2196533e0116546be4d6c6f1d661853451ea0f8d5f2acb85e7a0
7
- data.tar.gz: 347b05bd236520fbe54330909648be9e82e90a663194439ab80d34ddf21f65a236f27b844cdc6638f09b37bb2061e6a2a98337c9fdcb32870a8e279120d57954
6
+ metadata.gz: 161c3458ae787335bb1e8e02c2e312f6a93acfc604b9da3f20cf96d74e4f3cbfd083dfc50ca78f4ceabe448bbc52fdc90341e5b8e73149e6fb5fa78aff341f0e
7
+ data.tar.gz: 87f8608c1ba2bd9fc3125fd081be959498eb68d3919fbb741c85727174b6837305e7104d739e3de067b2e9c073d7abef0c22614b8ebffd82ef63f017a23a541f
@@ -1,11 +1,10 @@
1
1
  module MigrationTools
2
2
  module MigrationExtension
3
-
4
3
  attr_accessor :migration_group
5
4
 
6
5
  def group(arg = nil)
7
6
  unless MigrationTools::MIGRATION_GROUPS.member?(arg.to_s)
8
- raise "Invalid group \"#{arg.to_s}\" - valid groups are #{MigrationTools::MIGRATION_GROUPS.inspect}"
7
+ raise "Invalid group \"#{arg}\" - valid groups are #{MigrationTools::MIGRATION_GROUPS.inspect}"
9
8
  end
10
9
 
11
10
  self.migration_group = arg.to_s
@@ -31,4 +30,4 @@ ActiveRecord::Migration.class_eval do
31
30
  self.class.migration_group
32
31
  end
33
32
  end
34
- ActiveRecord::MigrationProxy.delegate :migration_group, :to => :migration
33
+ ActiveRecord::MigrationProxy.delegate :migration_group, to: :migration
@@ -1,5 +1,5 @@
1
- require 'rake'
2
- require 'rake/tasklib'
1
+ require "rake"
2
+ require "rake/tasklib"
3
3
 
4
4
  module MigrationTools
5
5
  class Tasks < ::Rake::TaskLib
@@ -12,7 +12,7 @@ module MigrationTools
12
12
  def group
13
13
  return @group if defined?(@group) && @group
14
14
 
15
- @group = ENV['GROUP'].to_s
15
+ @group = ENV["GROUP"].to_s
16
16
  raise "Invalid group \"#{@group}\"" if !@group.empty? && !MIGRATION_GROUPS.member?(@group)
17
17
  @group
18
18
  end
@@ -20,7 +20,7 @@ module MigrationTools
20
20
  def group=(group)
21
21
  @group = nil
22
22
  @pending_migrations = nil
23
- ENV['GROUP'] = group
23
+ ENV["GROUP"] = group
24
24
  end
25
25
 
26
26
  def migrations_paths
@@ -28,34 +28,37 @@ module MigrationTools
28
28
  end
29
29
 
30
30
  def migrator(target_version = nil)
31
- if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 1
31
+ if ActiveRecord::VERSION::MAJOR == 7 && ActiveRecord::VERSION::MINOR == 1
32
32
  migrate_up(ActiveRecord::MigrationContext.new(
33
33
  migrations_paths,
34
34
  ActiveRecord::Base.connection.schema_migration
35
35
  ).migrations, target_version)
36
- elsif ActiveRecord::VERSION::MAJOR >= 6
36
+ elsif ActiveRecord.gem_version >= Gem::Version.new("7.2")
37
37
  migrate_up(ActiveRecord::MigrationContext.new(
38
38
  migrations_paths,
39
- ActiveRecord::SchemaMigration
39
+ ActiveRecord::Base.connection_pool.schema_migration
40
40
  ).migrations, target_version)
41
- elsif ActiveRecord::VERSION::MAJOR == 5 && ActiveRecord::VERSION::MINOR == 2
42
- migrate_up(ActiveRecord::MigrationContext.new(migrations_paths).migrations, target_version)
43
41
  else
44
- migrate_up(ActiveRecord::Migrator.migrations(migrations_paths), target_version)
42
+ migrate_up(ActiveRecord::MigrationContext.new(
43
+ migrations_paths,
44
+ ActiveRecord::SchemaMigration
45
+ ).migrations, target_version)
45
46
  end
46
47
  end
47
48
 
48
49
  def migrate_up(migrations, target_version)
49
- if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 1
50
+ if ActiveRecord::VERSION::MAJOR == 7 && ActiveRecord::VERSION::MINOR == 1
50
51
  ActiveRecord::Migrator.new(:up, migrations,
51
52
  ActiveRecord::Base.connection.schema_migration,
52
53
  ActiveRecord::Base.connection.internal_metadata,
53
- target_version
54
- )
55
- elsif ActiveRecord::VERSION::MAJOR >= 6
56
- ActiveRecord::Migrator.new(:up, migrations, ActiveRecord::SchemaMigration, target_version)
54
+ target_version)
55
+ elsif ActiveRecord.gem_version >= Gem::Version.new("7.2")
56
+ ActiveRecord::Migrator.new(:up, migrations,
57
+ ActiveRecord::Base.connection_pool.schema_migration,
58
+ ActiveRecord::Base.connection_pool.internal_metadata,
59
+ target_version)
57
60
  else
58
- ActiveRecord::Migrator.new(:up, migrations, target_version)
61
+ ActiveRecord::Migrator.new(:up, migrations, ActiveRecord::SchemaMigration, target_version)
59
62
  end
60
63
  end
61
64
 
@@ -70,14 +73,14 @@ module MigrationTools
70
73
  def define_migrate_list
71
74
  namespace :db do
72
75
  namespace :migrate do
73
- desc 'Lists pending migrations'
74
- task :list => :environment do
76
+ desc "Lists pending migrations"
77
+ task list: :environment do
75
78
  if pending_migrations.empty?
76
79
  notify "Your database schema is up to date", group
77
80
  else
78
81
  notify "You have #{pending_migrations.size} pending migrations", group
79
82
  pending_migrations.each do |migration|
80
- notify ' %4d %s %s' % [ migration.version, migration.migration_group.to_s[0..5].center(6), migration.name ]
83
+ notify " %4d %s %s" % [migration.version, migration.migration_group.to_s[0..5].center(6), migration.name]
81
84
  end
82
85
  end
83
86
  end
@@ -88,8 +91,8 @@ module MigrationTools
88
91
  def define_migrate_group
89
92
  namespace :db do
90
93
  namespace :migrate do
91
- desc 'Runs pending migrations for a given group'
92
- task :group => :environment do
94
+ desc "Runs pending migrations for a given group"
95
+ task group: :environment do
93
96
  if group.empty?
94
97
  notify "Please specify a migration group"
95
98
  elsif pending_migrations.empty?
@@ -100,10 +103,10 @@ module MigrationTools
100
103
  end
101
104
 
102
105
  schema_format = if ActiveRecord::VERSION::MAJOR >= 7
103
- ActiveRecord.schema_format
104
- else
105
- ActiveRecord::Base.schema_format
106
- end
106
+ ActiveRecord.schema_format
107
+ else
108
+ ActiveRecord::Base.schema_format
109
+ end
107
110
 
108
111
  Rake::Task["db:schema:dump"].invoke if schema_format == :ruby
109
112
  Rake::Task["db:structure:dump"].invoke if schema_format == :sql
@@ -116,10 +119,10 @@ module MigrationTools
116
119
  def define_convenience_tasks
117
120
  namespace :db do
118
121
  namespace :migrate do
119
- [ :list, :group ].each do |ns|
122
+ [:list, :group].each do |ns|
120
123
  namespace ns do
121
124
  MigrationTools::MIGRATION_GROUPS.each do |migration_group|
122
- desc "#{ns == :list ? 'Lists' : 'Executes' } the migrations for group #{migration_group}"
125
+ desc "#{(ns == :list) ? "Lists" : "Executes"} the migrations for group #{migration_group}"
123
126
  task migration_group => :environment do
124
127
  self.group = migration_group.to_s
125
128
  Rake::Task["db:migrate:#{ns}"].invoke
@@ -150,7 +153,7 @@ module MigrationTools
150
153
  if group.empty?
151
154
  puts string
152
155
  else
153
- puts string + " for group \""+group+"\""
156
+ puts "#{string} for group \"#{group}\""
154
157
  end
155
158
  end
156
159
  end
@@ -1,10 +1,10 @@
1
- require 'benchmark'
2
- require 'active_record'
3
- require 'active_record/migration'
4
- require 'active_support/core_ext/object/blank'
1
+ require "benchmark"
2
+ require "active_record"
3
+ require "active_record/migration"
4
+ require "active_support/core_ext/object/blank"
5
5
 
6
- require 'migration_tools/migration_extension'
7
- require 'migration_tools/tasks'
6
+ require "migration_tools/migration_extension"
7
+ require "migration_tools/tasks"
8
8
 
9
9
  module MigrationTools
10
10
  def self.forced?
@@ -15,5 +15,5 @@ module MigrationTools
15
15
  @forced = true
16
16
  end
17
17
 
18
- MIGRATION_GROUPS = [ 'before', 'during', 'after', 'change' ]
18
+ MIGRATION_GROUPS = ["before", "during", "after", "change"]
19
19
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: migration_tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.0
4
+ version: 1.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Morten Primdahl
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-28 00:00:00.000000000 Z
11
+ date: 2024-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -16,20 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 4.2.0
20
- - - "<"
21
- - !ruby/object:Gem::Version
22
- version: '7.2'
19
+ version: 6.0.0
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
24
  - - ">="
28
25
  - !ruby/object:Gem::Version
29
- version: 4.2.0
30
- - - "<"
31
- - !ruby/object:Gem::Version
32
- version: '7.2'
26
+ version: 6.0.0
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: rake
35
29
  requirement: !ruby/object:Gem::Requirement
@@ -114,6 +108,20 @@ dependencies:
114
108
  - - ">="
115
109
  - !ruby/object:Gem::Version
116
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: standard
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
117
125
  description: Rake tasks for Rails that add groups to migrations
118
126
  email: morten@zendesk.com
119
127
  executables: []
@@ -135,14 +143,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
135
143
  requirements:
136
144
  - - ">="
137
145
  - !ruby/object:Gem::Version
138
- version: 2.6.0
146
+ version: 2.7.0
139
147
  required_rubygems_version: !ruby/object:Gem::Requirement
140
148
  requirements:
141
149
  - - ">="
142
150
  - !ruby/object:Gem::Version
143
151
  version: '0'
144
152
  requirements: []
145
- rubygems_version: 3.0.3.1
153
+ rubygems_version: 3.5.11
146
154
  signing_key:
147
155
  specification_version: 4
148
156
  summary: Encourage migrations that do not require downtime