data_migrate 11.2.0 → 11.3.1
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 +4 -4
 - data/Changelog.md +10 -1
 - data/README.md +10 -7
 - data/lib/data_migrate/config.rb +2 -2
 - data/lib/data_migrate/data_migrator.rb +0 -1
 - data/lib/data_migrate/data_schema_migration.rb +2 -2
 - data/lib/data_migrate/database_tasks.rb +11 -3
 - data/lib/data_migrate/schema_dumper.rb +8 -1
 - data/lib/data_migrate/version.rb +1 -1
 - metadata +5 -5
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 7bef47d5608c410a0158dfd4847c065895db273e0809f8467f3cae2e4d428604
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 5f1221a6c8fa70c5d095790892877e1aee369c3a06f2e145ec87534e06993065
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 3df1a19a487efc065928f135dc8e372e282d300956b2172d654247d9f6bbc3edbfff279e309b1d557093e7ef44ba49217de9dbfd7d58f75c96d6e91be83fd3ec
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 524ed4970e8f98a761d6b845b7d1d9be23015599be203e4aed2fb7fda68fe16b84a9dbcb29e68746de6d73559a2de584bad35307a1d60d134c8411b9f07fd75c
         
     | 
    
        data/Changelog.md
    CHANGED
    
    | 
         @@ -1,7 +1,16 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # Changelog
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
            # 11. 
     | 
| 
      
 3 
     | 
    
         
            +
            # 11.3.1
         
     | 
| 
      
 4 
     | 
    
         
            +
            - Schema version -- do formatted version like activerecord https://github.com/ilyakatz/data-migrate/pull/363
         
     | 
| 
      
 5 
     | 
    
         
            +
            - Resolve ActiveSupport::Configurable deprecation in Rails 8.2 https://github.com/ilyakatz/data-migrate/pull/365
         
     | 
| 
      
 6 
     | 
    
         
            +
            - Add support for Rails 8.1 in Appraisal https://github.com/ilyakatz/data-migrate/pull/366
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            # 11.3.0
         
     | 
| 
      
 9 
     | 
    
         
            +
            - Make table_name configurable https://github.com/ilyakatz/data-migrate/pull/361
         
     | 
| 
      
 10 
     | 
    
         
            +
            - Use lease_connection over deprecated connection for rails 8 https://github.com/ilyakatz/data-migrate/pull/353
         
     | 
| 
      
 11 
     | 
    
         
            +
            - Add Ruby 3.4 to CI matrix
         
     | 
| 
       4 
12 
     | 
    
         | 
| 
      
 13 
     | 
    
         
            +
            # 11.2.0
         
     | 
| 
       5 
14 
     | 
    
         
             
            - Remove committed Gemfile.lock, reduce bundled file list when running `gem install` https://github.com/ilyakatz/data-migrate/pull/351
         
     | 
| 
       6 
15 
     | 
    
         
             
            - [Bump actionpack from 7.1.3.4 to 7.1.4.1](https://github.com/ilyakatz/data-migrate/pull/348)
         
     | 
| 
       7 
16 
     | 
    
         
             
            - [Bump rexml from 3.3.6 to 3.3.9](https://github.com/ilyakatz/data-migrate/pull/349)
         
     | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -36,7 +36,7 @@ table to track all migrations. 
     | 
|
| 
       36 
36 
     | 
    
         | 
| 
       37 
37 
     | 
    
         
             
            ## Rails Support
         
     | 
| 
       38 
38 
     | 
    
         | 
| 
       39 
     | 
    
         
            -
            Support Rails 6.1 through  
     | 
| 
      
 39 
     | 
    
         
            +
            Support Rails 6.1 through 8.0
         
     | 
| 
       40 
40 
     | 
    
         | 
| 
       41 
41 
     | 
    
         
             
            For **Rails 6.0** support, please use gem version `9.1.x`:
         
     | 
| 
       42 
42 
     | 
    
         | 
| 
         @@ -115,6 +115,7 @@ You can override this setting in `config/initializers/data_migrate.rb` 
     | 
|
| 
       115 
115 
     | 
    
         | 
| 
       116 
116 
     | 
    
         
             
            ```ruby
         
     | 
| 
       117 
117 
     | 
    
         
             
            DataMigrate.configure do |config|
         
     | 
| 
      
 118 
     | 
    
         
            +
              config.data_migrations_table_name = 'my_migrations_database_name'
         
     | 
| 
       118 
119 
     | 
    
         
             
              config.data_migrations_path = 'db/awesomepath/'
         
     | 
| 
       119 
120 
     | 
    
         
             
              config.data_template_path = Rails.root.join("lib", "awesomepath", "custom_data_migration.rb")
         
     | 
| 
       120 
121 
     | 
    
         
             
              config.db_configuration = {
         
     | 
| 
         @@ -144,7 +145,7 @@ From now on capistrano will run `rake db:migrate:with_data` in every deploy. 
     | 
|
| 
       144 
145 
     | 
    
         
             
            ## Rails Engines support
         
     | 
| 
       145 
146 
     | 
    
         | 
| 
       146 
147 
     | 
    
         
             
            This gem also has a initial support for adding data migrations inside Rails engines.
         
     | 
| 
       147 
     | 
    
         
            -
            Just add your engines directory pattern to data_migrations initializer, for example 
     | 
| 
      
 148 
     | 
    
         
            +
            Just add your engines directory pattern to data_migrations initializer, for example
         
     | 
| 
       148 
149 
     | 
    
         
             
            in the case your engines are located in `engines` folder you can set it up like this:
         
     | 
| 
       149 
150 
     | 
    
         | 
| 
       150 
151 
     | 
    
         
             
            ```ruby
         
     | 
| 
         @@ -166,15 +167,17 @@ bundle exec appraisal rails-6.1 rspec 
     | 
|
| 
       166 
167 
     | 
    
         
             
            bundle exec appraisal rails-7.0 rspec
         
     | 
| 
       167 
168 
     | 
    
         
             
            bundle exec appraisal rails-7.1 rspec
         
     | 
| 
       168 
169 
     | 
    
         
             
            bundle exec appraisal rails-7.2 rspec
         
     | 
| 
      
 170 
     | 
    
         
            +
            bundle exec appraisal rails-8.0 rspec
         
     | 
| 
       169 
171 
     | 
    
         
             
            ```
         
     | 
| 
       170 
172 
     | 
    
         | 
| 
       171 
173 
     | 
    
         
             
            ## Releasing new version
         
     | 
| 
       172 
174 
     | 
    
         | 
| 
       173 
     | 
    
         
            -
            1.  
     | 
| 
       174 
     | 
    
         
            -
             
     | 
| 
       175 
     | 
    
         
            -
             
     | 
| 
       176 
     | 
    
         
            -
             
     | 
| 
       177 
     | 
    
         
            -
             
     | 
| 
      
 175 
     | 
    
         
            +
            1. Update version.rb file, run `bundle exec appraisal` to update the version in corresponding gemfile.lock
         
     | 
| 
      
 176 
     | 
    
         
            +
            2. Create a new tag, eg `git tag 9.4.1`
         
     | 
| 
      
 177 
     | 
    
         
            +
            3. Go to https://github.com/ilyakatz/data-migrate/tags
         
     | 
| 
      
 178 
     | 
    
         
            +
            4. Click "Create release" under 9.4.1
         
     | 
| 
      
 179 
     | 
    
         
            +
            5. CLick "Generate release notes"
         
     | 
| 
      
 180 
     | 
    
         
            +
            6. Click "Publish release"
         
     | 
| 
       178 
181 
     | 
    
         | 
| 
       179 
182 
     | 
    
         
             
            ## Thanks
         
     | 
| 
       180 
183 
     | 
    
         | 
    
        data/lib/data_migrate/config.rb
    CHANGED
    
    | 
         @@ -1,5 +1,4 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module DataMigrate
         
     | 
| 
       2 
     | 
    
         
            -
              include ActiveSupport::Configurable
         
     | 
| 
       3 
2 
     | 
    
         
             
              class << self
         
     | 
| 
       4 
3 
     | 
    
         | 
| 
       5 
4 
     | 
    
         
             
                def configure
         
     | 
| 
         @@ -12,11 +11,12 @@ module DataMigrate 
     | 
|
| 
       12 
11 
     | 
    
         
             
              end
         
     | 
| 
       13 
12 
     | 
    
         | 
| 
       14 
13 
     | 
    
         
             
              class Config
         
     | 
| 
       15 
     | 
    
         
            -
                attr_accessor :data_migrations_path, :data_template_path, :db_configuration, :spec_name
         
     | 
| 
      
 14 
     | 
    
         
            +
                attr_accessor :data_migrations_table_name, :data_migrations_path, :data_template_path, :db_configuration, :spec_name
         
     | 
| 
       16 
15 
     | 
    
         | 
| 
       17 
16 
     | 
    
         
             
                DEFAULT_DATA_TEMPLATE_PATH = "data_migration.rb"
         
     | 
| 
       18 
17 
     | 
    
         | 
| 
       19 
18 
     | 
    
         
             
                def initialize
         
     | 
| 
      
 19 
     | 
    
         
            +
                  @data_migrations_table_name = "data_migrations"
         
     | 
| 
       20 
20 
     | 
    
         
             
                  @data_migrations_path = "db/data/"
         
     | 
| 
       21 
21 
     | 
    
         
             
                  @data_template_path = DEFAULT_DATA_TEMPLATE_PATH
         
     | 
| 
       22 
22 
     | 
    
         
             
                  @db_configuration = nil
         
     | 
| 
         @@ -48,7 +48,6 @@ module DataMigrate 
     | 
|
| 
       48 
48 
     | 
    
         | 
| 
       49 
49 
     | 
    
         
             
                  # TODO: this was added to be backward compatible, need to re-evaluate
         
     | 
| 
       50 
50 
     | 
    
         
             
                  def migrations(_migrations_paths)
         
     | 
| 
       51 
     | 
    
         
            -
                    #DataMigrate::MigrationContext.new(migrations_paths).migrations
         
     | 
| 
       52 
51 
     | 
    
         
             
                    DataMigrate::MigrationContext.new(_migrations_paths).migrations
         
     | 
| 
       53 
52 
     | 
    
         
             
                  end
         
     | 
| 
       54 
53 
     | 
    
         | 
| 
         @@ -4,7 +4,7 @@ module DataMigrate 
     | 
|
| 
       4 
4 
     | 
    
         
             
                # So we only load the appropriate methods depending on Rails version.
         
     | 
| 
       5 
5 
     | 
    
         
             
                if DataMigrate::RailsHelper.rails_version_equal_to_or_higher_than_7_1
         
     | 
| 
       6 
6 
     | 
    
         
             
                  def table_name
         
     | 
| 
       7 
     | 
    
         
            -
                    ActiveRecord::Base.table_name_prefix +  
     | 
| 
      
 7 
     | 
    
         
            +
                    ActiveRecord::Base.table_name_prefix + DataMigrate.config.data_migrations_table_name + ActiveRecord::Base.table_name_suffix
         
     | 
| 
       8 
8 
     | 
    
         
             
                  end
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
       10 
10 
     | 
    
         
             
                  def primary_key
         
     | 
| 
         @@ -13,7 +13,7 @@ module DataMigrate 
     | 
|
| 
       13 
13 
     | 
    
         
             
                else
         
     | 
| 
       14 
14 
     | 
    
         
             
                  class << self
         
     | 
| 
       15 
15 
     | 
    
         
             
                    def table_name
         
     | 
| 
       16 
     | 
    
         
            -
                      ActiveRecord::Base.table_name_prefix +  
     | 
| 
      
 16 
     | 
    
         
            +
                      ActiveRecord::Base.table_name_prefix + DataMigrate.config.data_migrations_table_name + ActiveRecord::Base.table_name_suffix
         
     | 
| 
       17 
17 
     | 
    
         
             
                    end
         
     | 
| 
       18 
18 
     | 
    
         | 
| 
       19 
19 
     | 
    
         
             
                    def primary_key
         
     | 
| 
         @@ -9,6 +9,13 @@ module DataMigrate 
     | 
|
| 
       9 
9 
     | 
    
         
             
                extend ActiveRecord::Tasks::DatabaseTasks
         
     | 
| 
       10 
10 
     | 
    
         
             
                extend self
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
      
 12 
     | 
    
         
            +
                if respond_to?(:register_task)
         
     | 
| 
      
 13 
     | 
    
         
            +
                  register_task(/mysql/,        "ActiveRecord::Tasks::MySQLDatabaseTasks")
         
     | 
| 
      
 14 
     | 
    
         
            +
                  register_task(/trilogy/,      "ActiveRecord::Tasks::MySQLDatabaseTasks")
         
     | 
| 
      
 15 
     | 
    
         
            +
                  register_task(/postgresql/,   "ActiveRecord::Tasks::PostgreSQLDatabaseTasks")
         
     | 
| 
      
 16 
     | 
    
         
            +
                  register_task(/sqlite/,       "ActiveRecord::Tasks::SQLiteDatabaseTasks")
         
     | 
| 
      
 17 
     | 
    
         
            +
                end
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
       12 
19 
     | 
    
         
             
                # These method are only introduced in Rails 7.1
         
     | 
| 
       13 
20 
     | 
    
         
             
                unless respond_to?(:with_temporary_pool_for_each)
         
     | 
| 
       14 
21 
     | 
    
         
             
                  def with_temporary_pool_for_each(env: ActiveRecord::Tasks::DatabaseTasks.env, name: nil, &block) # :nodoc:
         
     | 
| 
         @@ -99,7 +106,7 @@ module DataMigrate 
     | 
|
| 
       99 
106 
     | 
    
         
             
                end
         
     | 
| 
       100 
107 
     | 
    
         | 
| 
       101 
108 
     | 
    
         
             
                def sort_migrations(*migrations)
         
     | 
| 
       102 
     | 
    
         
            -
                  migrations.flatten.sort { |a, b| 
     | 
| 
      
 109 
     | 
    
         
            +
                  migrations.flatten.sort { |a, b| sort_string(a) <=> sort_string(b) }
         
     | 
| 
       103 
110 
     | 
    
         
             
                end
         
     | 
| 
       104 
111 
     | 
    
         | 
| 
       105 
112 
     | 
    
         
             
                def sort_string migration
         
     | 
| 
         @@ -159,7 +166,7 @@ module DataMigrate 
     | 
|
| 
       159 
166 
     | 
    
         
             
                  data_migrator = DataMigrate::RailsHelper.data_migrator(:up, data_migrations)
         
     | 
| 
       160 
167 
     | 
    
         
             
                  sort_migrations(
         
     | 
| 
       161 
168 
     | 
    
         
             
                    data_migrator.pending_migrations.map { |m| { version: m.version, name: m.name, kind: :data } }
         
     | 
| 
       162 
     | 
    
         
            -
             
     | 
| 
      
 169 
     | 
    
         
            +
                  )
         
     | 
| 
       163 
170 
     | 
    
         
             
                end
         
     | 
| 
       164 
171 
     | 
    
         | 
| 
       165 
172 
     | 
    
         
             
                def pending_schema_migrations
         
     | 
| 
         @@ -219,7 +226,8 @@ module DataMigrate 
     | 
|
| 
       219 
226 
     | 
    
         
             
                    next unless primary?(db_config)
         
     | 
| 
       220 
227 
     | 
    
         | 
| 
       221 
228 
     | 
    
         
             
                    with_temporary_pool(db_config) do |pool|
         
     | 
| 
       222 
     | 
    
         
            -
                       
     | 
| 
      
 229 
     | 
    
         
            +
                      connection = pool.respond_to?(:lease_connection) ? pool.lease_connection : pool.connection
         
     | 
| 
      
 230 
     | 
    
         
            +
                      unless database_exists?(connection)
         
     | 
| 
       223 
231 
     | 
    
         
             
                        create(db_config)
         
     | 
| 
       224 
232 
     | 
    
         
             
                        if File.exist?(schema_dump_path(db_config))
         
     | 
| 
       225 
233 
     | 
    
         
             
                          load_schema(db_config, schema_format, nil)
         
     | 
| 
         @@ -15,7 +15,7 @@ module DataMigrate 
     | 
|
| 
       15 
15 
     | 
    
         
             
                end
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
       17 
17 
     | 
    
         
             
                def dump(stream)
         
     | 
| 
       18 
     | 
    
         
            -
                  define_params = @version ? "version: #{ 
     | 
| 
      
 18 
     | 
    
         
            +
                  define_params = @version ? "version: #{formatted_version}" : ""
         
     | 
| 
       19 
19 
     | 
    
         | 
| 
       20 
20 
     | 
    
         
             
                  stream.puts "DataMigrate::Data.define(#{define_params})"
         
     | 
| 
       21 
21 
     | 
    
         | 
| 
         @@ -34,5 +34,12 @@ module DataMigrate 
     | 
|
| 
       34 
34 
     | 
    
         
             
                                0
         
     | 
| 
       35 
35 
     | 
    
         
             
                              end
         
     | 
| 
       36 
36 
     | 
    
         
             
                end
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
                # turns 20170404131909 into "2017_04_04_131909"
         
     | 
| 
      
 39 
     | 
    
         
            +
                def formatted_version
         
     | 
| 
      
 40 
     | 
    
         
            +
                  stringified = @version.to_s
         
     | 
| 
      
 41 
     | 
    
         
            +
                  return stringified unless stringified.length == 14
         
     | 
| 
      
 42 
     | 
    
         
            +
                  stringified.insert(4, "_").insert(7, "_").insert(10, "_")
         
     | 
| 
      
 43 
     | 
    
         
            +
                end
         
     | 
| 
       37 
44 
     | 
    
         
             
              end
         
     | 
| 
       38 
45 
     | 
    
         
             
            end
         
     | 
    
        data/lib/data_migrate/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,16 +1,16 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: data_migrate
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 11. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 11.3.1
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Andrew J Vargo
         
     | 
| 
       8 
8 
     | 
    
         
             
            - Ilya Katz
         
     | 
| 
       9 
9 
     | 
    
         
             
            - Deborah Enomah
         
     | 
| 
       10 
     | 
    
         
            -
            autorequire: 
     | 
| 
      
 10 
     | 
    
         
            +
            autorequire:
         
     | 
| 
       11 
11 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       12 
12 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       13 
     | 
    
         
            -
            date:  
     | 
| 
      
 13 
     | 
    
         
            +
            date: 2025-10-27 00:00:00.000000000 Z
         
     | 
| 
       14 
14 
     | 
    
         
             
            dependencies:
         
     | 
| 
       15 
15 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       16 
16 
     | 
    
         
             
              name: activerecord
         
     | 
| 
         @@ -218,7 +218,7 @@ homepage: https://github.com/ilyakatz/data-migrate 
     | 
|
| 
       218 
218 
     | 
    
         
             
            licenses:
         
     | 
| 
       219 
219 
     | 
    
         
             
            - MIT
         
     | 
| 
       220 
220 
     | 
    
         
             
            metadata: {}
         
     | 
| 
       221 
     | 
    
         
            -
            post_install_message: 
     | 
| 
      
 221 
     | 
    
         
            +
            post_install_message:
         
     | 
| 
       222 
222 
     | 
    
         
             
            rdoc_options: []
         
     | 
| 
       223 
223 
     | 
    
         
             
            require_paths:
         
     | 
| 
       224 
224 
     | 
    
         
             
            - lib
         
     | 
| 
         @@ -234,7 +234,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       234 
234 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       235 
235 
     | 
    
         
             
            requirements: []
         
     | 
| 
       236 
236 
     | 
    
         
             
            rubygems_version: 3.4.19
         
     | 
| 
       237 
     | 
    
         
            -
            signing_key: 
     | 
| 
      
 237 
     | 
    
         
            +
            signing_key:
         
     | 
| 
       238 
238 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       239 
239 
     | 
    
         
             
            summary: Rake tasks to migrate data alongside schema changes.
         
     | 
| 
       240 
240 
     | 
    
         
             
            test_files: []
         
     |