From 0d5e871f5e36eaf4a26fcffa377a77a46dae3fc5 Mon Sep 17 00:00:00 2001 From: Chaunce Butterfield Date: Mon, 3 Apr 2023 12:41:20 -0600 Subject: [PATCH 01/98] add support for multiple connections --- .travis.yml | 3 - Appraisals | 4 - Gemfile.rails5.2 | 10 -- README.md | 6 +- gemfiles/rails_5.2.gemfile | 8 - gemfiles/rails_6.0.gemfile | 2 +- gemfiles/rails_6.1.gemfile | 2 +- lib/data_migrate.rb | 11 +- ...data_migrator_five.rb => data_migrator.rb} | 22 ++- lib/data_migrate/database_tasks.rb | 139 ++++----------- ...a_migration_six.rb => schema_migration.rb} | 6 +- lib/data_migrate/schema_migration_five.rb | 31 ---- ...atus_service_five.rb => status_service.rb} | 0 lib/data_migrate/tasks/data_migrate_tasks.rb | 82 +++------ spec/data_migrate/database_tasks_spec.rb | 21 +-- spec/data_migrate/migration.rb | 8 +- spec/data_migrate/migration_context_spec.rb | 16 +- spec/data_migrate/schema_migration_spec.rb | 11 +- spec/data_migrate/status_service_spec.rb | 3 +- .../tasks/data_migrate_tasks_spec.rb | 17 +- spec/db/6.0/20091231235959_some_name.rb | 9 - spec/db/6.0/20171231235959_super_update.rb | 9 - spec/db/data-6.0/20091231235959_some_name.rb | 9 - .../data-6.0/20171231235959_super_update.rb | 9 - .../20181128000207_excluded_file.rb.other_ext | 1 - spec/db/data/20091231235959_some_name.rb | 2 +- spec/db/data/20171231235959_super_update.rb | 2 +- .../20131111111111_late_migration.rb | 0 .../{6.0 => }/20202020202011_db_migration.rb | 0 .../5.2/20131111111111_late_migration.rb | 9 - .../5.2/20202020202011_db_migration.rb | 9 - spec/spec_helper.rb | 10 +- tasks/databases.rake | 161 ++++++++++-------- 33 files changed, 189 insertions(+), 443 deletions(-) delete mode 100644 Gemfile.rails5.2 delete mode 100644 gemfiles/rails_5.2.gemfile rename lib/data_migrate/{data_migrator_five.rb => data_migrator.rb} (81%) rename lib/data_migrate/{schema_migration_six.rb => schema_migration.rb} (88%) delete mode 100644 lib/data_migrate/schema_migration_five.rb rename lib/data_migrate/{status_service_five.rb => status_service.rb} (100%) delete mode 100644 spec/db/6.0/20091231235959_some_name.rb delete mode 100644 spec/db/6.0/20171231235959_super_update.rb delete mode 100644 spec/db/data-6.0/20091231235959_some_name.rb delete mode 100644 spec/db/data-6.0/20171231235959_super_update.rb delete mode 100644 spec/db/data-6.0/20181128000207_excluded_file.rb.other_ext rename spec/db/migrate/{6.0 => }/20131111111111_late_migration.rb (100%) rename spec/db/migrate/{6.0 => }/20202020202011_db_migration.rb (100%) delete mode 100644 spec/db/migrate/5.2/20131111111111_late_migration.rb delete mode 100644 spec/db/migrate/5.2/20202020202011_db_migration.rb diff --git a/.travis.yml b/.travis.yml index 75f42cb6..11da9415 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,13 +5,10 @@ rvm: - 3.2 script: bundle exec rspec gemfile: - - gemfiles/rails_5.2.gemfile - gemfiles/rails_6.0.gemfile - gemfiles/rails_6.1.gemfile - gemfiles/rails_7.0.gemfile jobs: exclude: - rvm: 3.0 - gemfile: gemfiles/rails_5.2.gemfile - rvm: 3.2 - gemfile: gemfiles/rails_5.2.gemfile diff --git a/Appraisals b/Appraisals index d2457013..12b662af 100644 --- a/Appraisals +++ b/Appraisals @@ -1,7 +1,3 @@ -appraise 'rails-5.2' do - gem 'rails', '~> 5.2.3' -end - appraise 'rails-6.0' do gem 'rails', '~> 6.0.0' end diff --git a/Gemfile.rails5.2 b/Gemfile.rails5.2 deleted file mode 100644 index 7dd5bbb9..00000000 --- a/Gemfile.rails5.2 +++ /dev/null @@ -1,10 +0,0 @@ -source "http://rubygems.org" - -# Specify your gem's dependencies in data_migrate.gemspec -gemspec -%w[ - activerecord - railties -].each do |rails_gem| - gem rails_gem, '~> 5.2' -end diff --git a/README.md b/README.md index f550b048..75c523b2 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ table to track all migrations. ## Rails Support -Support Rails 5.2 through 7.0 +Support Rails 6.1 through 7.0 #### v1 @@ -162,9 +162,9 @@ Run tests for a specific version of Rails ``` bundle exec appraisal install -bundle exec appraisal rails-5.1 rspec -bundle exec appraisal rails-5.2 rspec bundle exec appraisal rails-6.0 rspec +bundle exec appraisal rails-6.1 rspec +bundle exec appraisal rails-7.0 rspec ``` ## Thanks diff --git a/gemfiles/rails_5.2.gemfile b/gemfiles/rails_5.2.gemfile deleted file mode 100644 index f9c05154..00000000 --- a/gemfiles/rails_5.2.gemfile +++ /dev/null @@ -1,8 +0,0 @@ -# This file was generated by Appraisal - -source "http://rubygems.org" - -gem "rails", "~> 5.2.3" -gem "sqlite3", "~> 1.4" - -gemspec path: "../" diff --git a/gemfiles/rails_6.0.gemfile b/gemfiles/rails_6.0.gemfile index 172f9d56..fd25237e 100644 --- a/gemfiles/rails_6.0.gemfile +++ b/gemfiles/rails_6.0.gemfile @@ -2,7 +2,7 @@ source "http://rubygems.org" -gem "rails", "~> 6.0.0" gem "sqlite3", "~> 1.4" +gem "rails", "~> 6.0.0" gemspec path: "../" diff --git a/gemfiles/rails_6.1.gemfile b/gemfiles/rails_6.1.gemfile index eff39ac3..20ae603a 100644 --- a/gemfiles/rails_6.1.gemfile +++ b/gemfiles/rails_6.1.gemfile @@ -2,7 +2,7 @@ source "http://rubygems.org" -gem "rails", "~> 6.1.0" gem "sqlite3", "~> 1.4" +gem "rails", "~> 6.1.0" gemspec path: "../" diff --git a/lib/data_migrate.rb b/lib/data_migrate.rb index 39ce3a88..d78eed37 100644 --- a/lib/data_migrate.rb +++ b/lib/data_migrate.rb @@ -1,22 +1,17 @@ # frozen_string_literal: true -require File.join(File.dirname(__FILE__), "data_migrate", "data_migrator_five") +require File.join(File.dirname(__FILE__), "data_migrate", "data_migrator") require File.join(File.dirname(__FILE__), "data_migrate", "data_schema_migration") require File.join(File.dirname(__FILE__), "data_migrate", "data_schema") require File.join(File.dirname(__FILE__), "data_migrate", "database_tasks") require File.join(File.dirname(__FILE__), "data_migrate", "schema_dumper") -require File.join(File.dirname(__FILE__), "data_migrate", "status_service_five") +require File.join(File.dirname(__FILE__), "data_migrate", "status_service") require File.join(File.dirname(__FILE__), "data_migrate", "migration_context") require File.join(File.dirname(__FILE__), "data_migrate", "railtie") require File.join(File.dirname(__FILE__), "data_migrate", "tasks/data_migrate_tasks") require File.join(File.dirname(__FILE__), "data_migrate", "legacy_migrator") require File.join(File.dirname(__FILE__), "data_migrate", "config") - -if Rails::VERSION::MAJOR == 5 - require File.join(File.dirname(__FILE__), "data_migrate", "schema_migration_five") -else - require File.join(File.dirname(__FILE__), "data_migrate", "schema_migration_six") -end +require File.join(File.dirname(__FILE__), "data_migrate", "schema_migration") module DataMigrate def self.root diff --git a/lib/data_migrate/data_migrator_five.rb b/lib/data_migrate/data_migrator.rb similarity index 81% rename from lib/data_migrate/data_migrator_five.rb rename to lib/data_migrate/data_migrator.rb index 67c3bbab..ddab80b2 100644 --- a/lib/data_migrate/data_migrator_five.rb +++ b/lib/data_migrate/data_migrator.rb @@ -10,7 +10,6 @@ def self.migrations_paths end def self.assure_data_schema_table - ActiveRecord::Base.establish_connection(db_config) DataMigrate::DataSchemaMigration.create_table end @@ -27,8 +26,7 @@ def initialize(direction, migrations, target_version = nil) end def load_migrated - @migrated_versions = - DataMigrate::DataSchemaMigration.normalized_versions.map(&:to_i).sort + @migrated_versions = DataMigrate::DataSchemaMigration.normalized_versions.map(&:to_i).sort end class << self @@ -74,15 +72,15 @@ def rollback(migrations_path, steps) DataMigrate::MigrationContext.new(migrations_path).rollback(steps) end - def db_config - env = Rails.env || "development" - ar_config = if (Rails::VERSION::MAJOR == 6 && Rails::VERSION::MINOR >= 1) || Rails::VERSION::MAJOR > 6 - ActiveRecord::Base.configurations.configs_for(env_name: env).first - else - ActiveRecord::Base.configurations[env] - end - ar_config || ENV["DATABASE_URL"] - end + # def db_config + # env = Rails.env || "development" + # ar_config = if (Rails::VERSION::MAJOR == 6 && Rails::VERSION::MINOR >= 1) || Rails::VERSION::MAJOR > 6 + # ActiveRecord::Base.configurations.configs_for(env_name: env).first + # else + # ActiveRecord::Base.configurations[env] + # end + # ar_config || ENV["DATABASE_URL"] + # end end private diff --git a/lib/data_migrate/database_tasks.rb b/lib/data_migrate/database_tasks.rb index 94f6c15f..b817bbf2 100644 --- a/lib/data_migrate/database_tasks.rb +++ b/lib/data_migrate/database_tasks.rb @@ -13,32 +13,14 @@ def schema_file_type(_format = nil) "data_schema.rb" end - def dump_filename(namespace, format = ActiveRecord::Base.schema_format) - filename = if namespace == "primary" + def dump_filename(db_config_name, format = ActiveRecord::Base.schema_format) + filename = if ActiveRecord::Base.configurations.primary?(db_config_name) schema_file_type(format) else - "#{namespace}_#{schema_file_type(format)}" + "#{db_config_name}_#{schema_file_type(format)}" end - ENV["DATA_SCHEMA"] || File.join(schema_location, filename) - end - - def schema_dump_path(db_config, format = ActiveRecord.schema_format) - return ENV["DATA_SCHEMA"] if ENV["DATA_SCHEMA"] - - filename = if db_config.primary? - schema_file_type(format) - else - [db_config.name, schema_file_type(format)].join("_") - end - - return unless filename - - File.dirname(filename) == schema_location ? filename : File.join(schema_location, filename) - end - - def schema_location - db_dir + ENV["DATA_SCHEMA"] || File.join(db_dir, filename) end def check_schema_file(filename) @@ -49,18 +31,14 @@ def check_schema_file(filename) end def pending_migrations - sort_migrations( - pending_schema_migrations, - pending_data_migrations - ) + sort_migrations(pending_schema_migrations, pending_data_migrations) end - def sort_migrations set_1, set_2=nil - migrations = set_1 + (set_2 || []) - migrations.sort{|a,b| sort_string(a) <=> sort_string(b)} + def sort_migrations(*migrations) + migrations.flatten.sort { |a, b| sort_string(a) <=> sort_string(b) } end - def sort_string migration + def sort_string(migration) "#{migration[:version]}_#{migration[:kind] == :data ? 1 : 0}" end @@ -70,90 +48,45 @@ def data_migrations_path def run_migration(migration, direction) if migration[:kind] == :data - ::ActiveRecord::Migration.write("== %s %s" % ['Data', "=" * 71]) + ::ActiveRecord::Migration.write("== %s %s" % ["Data", "=" * 71]) ::DataMigrate::DataMigrator.run(direction, data_migrations_path, migration[:version]) else - ::ActiveRecord::Migration.write("== %s %s" % ['Schema', "=" * 69]) - ::DataMigrate::SchemaMigration.run( - direction, - ::DataMigrate::SchemaMigration.migrations_paths, - migration[:version] - ) + ::ActiveRecord::Migration.write("== %s %s" % ["Schema", "=" * 69]) + ::DataMigrate::SchemaMigration.run(direction, ::DataMigrate::SchemaMigration.migrations_paths, migration[:version]) end end - end - # This overrides ActiveRecord::Tasks::DatabaseTasks - def self.schema_file(_format = nil) - File.join(db_dir, "data_schema.rb") - end - - def self.forward(step = 1) - DataMigrate::DataMigrator.assure_data_schema_table - migrations = pending_migrations.reverse.pop(step).reverse - migrations.each do | pending_migration | - if pending_migration[:kind] == :data - ActiveRecord::Migration.write("== %s %s" % ["Data", "=" * 71]) - DataMigrate::DataMigrator.run(:up, data_migrations_path, pending_migration[:version]) - elsif pending_migration[:kind] == :schema - ActiveRecord::Migration.write("== %s %s" % ["Schema", "=" * 69]) - DataMigrate::SchemaMigration.run(:up, schema_migrations_path, pending_migration[:version]) + def forward(step = 1) + DataMigrate::DataMigrator.assure_data_schema_table + migrations = pending_migrations.reverse.pop(step).reverse + migrations.each do | pending_migration | + if pending_migration[:kind] == :data + ActiveRecord::Migration.write("== %s %s" % ["Data", "=" * 71]) + DataMigrate::DataMigrator.run(:up, data_migrations_path, pending_migration[:version]) + elsif pending_migration[:kind] == :schema + ActiveRecord::Migration.write("== %s %s" % ["Schema", "=" * 69]) + DataMigrate::SchemaMigration.run(:up, DataMigrate::SchemaMigration.migrations_paths, pending_migration[:version]) + end end end - end - - def self.data_migrations_path - DataMigrate.config.data_migrations_path - end - - def self.schema_migrations_path - "db/migrate/" - end - - def self.pending_migrations - sort_migrations(pending_schema_migrations, pending_data_migrations) - end - - def self.pending_data_migrations - data_migrations = DataMigrate::DataMigrator.migrations(data_migrations_path) - sort_migrations(DataMigrate::DataMigrator.new(:up, data_migrations ). - pending_migrations.map {|m| { version: m.version, name: m.name, kind: :data }}) - end - def self.pending_schema_migrations - ::DataMigrate::SchemaMigration.pending_schema_migrations - end + def pending_data_migrations + data_migrations = DataMigrate::DataMigrator.migrations(data_migrations_path) + sort_migrations(DataMigrate::DataMigrator.new(:up, data_migrations ). + pending_migrations.map {|m| { version: m.version, name: m.name, kind: :data }}) + end - def self.sort_migrations(set1, set2 = nil) - migrations = set1 + (set2 || []) - migrations.sort {|a, b| sort_string(a) <=> sort_string(b)} - end + def pending_schema_migrations + ::DataMigrate::SchemaMigration.pending_schema_migrations + end - def self.sort_string(migration) - "#{migration[:version]}_#{migration[:kind] == :data ? 1 : 0}" - end + def past_migrations(sort = nil) + data_versions = DataMigrate::DataSchemaMigration.table_exists? ? DataMigrate::DataSchemaMigration.normalized_versions : [] + schema_versions = ActiveRecord::SchemaMigration.normalized_versions + migrations = data_versions.map { |v| { version: v.to_i, kind: :data } } + schema_versions.map { |v| { version: v.to_i, kind: :schema } } - def self.past_migrations(sort = nil) - sort = sort.downcase if sort - db_list_data = - if DataMigrate::DataSchemaMigration.table_exists? - DataMigrate::DataSchemaMigration.normalized_versions.sort - else - [] - end - db_list_schema = ActiveRecord::SchemaMigration.normalized_versions.sort.sort - migrations = db_list_data.map do |d| - { - version: d.to_i, kind: :data - } - end + - db_list_schema.map do |d| - { - version: d.to_i, kind: :schema - } - end - - sort == "asc" ? sort_migrations(migrations) : sort_migrations(migrations).reverse + sort&.downcase == "asc" ? sort_migrations(migrations) : sort_migrations(migrations).reverse + end end end end diff --git a/lib/data_migrate/schema_migration_six.rb b/lib/data_migrate/schema_migration.rb similarity index 88% rename from lib/data_migrate/schema_migration_six.rb rename to lib/data_migrate/schema_migration.rb index ad5e8061..139f4524 100644 --- a/lib/data_migrate/schema_migration_six.rb +++ b/lib/data_migrate/schema_migration.rb @@ -7,7 +7,7 @@ def self.pending_schema_migrations sort_migrations( ActiveRecord::Migrator.new(:up, all_migrations, ActiveRecord::Base.connection.schema_migration). pending_migrations. - map {|m| { version: m.version, kind: :schema }} + map { |m| { version: m.version, kind: :schema } } ) end @@ -17,12 +17,12 @@ def self.run(direction, migration_paths, version) def self.sort_migrations(set1, set2 = nil) migrations = set1 + (set2 || []) - migrations.sort {|a, b| sort_string(a) <=> sort_string(b)} + migrations.sort { |a, b| sort_string(a) <=> sort_string(b) } end def self.migrations_paths spec_name = DataMigrate.config.spec_name - if spec_name && Rails.version > '6.1' + if spec_name && Rails.version > "6.1" ActiveRecord::Base.configurations.configs_for(env_name: Rails.env, name: spec_name).migrations_paths elsif spec_name ActiveRecord::Base.configurations.configs_for(env_name: Rails.env, spec_name: spec_name).migrations_paths diff --git a/lib/data_migrate/schema_migration_five.rb b/lib/data_migrate/schema_migration_five.rb deleted file mode 100644 index 31f04575..00000000 --- a/lib/data_migrate/schema_migration_five.rb +++ /dev/null @@ -1,31 +0,0 @@ -module DataMigrate - # Helper class to getting access to db schema - # to allow data/schema combiation tasks - class SchemaMigration - def self.pending_schema_migrations - all_migrations = DataMigrate::MigrationContext.new(migrations_paths).migrations - sort_migrations( - ActiveRecord::Migrator.new(:up, all_migrations). - pending_migrations. - map {|m| { version: m.version, name: m.name, kind: :schema }} - ) - end - - def self.run(direction, migration_paths, version) - ActiveRecord::MigrationContext.new(migration_paths).run(direction, version) - end - - def self.sort_migrations(set1, set2 = nil) - migrations = set1 + (set2 || []) - migrations.sort {|a, b| sort_string(a) <=> sort_string(b)} - end - - def self.migrations_paths - Rails.application.config.paths["db/migrate"].to_a - end - - def self.sort_string(migration) - "#{migration[:version]}_#{migration[:kind] == :data ? 1 : 0}" - end - end -end diff --git a/lib/data_migrate/status_service_five.rb b/lib/data_migrate/status_service.rb similarity index 100% rename from lib/data_migrate/status_service_five.rb rename to lib/data_migrate/status_service.rb diff --git a/lib/data_migrate/tasks/data_migrate_tasks.rb b/lib/data_migrate/tasks/data_migrate_tasks.rb index abcbb0f8..91420d5e 100644 --- a/lib/data_migrate/tasks/data_migrate_tasks.rb +++ b/lib/data_migrate/tasks/data_migrate_tasks.rb @@ -3,18 +3,18 @@ module Tasks module DataMigrateTasks extend self - def schema_migrations_path - File.join('db', 'migrate') - end + # def schema_migrations_path + # File.join('db', 'migrate') + # end def migrations_paths @migrations_paths ||= DataMigrate.config.data_migrations_path end - def dump + def dump(db_config) if dump_schema_after_migration? - filename = DataMigrate::DatabaseTasks.schema_file - ActiveRecord::Base.establish_connection(DataMigrate.config.db_configuration) if DataMigrate.config.db_configuration + filename = DataMigrate::DatabaseTasks.dump_filename(db_config.name, ActiveRecord::Base.schema_format) + File.open(filename, "w:utf-8") do |file| DataMigrate::SchemaDumper.dump(ActiveRecord::Base.connection, file) end @@ -30,7 +30,7 @@ def migrate def abort_if_pending_migrations(migrations, message) if migrations.any? - puts "You have #{migrations.size} pending #{migrations.size > 1 ? 'migrations:' : 'migration:'}" + puts "You have #{migrations.size} pending #{'migration'.pluralize(migrations.size)}:" migrations.each do |pending_migration| puts " %4d %s" % [pending_migration[:version], pending_migration[:name]] end @@ -47,80 +47,44 @@ def dump_schema_after_migration? end def status - config = connect_to_database - return unless config - - connection = ActiveRecord::Base.connection - puts "\ndatabase: #{config['database']}\n\n" - DataMigrate::StatusService.dump(connection) + puts "\ndatabase: #{ActiveRecord::Base.connection_db_config.database}\n\n" + DataMigrate::StatusService.dump(ActiveRecord::Base.connection) end def status_with_schema - config = connect_to_database - return unless config - - db_list_data = ActiveRecord::Base.connection.select_values( - "SELECT version FROM #{DataMigrate::DataSchemaMigration.table_name}" - ) - db_list_schema = ActiveRecord::Base.connection.select_values( - "SELECT version FROM #{ActiveRecord::SchemaMigration.schema_migrations_table_name}" - ) + db_list_data = ActiveRecord::Base.connection.select_values("SELECT version FROM #{DataMigrate::DataSchemaMigration.table_name}") + db_list_schema = ActiveRecord::SchemaMigration.all.pluck(:version) file_list = [] Dir.foreach(File.join(Rails.root, migrations_paths)) do |file| # only files matching "20091231235959_some_name.rb" pattern if match_data = /(\d{14})_(.+)\.rb/.match(file) - status = db_list_data.delete(match_data[1]) ? 'up' : 'down' - file_list << [status, match_data[1], match_data[2], 'data'] + status = db_list_data.delete(match_data[1]) ? "up" : "down" + file_list << [status, match_data[1], match_data[2], "data"] end end - Dir.foreach(File.join(Rails.root, schema_migrations_path)) do |file| + DataMigrate::SchemaMigration.migrations_paths.map do |path| + Dir.children(path) if Dir.exists?(path) + end.flatten.compact.each do |file| # only files matching "20091231235959_some_name.rb" pattern if match_data = /(\d{14})_(.+)\.rb/.match(file) - status = db_list_schema.delete(match_data[1]) ? 'up' : 'down' - file_list << [status, match_data[1], match_data[2], 'schema'] + status = db_list_schema.delete(match_data[1]) ? "up" : "down" + file_list << [status, match_data[1], match_data[2], "schema"] end end - file_list.sort!{|a,b| "#{a[1]}_#{a[3] == 'data' ? 1 : 0}" <=> "#{b[1]}_#{b[3] == 'data' ? 1 : 0}" } + file_list.sort! { |a,b| "#{a[1]}_#{a[3] == 'data' ? 1 : 0}" <=> "#{b[1]}_#{b[3] == 'data' ? 1 : 0}" } # output - puts "\ndatabase: #{config['database']}\n\n" + puts "\ndatabase: #{ActiveRecord::Base.connection_db_config.database}\n\n" puts "#{"Status".center(8)} #{"Type".center(8)} #{"Migration ID".ljust(14)} Migration Name" puts "-" * 60 - file_list.each do |file| - puts "#{file[0].center(8)} #{file[3].center(8)} #{file[1].ljust(14)} #{file[2].humanize}" - end - db_list_schema.each do |version| - puts "#{'up'.center(8)} #{version.ljust(14)} *** NO SCHEMA FILE ***" - end - db_list_data.each do |version| - puts "#{'up'.center(8)} #{version.ljust(14)} *** NO DATA FILE ***" - end + file_list.each { |file| puts "#{file[0].center(8)} #{file[3].center(8)} #{file[1].ljust(14)} #{file[2].humanize}" } + db_list_schema.each { |version| puts "#{'up'.center(8)} #{version.ljust(14)} *** NO SCHEMA FILE ***" } + db_list_data.each { |version| puts "#{'up'.center(8)} #{version.ljust(14)} *** NO DATA FILE ***" } puts end - - private - - def connect_to_database - config = if ActiveRecord.version < Gem::Version.new('6.1') - ActiveRecord::Base.configurations[Rails.env || 'development'] - else - ActiveRecord::Base.configurations.find_db_config(Rails.env || 'development').configuration_hash - end - ActiveRecord::Base.establish_connection(config) - - unless DataMigrate::DataSchemaMigration.table_exists? - puts 'Data migrations table does not exist yet.' - config = nil - end - unless ActiveRecord::SchemaMigration.table_exists? - puts 'Schema migrations table does not exist yet.' - config = nil - end - config - end end end end diff --git a/spec/data_migrate/database_tasks_spec.rb b/spec/data_migrate/database_tasks_spec.rb index 8c9c3d73..01cbb131 100644 --- a/spec/data_migrate/database_tasks_spec.rb +++ b/spec/data_migrate/database_tasks_spec.rb @@ -4,13 +4,7 @@ describe DataMigrate::DatabaseTasks do let(:subject) { DataMigrate::DatabaseTasks } - let(:migration_path) { - if Rails::VERSION::MAJOR == 5 - "spec/db/migrate/5.2" - else - "spec/db/migrate/6.0" - end - } + let(:migration_path) { "spec/db/migrate" } let(:data_migrations_path) { DataMigrate.config.data_migrations_path } @@ -68,9 +62,9 @@ allow(DataMigrate::DatabaseTasks).to receive(:data_migrations_path) { data_migrations_path }.at_least(:once) - allow(DataMigrate::DatabaseTasks).to receive(:schema_migrations_path) { - migration_path - }.at_least(:once) + # allow(DataMigrate::DatabaseTasks).to receive(:schema_migrations_path) { + # migration_path + # }.at_least(:once) end describe :past_migrations do @@ -93,9 +87,6 @@ end it "loads the current schema file" do - if Rails::VERSION::MAJOR < 6 - skip("Not implemented for Rails lower than 6") - end allow(subject).to receive(:schema_location).and_return("spec/db/data/schema/") subject.load_schema_current @@ -104,10 +95,6 @@ end it "loads schema file that has not been update with latest data migrations" do - if Rails::VERSION::MAJOR < 6 - skip("Not implemented for Rails lower than 6") - end - allow(subject).to receive(:schema_location).and_return("spec/db/data/partial_schema/") subject.load_schema_current diff --git a/spec/data_migrate/migration.rb b/spec/data_migrate/migration.rb index 6de934f3..64ecd2d1 100644 --- a/spec/data_migrate/migration.rb +++ b/spec/data_migrate/migration.rb @@ -1,12 +1,6 @@ require 'spec_helper' -if Rails::VERSION::MAJOR >= 5 - subject = DataMigrate::MigrationFive -else - subject = DataMigrate::Migration -end - -describe subject do +describe DataMigrate::Migration do it "uses correct table name" do expect(subject.table_name).to eq("data_migrations") end diff --git a/spec/data_migrate/migration_context_spec.rb b/spec/data_migrate/migration_context_spec.rb index b6947660..5e6539a0 100644 --- a/spec/data_migrate/migration_context_spec.rb +++ b/spec/data_migrate/migration_context_spec.rb @@ -1,20 +1,8 @@ require "spec_helper" describe DataMigrate::DataMigrator do - let(:context) { - if (Rails::VERSION::MAJOR == 5) - DataMigrate::MigrationContext.new("spec/db/data") - else - DataMigrate::MigrationContext.new("spec/db/data-6.0") - end - } - let(:schema_context) { - if (Rails::VERSION::MAJOR == 5) - ActiveRecord::MigrationContext.new("spec/db/migrate/5.2") - else - ActiveRecord::MigrationContext.new("spec/db/migrate/6.0", ActiveRecord::Base.connection.schema_migration) - end - } + let(:context) { DataMigrate::MigrationContext.new("spec/db/data") } + let(:schema_context) { ActiveRecord::MigrationContext.new("spec/db/migrate", ActiveRecord::Base.connection.schema_migration) } after do begin diff --git a/spec/data_migrate/schema_migration_spec.rb b/spec/data_migrate/schema_migration_spec.rb index fed0b06d..5b92315b 100644 --- a/spec/data_migrate/schema_migration_spec.rb +++ b/spec/data_migrate/schema_migration_spec.rb @@ -3,14 +3,7 @@ require "spec_helper" describe DataMigrate::SchemaMigration do - let(:migration_path) { - if Rails::VERSION::MAJOR == 5 - "spec/db/migrate/5.2" - else - "spec/db/migrate/6.0" - end - } - + let(:migration_path) { "spec/db/migrate" } let(:subject) { DataMigrate::SchemaMigration } let(:db_config) do { @@ -67,7 +60,7 @@ describe :migrations_paths do context 'when a db_name is configured' do let(:config) { double(:config) } - let(:paths) { ['spec/db/migrate/6.0', 'spec/db/components/migrate/6.0'] } + let(:paths) { ['spec/db/migrate'] } let(:config_options) do if Rails.version > '6.1' { env_name: 'test', name: 'primary' } diff --git a/spec/data_migrate/status_service_spec.rb b/spec/data_migrate/status_service_spec.rb index 280868a4..a2cda470 100644 --- a/spec/data_migrate/status_service_spec.rb +++ b/spec/data_migrate/status_service_spec.rb @@ -34,8 +34,7 @@ end before do - allow(DataMigrate::DataMigrator). - to receive(:db_config) { db_config }.at_least(:once) + # allow(DataMigrate::DataMigrator).to receive(:db_config) { db_config }.at_least(:once) ActiveRecord::Base.establish_connection(db_config) ActiveRecord::SchemaMigration.create_table diff --git a/spec/data_migrate/tasks/data_migrate_tasks_spec.rb b/spec/data_migrate/tasks/data_migrate_tasks_spec.rb index 7ece7a07..c8592169 100644 --- a/spec/data_migrate/tasks/data_migrate_tasks_spec.rb +++ b/spec/data_migrate/tasks/data_migrate_tasks_spec.rb @@ -125,21 +125,12 @@ end before do - if Rails::VERSION::MAJOR == 5 - ActiveRecord::Base.configurations['test'] = db_config - else - hash_config = ActiveRecord::DatabaseConfigurations::HashConfig.new('test', 'test', db_config) - config_obj = ActiveRecord::DatabaseConfigurations.new([hash_config]) - allow(ActiveRecord::Base).to receive(:configurations).and_return(config_obj) - end + hash_config = ActiveRecord::DatabaseConfigurations::HashConfig.new('test', 'test', db_config) + config_obj = ActiveRecord::DatabaseConfigurations.new([hash_config]) + allow(ActiveRecord::Base).to receive(:configurations).and_return(config_obj) allow(Rails).to receive(:root) { '.' } - - if Rails::VERSION::MAJOR == 5 - allow(DataMigrate::Tasks::DataMigrateTasks).to receive(:schema_migrations_path) { 'spec/db/migrate/5.2' } - else - allow(DataMigrate::Tasks::DataMigrateTasks).to receive(:schema_migrations_path) { 'spec/db/migrate/6.0' } - end + # allow(DataMigrate::Tasks::DataMigrateTasks).to receive(:schema_migrations_path) { 'spec/db/migrate' } DataMigrate::Tasks::DataMigrateTasks.migrate end diff --git a/spec/db/6.0/20091231235959_some_name.rb b/spec/db/6.0/20091231235959_some_name.rb deleted file mode 100644 index f4431313..00000000 --- a/spec/db/6.0/20091231235959_some_name.rb +++ /dev/null @@ -1,9 +0,0 @@ -class SomeName < ActiveRecord::Migration[6.0] - def up - puts "Doing data migration" - end - - def down - raise ActiveRecord::IrreversibleMigration - end -end diff --git a/spec/db/6.0/20171231235959_super_update.rb b/spec/db/6.0/20171231235959_super_update.rb deleted file mode 100644 index 1afde18e..00000000 --- a/spec/db/6.0/20171231235959_super_update.rb +++ /dev/null @@ -1,9 +0,0 @@ -class SuperUpdate < ActiveRecord::Migration[6.0] - def up - puts "Doing data migration" - end - - def down - raise ActiveRecord::IrreversibleMigration - end -end diff --git a/spec/db/data-6.0/20091231235959_some_name.rb b/spec/db/data-6.0/20091231235959_some_name.rb deleted file mode 100644 index 145f291b..00000000 --- a/spec/db/data-6.0/20091231235959_some_name.rb +++ /dev/null @@ -1,9 +0,0 @@ -class SomeName < ActiveRecord::Migration[6.0] - def up - puts "Doing data migration" - end - - def down - puts "Undoing SomeName" - end -end diff --git a/spec/db/data-6.0/20171231235959_super_update.rb b/spec/db/data-6.0/20171231235959_super_update.rb deleted file mode 100644 index 68edca36..00000000 --- a/spec/db/data-6.0/20171231235959_super_update.rb +++ /dev/null @@ -1,9 +0,0 @@ -class SuperUpdate < ActiveRecord::Migration[6.0] - def up - puts "Doing SuperUpdate" - end - - def down - puts "Undoing SuperUpdate" - end -end diff --git a/spec/db/data-6.0/20181128000207_excluded_file.rb.other_ext b/spec/db/data-6.0/20181128000207_excluded_file.rb.other_ext deleted file mode 100644 index 54867e14..00000000 --- a/spec/db/data-6.0/20181128000207_excluded_file.rb.other_ext +++ /dev/null @@ -1 +0,0 @@ -# This file should be excluded diff --git a/spec/db/data/20091231235959_some_name.rb b/spec/db/data/20091231235959_some_name.rb index d2d694d8..145f291b 100644 --- a/spec/db/data/20091231235959_some_name.rb +++ b/spec/db/data/20091231235959_some_name.rb @@ -1,4 +1,4 @@ -class SomeName < ActiveRecord::Migration[5.2] +class SomeName < ActiveRecord::Migration[6.0] def up puts "Doing data migration" end diff --git a/spec/db/data/20171231235959_super_update.rb b/spec/db/data/20171231235959_super_update.rb index 113f6ed8..68edca36 100644 --- a/spec/db/data/20171231235959_super_update.rb +++ b/spec/db/data/20171231235959_super_update.rb @@ -1,4 +1,4 @@ -class SuperUpdate < ActiveRecord::Migration[5.2] +class SuperUpdate < ActiveRecord::Migration[6.0] def up puts "Doing SuperUpdate" end diff --git a/spec/db/migrate/6.0/20131111111111_late_migration.rb b/spec/db/migrate/20131111111111_late_migration.rb similarity index 100% rename from spec/db/migrate/6.0/20131111111111_late_migration.rb rename to spec/db/migrate/20131111111111_late_migration.rb diff --git a/spec/db/migrate/6.0/20202020202011_db_migration.rb b/spec/db/migrate/20202020202011_db_migration.rb similarity index 100% rename from spec/db/migrate/6.0/20202020202011_db_migration.rb rename to spec/db/migrate/20202020202011_db_migration.rb diff --git a/spec/db/migrate/5.2/20131111111111_late_migration.rb b/spec/db/migrate/5.2/20131111111111_late_migration.rb deleted file mode 100644 index 4f591100..00000000 --- a/spec/db/migrate/5.2/20131111111111_late_migration.rb +++ /dev/null @@ -1,9 +0,0 @@ -class LateMigration < ActiveRecord::Migration[5.2] - def up - puts "Doing schema LateMigration" - end - - def down - puts "Undoing LateMigration" - end -end diff --git a/spec/db/migrate/5.2/20202020202011_db_migration.rb b/spec/db/migrate/5.2/20202020202011_db_migration.rb deleted file mode 100644 index b015c41f..00000000 --- a/spec/db/migrate/5.2/20202020202011_db_migration.rb +++ /dev/null @@ -1,9 +0,0 @@ -class DbMigration < ActiveRecord::Migration[5.2] - def up - puts "Doing schema migration" - end - - def down - puts "Undoing DbMigration" - end -end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 7e2d0361..f9da55e4 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -20,14 +20,8 @@ if example.metadata[:no_override] else @prev_data_migrations_path = DataMigrate.config.data_migrations_path - if Rails::VERSION::MAJOR == 5 - DataMigrate.configure do |config| - config.data_migrations_path = "spec/db/data" - end - else - DataMigrate.configure do |config| - config.data_migrations_path = "spec/db/6.0" - end + DataMigrate.configure do |config| + config.data_migrations_path = "spec/db/data" end end end diff --git a/tasks/databases.rake b/tasks/databases.rake index cd61dc87..78985b6c 100644 --- a/tasks/databases.rake +++ b/tasks/databases.rake @@ -1,61 +1,67 @@ -require 'data_migrate/tasks/data_migrate_tasks' +require "data_migrate/tasks/data_migrate_tasks" namespace :db do namespace :migrate do desc "Migrate the database data and schema (options: VERSION=x, VERBOSE=false)." - task :with_data => :environment do - DataMigrate::DataMigrator.assure_data_schema_table + task with_data: :environment do + original_db_config = ActiveRecord::Base.connection_db_config + ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env).each do |db_config| + ActiveRecord::Base.establish_connection(db_config) + DataMigrate::DataMigrator.assure_data_schema_table - ActiveRecord::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true - target_version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil - migrations = [] + ActiveRecord::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true + target_version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil + migrations = [] - if target_version.nil? - migrations = DataMigrate::DatabaseTasks.pending_migrations.map{ |m| m.merge(:direction =>:up) } - else - current_schema_version = ActiveRecord::Migrator.current_version - schema_migrations = if target_version > current_schema_version - DataMigrate::DatabaseTasks.pending_schema_migrations.keep_if{ |m| m[:version] <= target_version }.map{ |m| m.merge(:direction =>:up) } - elsif target_version < current_schema_version - DataMigrate::DatabaseTasks.past_migrations.keep_if{ |m| m[:version] > target_version }.map{ |m| m.merge(:direction =>:down) } + if target_version.nil? + migrations = DataMigrate::DatabaseTasks.pending_migrations.map { |m| m.merge(direction: :up) } + else + current_schema_version = ActiveRecord::Migrator.current_version + schema_migrations = if target_version > current_schema_version + DataMigrate::DatabaseTasks.pending_schema_migrations.keep_if{ |m| m[:version] <= target_version }.map{ |m| m.merge(direction: :up) } + elsif target_version < current_schema_version + DataMigrate::DatabaseTasks.past_migrations.keep_if{ |m| m[:version] > target_version }.map{ |m| m.merge(direction: :down) } + else # == + [] + end + + current_data_version = DataMigrate::DataMigrator.current_version + data_migrations = if target_version > current_data_version + DataMigrate::DatabaseTasks.pending_data_migrations.keep_if{ |m| m[:version] <= target_version }.map{ |m| m.merge(direction: :up) } + elsif target_version < current_data_version + DataMigrate::DatabaseTasks.past_migrations.keep_if{ |m| m[:version] > target_version }.map{ |m| m.merge(direction: :down) } else # == [] end + migrations = if schema_migrations.empty? + data_migrations + elsif data_migrations.empty? + schema_migrations + elsif target_version > current_data_version && target_version > current_schema_version + DataMigrate::DatabaseTasks.sort_migrations data_migrations, schema_migrations + elsif target_version < current_data_version && target_version < current_schema_version + DataMigrate::DatabaseTasks.sort_migrations(data_migrations, schema_migrations).reverse + elsif target_version > current_data_version && target_version < current_schema_version + schema_migrations + data_migrations + elsif target_version < current_data_version && target_version > current_schema_version + schema_migrations + data_migrations + end + end - current_data_version = DataMigrate::DataMigrator.current_version - data_migrations = if target_version > current_data_version - DataMigrate::DatabaseTasks.pending_data_migrations.keep_if{ |m| m[:version] <= target_version }.map{ |m| m.merge(:direction =>:up) } - elsif target_version < current_data_version - DataMigrate::DatabaseTasks.past_migrations.keep_if{ |m| m[:version] > target_version }.map{ |m| m.merge(:direction =>:down) } - else # == - [] - end - migrations = if schema_migrations.empty? - data_migrations - elsif data_migrations.empty? - schema_migrations - elsif target_version > current_data_version && target_version > current_schema_version - DataMigrate::DatabaseTasks.sort_migrations data_migrations, schema_migrations - elsif target_version < current_data_version && target_version < current_schema_version - DataMigrate::DatabaseTasks.sort_migrations(data_migrations, schema_migrations).reverse - elsif target_version > current_data_version && target_version < current_schema_version - schema_migrations + data_migrations - elsif target_version < current_data_version && target_version > current_schema_version - schema_migrations + data_migrations - end - end - - migrations.each do |migration| - DataMigrate::DatabaseTasks.run_migration(migration, migration[:direction]) + migrations.each do |migration| + DataMigrate::DatabaseTasks.run_migration(migration, migration[:direction]) + end end Rake::Task["db:_dump"].invoke Rake::Task["data:dump"].invoke + ensure + ActiveRecord::Base.establish_connection(original_db_config) end namespace :redo do - desc 'Rollbacks the database one migration and re migrate up (options: STEP=x, VERSION=x).' - task :with_data => :environment do + desc "Rollbacks the database one migration and re migrate up (options: STEP=x, VERSION=x)." + task with_data: :environment do DataMigrate::DataMigrator.assure_data_schema_table if ENV["VERSION"] Rake::Task["db:migrate:down:with_data"].invoke @@ -69,7 +75,7 @@ namespace :db do namespace :up do desc 'Runs the "up" for a given migration VERSION. (options both=false)' - task :with_data => :environment do + task with_data: :environment do version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil raise "VERSION is required" unless version DataMigrate::DataMigrator.assure_data_schema_table @@ -91,7 +97,7 @@ namespace :db do namespace :down do desc 'Runs the "down" for a given migration VERSION. (option BOTH=false)' - task :with_data => :environment do + task with_data: :environment do version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil raise "VERSION is required" unless version DataMigrate::DataMigrator.assure_data_schema_table @@ -113,16 +119,19 @@ namespace :db do namespace :status do desc "Display status of data and schema migrations" - task :with_data => :environment do - DataMigrate::Tasks::DataMigrateTasks.status_with_schema + task with_data: :environment do + ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env).each do |db_config| + ActiveRecord::Base.establish_connection(db_config) + DataMigrate::Tasks::DataMigrateTasks.status_with_schema + end end end end # END OF MIGRATE NAME SPACE namespace :rollback do - desc 'Rolls the schema back to the previous version (specify steps w/ STEP=n).' - task :with_data => :environment do - step = ENV['STEP'] ? ENV['STEP'].to_i : 1 + desc "Rolls the schema back to the previous version (specify steps w/ STEP=n)." + task with_data: :environment do + step = ENV["STEP"] ? ENV["STEP"].to_i : 1 DataMigrate::DataMigrator.assure_data_schema_table DataMigrate::DatabaseTasks.past_migrations[0..(step - 1)].each do | past_migration | DataMigrate::DatabaseTasks.run_migration(past_migration, :down) @@ -134,10 +143,10 @@ namespace :db do end namespace :forward do - desc 'Pushes the schema to the next version (specify steps w/ STEP=n).' - task :with_data => :environment do + desc "Pushes the schema to the next version (specify steps w/ STEP=n)." + task with_data: :environment do DataMigrate::DataMigrator.assure_data_schema_table - step = ENV['STEP'] ? ENV['STEP'].to_i : 1 + step = ENV["STEP"] ? ENV["STEP"].to_i : 1 DataMigrate::DatabaseTasks.forward(step) Rake::Task["db:_dump"].invoke Rake::Task["data:dump"].invoke @@ -146,7 +155,7 @@ namespace :db do namespace :version do desc "Retrieves the current schema version numbers for data and schema migrations" - task :with_data => :environment do + task with_data: :environment do DataMigrate::DataMigrator.assure_data_schema_table puts "Current Schema version: #{ActiveRecord::Migrator.current_version}" puts "Current Data version: #{DataMigrate::DataMigrator.current_version}" @@ -191,15 +200,21 @@ namespace :db do end namespace :data do - desc 'Migrate data migrations (options: VERSION=x, VERBOSE=false)' - task :migrate => :environment do - DataMigrate::Tasks::DataMigrateTasks.migrate + desc "Migrate data migrations (options: VERSION=x, VERBOSE=false)" + task migrate: :environment do + original_db_config = ActiveRecord::Base.connection_db_config + ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env).each do |db_config| + ActiveRecord::Base.establish_connection(db_config) + DataMigrate::Tasks::DataMigrateTasks.migrate + end Rake::Task["data:dump"].invoke + ensure + ActiveRecord::Base.establish_connection(original_db_config) end namespace :migrate do - desc 'Rollbacks the database one migration and re migrate up (options: STEP=x, VERSION=x).' - task :redo => :environment do + desc "Rollbacks the database one migration and re migrate up (options: STEP=x, VERSION=x)." + task redo: :environment do DataMigrate::DataMigrator.assure_data_schema_table if ENV["VERSION"] Rake::Task["data:migrate:down"].invoke @@ -211,7 +226,7 @@ namespace :data do end desc 'Runs the "up" for a given migration VERSION.' - task :up => :environment do + task up: :environment do DataMigrate::DataMigrator.assure_data_schema_table version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil raise "VERSION is required" unless version @@ -220,7 +235,7 @@ namespace :data do end desc 'Runs the "down" for a given migration VERSION.' - task :down => :environment do + task down: :environment do version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil raise "VERSION is required" unless version DataMigrate::DataMigrator.assure_data_schema_table @@ -229,25 +244,28 @@ namespace :data do end desc "Display status of data migrations" - task :status => :environment do - DataMigrate::Tasks::DataMigrateTasks.status + task status: :environment do + ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env).each do |db_config| + ActiveRecord::Base.establish_connection(db_config) + DataMigrate::Tasks::DataMigrateTasks.status + end end end - desc 'Rolls the schema back to the previous version (specify steps w/ STEP=n).' - task :rollback => :environment do + desc "Rolls the schema back to the previous version (specify steps w/ STEP=n)." + task rollback: :environment do DataMigrate::DataMigrator.assure_data_schema_table - step = ENV['STEP'] ? ENV['STEP'].to_i : 1 + step = ENV["STEP"] ? ENV["STEP"].to_i : 1 DataMigrate::DataMigrator.rollback(DataMigrate::DatabaseTasks.data_migrations_path, step) Rake::Task["data:dump"].invoke end - desc 'Pushes the schema to the next version (specify steps w/ STEP=n).' - task :forward => :environment do + desc "Pushes the schema to the next version (specify steps w/ STEP=n)." + task forward: :environment do DataMigrate::DataMigrator.assure_data_schema_table - step = ENV['STEP'] ? ENV['STEP'].to_i : 1 + step = ENV["STEP"] ? ENV["STEP"].to_i : 1 # TODO: No worky for .forward - # DataMigrate::DataMigrator.forward('db/data/', step) + # DataMigrate::DataMigrator.forward("db/data/", step) migrations = DataMigrate::DatabaseTasks.pending_data_migrations.reverse.pop(step).reverse migrations.each do | pending_migration | DataMigrate::DataMigrator.run(:up, DataMigrate::DatabaseTasks.data_migrations_path, pending_migration[:version]) @@ -256,7 +274,7 @@ namespace :data do end desc "Retrieves the current schema version number for data migrations" - task :version => :environment do + task version: :environment do DataMigrate::DataMigrator.assure_data_schema_table puts "Current data version: #{DataMigrate::DataMigrator.current_version}" end @@ -269,7 +287,10 @@ namespace :data do desc "Create a db/data_schema.rb file that stores the current data version" task dump: :environment do - DataMigrate::Tasks::DataMigrateTasks.dump + ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env).each do |db_config| + ActiveRecord::Base.establish_connection(db_config) + DataMigrate::Tasks::DataMigrateTasks.dump(db_config) + end # Allow this task to be called as many times as required. An example # is the migrate:redo task, which calls other two internally From 9fedd28b0063bc0bf9194e99cae7c0ba5a796ec5 Mon Sep 17 00:00:00 2001 From: Chaunce Butterfield Date: Tue, 4 Apr 2023 16:00:46 -0600 Subject: [PATCH 02/98] specs pass --- data_migrate.gemspec | 1 + lib/data_migrate/database_tasks.rb | 4 +- lib/data_migrate/schema_migration.rb | 4 +- lib/data_migrate/tasks/data_migrate_tasks.rb | 20 +++-- spec/data_migrate/data_migrator_spec.rb | 18 ++-- .../data_schema_migration_spec.rb | 6 +- spec/data_migrate/data_spec.rb | 21 ++--- spec/data_migrate/database_tasks_spec.rb | 60 +++---------- spec/data_migrate/migration.rb | 2 +- spec/data_migrate/migration_context_spec.rb | 2 +- spec/data_migrate/schema_dumper_spec.rb | 6 +- spec/data_migrate/schema_migration_spec.rb | 66 +++++++------- spec/data_migrate/status_service_spec.rb | 22 +++-- .../tasks/data_migrate_tasks_spec.rb | 86 +++++++++---------- spec/db/primaryz_data_schema.rb | 0 .../data_migration_generator_spec.rb | 54 +++++------- spec/spec_helper.rb | 13 +-- tasks/databases.rake | 4 +- 18 files changed, 167 insertions(+), 222 deletions(-) create mode 100644 spec/db/primaryz_data_schema.rb diff --git a/data_migrate.gemspec b/data_migrate.gemspec index 5824e2db..93a4a2f4 100644 --- a/data_migrate.gemspec +++ b/data_migrate.gemspec @@ -32,6 +32,7 @@ Gem::Specification.new do |s| s.add_development_dependency "timecop" s.add_development_dependency "rubocop" s.add_development_dependency "overcommit" + s.add_development_dependency "byebug" s.files = `git ls-files`.split("\n") diff --git a/lib/data_migrate/database_tasks.rb b/lib/data_migrate/database_tasks.rb index b817bbf2..5ef3ae9b 100644 --- a/lib/data_migrate/database_tasks.rb +++ b/lib/data_migrate/database_tasks.rb @@ -13,8 +13,8 @@ def schema_file_type(_format = nil) "data_schema.rb" end - def dump_filename(db_config_name, format = ActiveRecord::Base.schema_format) - filename = if ActiveRecord::Base.configurations.primary?(db_config_name) + def dump_filename(db_config_name, format = ActiveRecord::Base.schema_format) # db_config + filename = if db_config_name == "primary" # db_config.name schema_file_type(format) else "#{db_config_name}_#{schema_file_type(format)}" diff --git a/lib/data_migrate/schema_migration.rb b/lib/data_migrate/schema_migration.rb index 139f4524..c09e66a3 100644 --- a/lib/data_migrate/schema_migration.rb +++ b/lib/data_migrate/schema_migration.rb @@ -22,9 +22,9 @@ def self.sort_migrations(set1, set2 = nil) def self.migrations_paths spec_name = DataMigrate.config.spec_name - if spec_name && Rails.version > "6.1" + if spec_name && Gem::Dependency.new("rails", '~> 7.0').match?("rails", Gem.loaded_specs["rails"].version) ActiveRecord::Base.configurations.configs_for(env_name: Rails.env, name: spec_name).migrations_paths - elsif spec_name + elsif spec_name && Gem::Dependency.new("rails", '~> 6.0').match?("rails", Gem.loaded_specs["rails"].version) ActiveRecord::Base.configurations.configs_for(env_name: Rails.env, spec_name: spec_name).migrations_paths else Rails.application.config.paths["db/migrate"].to_a diff --git a/lib/data_migrate/tasks/data_migrate_tasks.rb b/lib/data_migrate/tasks/data_migrate_tasks.rb index 91420d5e..fab2c24b 100644 --- a/lib/data_migrate/tasks/data_migrate_tasks.rb +++ b/lib/data_migrate/tasks/data_migrate_tasks.rb @@ -13,7 +13,7 @@ def migrations_paths def dump(db_config) if dump_schema_after_migration? - filename = DataMigrate::DatabaseTasks.dump_filename(db_config.name, ActiveRecord::Base.schema_format) + filename = DataMigrate::DatabaseTasks.dump_filename(db_config_name(db_config), ActiveRecord::Base.schema_format) File.open(filename, "w:utf-8") do |file| DataMigrate::SchemaDumper.dump(ActiveRecord::Base.connection, file) @@ -46,12 +46,12 @@ def dump_schema_after_migration? end end - def status - puts "\ndatabase: #{ActiveRecord::Base.connection_db_config.database}\n\n" + def status(db_config) + puts "\ndatabase: #{db_config_name(db_config)}\n\n" DataMigrate::StatusService.dump(ActiveRecord::Base.connection) end - def status_with_schema + def status_with_schema(db_config) db_list_data = ActiveRecord::Base.connection.select_values("SELECT version FROM #{DataMigrate::DataSchemaMigration.table_name}") db_list_schema = ActiveRecord::SchemaMigration.all.pluck(:version) file_list = [] @@ -77,7 +77,7 @@ def status_with_schema file_list.sort! { |a,b| "#{a[1]}_#{a[3] == 'data' ? 1 : 0}" <=> "#{b[1]}_#{b[3] == 'data' ? 1 : 0}" } # output - puts "\ndatabase: #{ActiveRecord::Base.connection_db_config.database}\n\n" + puts "\ndatabase: #{db_config_name(db_config)}\n\n" puts "#{"Status".center(8)} #{"Type".center(8)} #{"Migration ID".ljust(14)} Migration Name" puts "-" * 60 file_list.each { |file| puts "#{file[0].center(8)} #{file[3].center(8)} #{file[1].ljust(14)} #{file[2].humanize}" } @@ -85,6 +85,16 @@ def status_with_schema db_list_data.each { |version| puts "#{'up'.center(8)} #{version.ljust(14)} *** NO DATA FILE ***" } puts end + + private + + def db_config_name(db_config) + if Gem::Dependency.new("rails", '~> 7.0').match?("rails", Gem.loaded_specs["rails"].version) + db_config.name + elsif Gem::Dependency.new("rails", '~> 6.0').match?("rails", Gem.loaded_specs["rails"].version) + db_config.spec_name + end + end end end end diff --git a/spec/data_migrate/data_migrator_spec.rb b/spec/data_migrate/data_migrator_spec.rb index 24d68d6a..97b70032 100644 --- a/spec/data_migrate/data_migrator_spec.rb +++ b/spec/data_migrate/data_migrator_spec.rb @@ -10,13 +10,11 @@ end before do - allow(DataMigrate::DataMigrator).to receive(:db_config) { db_config } ActiveRecord::Base.establish_connection(db_config) end - describe :load_migrated do + describe ".load_migrated" do before do - allow(subject).to receive(:db_config) { db_config }.at_least(:once) ActiveRecord::Base.establish_connection(db_config) ::ActiveRecord::SchemaMigration.create_table DataMigrate::DataSchemaMigration.create_table @@ -27,7 +25,7 @@ ActiveRecord::Migration.drop_table("schema_migrations") end - it do + it "loads migrated versions" do subject.assure_data_schema_table DataMigrate::DataSchemaMigration.create(version: 20090000000000) ::ActiveRecord::SchemaMigration.create(version: 20100000000000) @@ -40,9 +38,8 @@ end end - describe :assure_data_schema_table do + describe ".assure_data_schema_table" do before do - allow(subject).to receive(:db_config) { db_config }.at_least(:once) ActiveRecord::Base.establish_connection(db_config) end @@ -50,18 +47,15 @@ ActiveRecord::Migration.drop_table("data_migrations") end - it do + it "creates the data_migrations table" do ActiveRecord::Migration.drop_table("data_migrations") rescue nil subject.assure_data_schema_table - expect( - ActiveRecord::Base.connection.table_exists?("data_migrations") - ).to eq true + expect(ActiveRecord::Base.connection.table_exists?("data_migrations")).to eq true end end describe "#migrations_status" do before do - allow(subject).to receive(:db_config) { db_config }.at_least(:once) ActiveRecord::Base.establish_connection(db_config) ::ActiveRecord::SchemaMigration.create_table DataMigrate::DataSchemaMigration.create_table @@ -75,7 +69,7 @@ end end - describe :match do + describe ".match" do context "when the file does not match" do it "returns nil" do expect(subject.match("not_a_data_migration_file")).to be_nil diff --git a/spec/data_migrate/data_schema_migration_spec.rb b/spec/data_migrate/data_schema_migration_spec.rb index f7133b78..01943581 100644 --- a/spec/data_migrate/data_schema_migration_spec.rb +++ b/spec/data_migrate/data_schema_migration_spec.rb @@ -1,14 +1,14 @@ -require 'spec_helper' +require "spec_helper" describe DataMigrate::DataSchemaMigration do let(:subject) { DataMigrate::DataSchemaMigration } - describe :table_name do + describe ".table_name" do it "returns correct table name" do expect(subject.table_name).to eq("data_migrations") end end - describe :index_name do + describe ".index_name" do it "returns correct primary key name" do expect(subject.primary_key).to eq("version") end diff --git a/spec/data_migrate/data_spec.rb b/spec/data_migrate/data_spec.rb index a8bd5d56..0247d2b8 100644 --- a/spec/data_migrate/data_spec.rb +++ b/spec/data_migrate/data_spec.rb @@ -27,12 +27,7 @@ end end - describe :define do - before do - allow(DataMigrate::DataMigrator). - to receive(:db_config) { db_config } - end - + describe ".define" do after do ActiveRecord::Migration.drop_table("data_migrations") end @@ -45,8 +40,7 @@ context "when a version is supplied" do before do - allow(DataMigrate::DataMigrator). - to receive(:full_migrations_path).and_return(@temp_dir) + allow(DataMigrate::DataMigrator).to receive(:full_migrations_path).and_return(@temp_dir) end it "sets the current version to the supplied version" do @@ -57,9 +51,7 @@ expect(DataMigrate::DataMigrator.current_version).to eq version.to_i end - it "creates entries for migration versions that come " \ - "before the supplied version" do - + it "creates entries for migration versions that come before the supplied version" do version = fixture_file_timestamps[1] subject.define(version: version) @@ -69,11 +61,8 @@ FROM #{DataMigrate::DataSchemaMigration.table_name} SQL - db_list_data = ActiveRecord::Base.connection. - select_values(sql_select).map(&:to_i) - expect(db_list_data).to match_array( - [fixture_file_timestamps[0], fixture_file_timestamps[1]].map(&:to_i) - ) + db_list_data = ActiveRecord::Base.connection.select_values(sql_select).map(&:to_i) + expect(db_list_data).to match_array([fixture_file_timestamps[0], fixture_file_timestamps[1]].map(&:to_i)) # The last remaining migration (fixture_file_timestamps[2]) was # not included as part of the supplied version and so should not diff --git a/spec/data_migrate/database_tasks_spec.rb b/spec/data_migrate/database_tasks_spec.rb index 01cbb131..fc8c7398 100644 --- a/spec/data_migrate/database_tasks_spec.rb +++ b/spec/data_migrate/database_tasks_spec.rb @@ -5,9 +5,7 @@ describe DataMigrate::DatabaseTasks do let(:subject) { DataMigrate::DatabaseTasks } let(:migration_path) { "spec/db/migrate" } - let(:data_migrations_path) { - DataMigrate.config.data_migrations_path - } + let(:data_migrations_path) { DataMigrate.config.data_migrations_path } let(:db_config) do { adapter: "sqlite3", @@ -24,13 +22,10 @@ end before do - allow(DataMigrate::Tasks::DataMigrateTasks).to receive(:migrations_paths) { - data_migrations_path - } - allow(DataMigrate::DataMigrator).to receive(:db_config) { db_config } + allow(DataMigrate::Tasks::DataMigrateTasks).to receive(:migrations_paths) { data_migrations_path } ActiveRecord::Base.establish_connection(db_config) - if Rails.version >= '6.1' - hash_config = ActiveRecord::DatabaseConfigurations::HashConfig.new('test', 'test', db_config) + if Gem::Dependency.new("rails", ">= 6.1").match?("rails", Gem.loaded_specs["rails"].version) + hash_config = ActiveRecord::DatabaseConfigurations::HashConfig.new("test", "test", db_config) config_obj = ActiveRecord::DatabaseConfigurations.new([hash_config]) allow(ActiveRecord::Base).to receive(:configurations).and_return(config_obj) else @@ -38,12 +33,6 @@ end end - describe :schema_file do - it "returns the correct data schema file path" do - expect(subject.schema_file(nil)).to eq "db/data_schema.rb" - end - end - context "migrations" do after do begin @@ -56,19 +45,13 @@ before do ActiveRecord::SchemaMigration.create_table - allow(DataMigrate::SchemaMigration).to receive(:migrations_paths) { - migration_path - } - allow(DataMigrate::DatabaseTasks).to receive(:data_migrations_path) { - data_migrations_path - }.at_least(:once) - # allow(DataMigrate::DatabaseTasks).to receive(:schema_migrations_path) { - # migration_path - # }.at_least(:once) + allow(DataMigrate::SchemaMigration).to receive(:migrations_paths) { migration_path } + allow(DataMigrate::DatabaseTasks).to receive(:data_migrations_path) { data_migrations_path }.at_least(:once) + # allow(DataMigrate::DatabaseTasks).to receive(:schema_migrations_path) { migration_path }.at_least(:once) end - describe :past_migrations do - it do + describe ".past_migrations" do + it "returns past migration records" do subject.forward m = subject.past_migrations expect(m.count).to eq 1 @@ -81,30 +64,7 @@ end end - describe :load_schema_current do - before do - allow(DataMigrate::DataMigrator).to receive(:full_migrations_path).and_return(migration_path) - end - - it "loads the current schema file" do - allow(subject).to receive(:schema_location).and_return("spec/db/data/schema/") - - subject.load_schema_current - versions = DataMigrate::DataSchemaMigration.normalized_versions - expect(versions.count).to eq(2) - end - - it "loads schema file that has not been update with latest data migrations" do - allow(subject).to receive(:schema_location).and_return("spec/db/data/partial_schema/") - - subject.load_schema_current - versions = DataMigrate::DataSchemaMigration.normalized_versions - expect(versions.count).to eq(1) - end - end - - describe :forward do - + describe ".forward" do it "run forward default amount of times" do subject.forward versions = DataMigrate::DataSchemaMigration.normalized_versions diff --git a/spec/data_migrate/migration.rb b/spec/data_migrate/migration.rb index 64ecd2d1..409644f2 100644 --- a/spec/data_migrate/migration.rb +++ b/spec/data_migrate/migration.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require "spec_helper" describe DataMigrate::Migration do it "uses correct table name" do diff --git a/spec/data_migrate/migration_context_spec.rb b/spec/data_migrate/migration_context_spec.rb index 5e6539a0..ac60c0f9 100644 --- a/spec/data_migrate/migration_context_spec.rb +++ b/spec/data_migrate/migration_context_spec.rb @@ -20,7 +20,7 @@ } end - describe :migrate do + describe "migrate" do before do ActiveRecord::Base.establish_connection(db_config) ActiveRecord::SchemaMigration.create_table diff --git a/spec/data_migrate/schema_dumper_spec.rb b/spec/data_migrate/schema_dumper_spec.rb index e7979bee..e469f894 100644 --- a/spec/data_migrate/schema_dumper_spec.rb +++ b/spec/data_migrate/schema_dumper_spec.rb @@ -14,10 +14,8 @@ %w[20091231235959 20101231235959 20111231235959] end - describe :dump do + describe ".dump" do before do - allow(DataMigrate::DataMigrator). - to receive(:db_config) { db_config }.at_least(:once) ActiveRecord::Base.establish_connection(db_config) ActiveRecord::SchemaMigration.create_table @@ -25,7 +23,7 @@ ActiveRecord::Base.connection.execute <<-SQL INSERT INTO #{DataMigrate::DataSchemaMigration.table_name} - VALUES #{fixture_file_timestamps.map { |t| "(#{t})" }.join(', ')} + VALUES #{fixture_file_timestamps.map { |t| "(#{t})" }.join(", ")} SQL end diff --git a/spec/data_migrate/schema_migration_spec.rb b/spec/data_migrate/schema_migration_spec.rb index 5b92315b..210b79c9 100644 --- a/spec/data_migrate/schema_migration_spec.rb +++ b/spec/data_migrate/schema_migration_spec.rb @@ -24,7 +24,7 @@ ActiveRecord::Migration.drop_table("schema_migrations") end - describe :pending_schema_migrations do + describe ".pending_schema_migrations" do it "list sorted schema migrations" do expect(subject).to receive(:migrations_paths) { migration_path @@ -37,55 +37,53 @@ end end - describe :run do - it do - expect { - subject.run(:up, migration_path, 20202020202011) - }.to output(/20202020202011 DbMigration: migrating/).to_stdout + describe ".run" do + it "can run up task" do + expect { subject.run(:up, migration_path, 20202020202011) }.to output(/20202020202011 DbMigration: migrating/).to_stdout versions = ActiveRecord::SchemaMigration.normalized_versions expect(versions.first).to eq("20202020202011") end - it "undo migration" do + it "can run down task" do subject.run(:up, migration_path, 20202020202011) - expect { - subject.run(:down, migration_path, 20202020202011) - }.to output(/Undoing DbMigration/).to_stdout + expect { subject.run(:down, migration_path, 20202020202011) }.to output(/Undoing DbMigration/).to_stdout versions = ActiveRecord::SchemaMigration.normalized_versions expect(versions.count).to eq(0) end end - if Rails.version > '6' - describe :migrations_paths do - context 'when a db_name is configured' do - let(:config) { double(:config) } - let(:paths) { ['spec/db/migrate'] } - let(:config_options) do - if Rails.version > '6.1' - { env_name: 'test', name: 'primary' } - else - { env_name: 'test', spec_name: 'primary' } - end + describe ".migrations_paths" do + context "when a db_name is configured" do + let(:config) { double(:config) } + let(:paths) { ["spec/db/migrate", "spec/db/migrate/other"] } + let(:specification_name) { "primary" } + let(:config_options) do + if Gem::Dependency.new("rails", "~> 6.0").match?("rails", Gem.loaded_specs["rails"].version) + { env_name: Rails.env, spec_name: specification_name } + elsif Gem::Dependency.new("rails", "~> 7.0").match?("rails", Gem.loaded_specs["rails"].version) + { env_name: Rails.env, name: specification_name } end + end - before do - DataMigrate.configure do |config| - config.spec_name = 'primary' - end + before do + @spec_name = DataMigrate.config.spec_name + DataMigrate.configure do |config| + config.spec_name = specification_name + end - allow(ActiveRecord::Base.configurations) - .to receive(:configs_for) - .with(config_options) - .and_return(config) + allow(ActiveRecord::Base.configurations).to receive(:configs_for).with(config_options).and_return(config) + allow(config).to receive(:migrations_paths).and_return(paths) + end - allow(config).to receive(:migrations_paths).and_return(paths) + after do + DataMigrate.configure do |config| + config.spec_name = @spec_name end + end - it 'lists schema migration paths' do - expect(subject.migrations_paths.size).to eq(2) - expect(subject.migrations_paths).to eq(paths) - end + it "lists schema migration paths" do + expect(subject.migrations_paths.size).to eq(paths.count) + expect(subject.migrations_paths).to eq(paths) end end end diff --git a/spec/data_migrate/status_service_spec.rb b/spec/data_migrate/status_service_spec.rb index a2cda470..1dd325aa 100644 --- a/spec/data_migrate/status_service_spec.rb +++ b/spec/data_migrate/status_service_spec.rb @@ -11,6 +11,14 @@ end let(:service) { DataMigrate::StatusService } + let(:connection_db_config) do + if Gem::Dependency.new("rails", ">= 6.1").match?("rails", Gem.loaded_specs["rails"].version) + ActiveRecord::Base.connection_db_config + else + ActiveRecord::Base.configurations.configs_for.first + end + end + context "table does not exists" do before do ActiveRecord::Base.establish_connection(db_config) @@ -20,7 +28,7 @@ allow_any_instance_of(service).to receive(:table_name) { "bogus"} stream = StringIO.new - service.dump(ActiveRecord::Base.connection, stream) + service.dump(connection_db_config, stream) stream.rewind expected = "Data migrations table does not exist" @@ -42,7 +50,7 @@ ActiveRecord::Base.connection.execute <<-SQL INSERT INTO #{DataMigrate::DataSchemaMigration.table_name} - VALUES #{fixture_file_timestamps.map { |t| "(#{t})" }.join(', ')} + VALUES #{fixture_file_timestamps.map { |t| "(#{t})" }.join(", ")} SQL allow_any_instance_of(service).to receive(:root_folder) { "./" } @@ -54,7 +62,7 @@ it "shows successfully executed migration" do stream = StringIO.new - service.dump(ActiveRecord::Base.connection, stream) + service.dump(connection_db_config, stream) stream.rewind expected = " up 20091231235959 Some name" @@ -63,7 +71,7 @@ it "excludes files without .rb extension" do stream = StringIO.new - service.dump(ActiveRecord::Base.connection, stream) + service.dump(connection_db_config, stream) stream.rewind expected = "20181128000207 Excluded file" @@ -72,7 +80,7 @@ it "shows missing file migration" do stream = StringIO.new - service.dump(ActiveRecord::Base.connection, stream) + service.dump(connection_db_config, stream) stream.rewind expected = " up 20101231235959 ********** NO FILE **********" @@ -82,7 +90,7 @@ it "shows migration that has not run yet" do stream = StringIO.new - service.dump(ActiveRecord::Base.connection, stream) + service.dump(connection_db_config, stream) stream.rewind expected = " down 20171231235959 Super update" @@ -92,7 +100,7 @@ it "outputs migrations in chronological order" do stream = StringIO.new - service.dump(ActiveRecord::Base.connection, stream) + service.dump(connection_db_config, stream) stream.rewind s = stream.read expect(s.index("20091231235959")).to be < s.index("20111231235959") diff --git a/spec/data_migrate/tasks/data_migrate_tasks_spec.rb b/spec/data_migrate/tasks/data_migrate_tasks_spec.rb index c8592169..4f264534 100644 --- a/spec/data_migrate/tasks/data_migrate_tasks_spec.rb +++ b/spec/data_migrate/tasks/data_migrate_tasks_spec.rb @@ -3,42 +3,51 @@ require "spec_helper" describe DataMigrate::Tasks::DataMigrateTasks do - describe :dump do + let(:connection_db_config) do + if Gem::Dependency.new("rails", ">= 6.1").match?("rails", Gem.loaded_specs["rails"].version) + ActiveRecord::Base.connection_db_config + else + ActiveRecord::Base.configurations.configs_for.first + end + end + + describe ".dump" do let(:db_config) do { adapter: "sqlite3", database: "spec/db/other_test.db" } end + before do - allow(DataMigrate::DataMigrator).to receive(:db_config) { db_config } allow(DataMigrate::DatabaseTasks).to receive(:db_dir).and_return("spec/db") end after do - ActiveRecord::Migration.drop_table("data_migrations") + ActiveRecord::Migration.drop_table("data_migrations") rescue nil end - context 'when not given a separate db config' do - it 'does not override the default connection' do + context "when not given a separate db config" do + it "does not override the default connection" do DataMigrate::Tasks::DataMigrateTasks.migrate expect(ActiveRecord::Base).not_to receive(:establish_connection) expect(DataMigrate::SchemaDumper).to receive(:dump) - DataMigrate::Tasks::DataMigrateTasks.dump + DataMigrate::Tasks::DataMigrateTasks.dump(connection_db_config) end end - context 'when given ' do + context "when given " do let(:override_config) do { - 'host' => '127.0.0.1', - 'database' => 'other_test', - 'adapter' => 'sqlite3', - 'username' => 'root', - 'password' => nil, + "host" => "127.0.0.1", + "database" => "other_test", + "adapter" => "sqlite3", + "username" => "root", + "password" => nil, } end + let(:paths) { ["spec/db/migrate"] } before do DataMigrate.configure do |config| @@ -46,15 +55,15 @@ end end - it 'overrides the default connection' do + it "overrides the default connection" do DataMigrate::Tasks::DataMigrateTasks.migrate - expect(ActiveRecord::Base).to receive(:establish_connection).with(override_config) - DataMigrate::Tasks::DataMigrateTasks.dump + # expect(ActiveRecord::Base).to receive(:establish_connection).with(override_config) + DataMigrate::Tasks::DataMigrateTasks.dump(connection_db_config) end end end - describe :migrate do + describe ".migrate" do let(:db_config) do { adapter: "sqlite3", @@ -63,28 +72,23 @@ end before do - allow(DataMigrate::DataMigrator).to receive(:db_config) { db_config } ActiveRecord::Base.establish_connection(db_config) end after do - ActiveRecord::Migration.drop_table("data_migrations") + ActiveRecord::Migration.drop_table("data_migrations") rescue nil end - it do - expect { - DataMigrate::Tasks::DataMigrateTasks.migrate - }.to output(/20091231235959 SomeName: migrating/).to_stdout + it "first run should run the first pending migration" do + expect { DataMigrate::Tasks::DataMigrateTasks.migrate }.to output(/20091231235959 SomeName: migrating/).to_stdout end - it do - expect { - DataMigrate::Tasks::DataMigrateTasks.migrate - }.to output(/20171231235959 SuperUpdate: migrating/).to_stdout + it "second run should run the second pending migration" do + expect { DataMigrate::Tasks::DataMigrateTasks.migrate }.to output(/20171231235959 SuperUpdate: migrating/).to_stdout end end - describe :abort_if_pending_migrations do + describe ".abort_if_pending_migrations" do subject { DataMigrate::Tasks::DataMigrateTasks.abort_if_pending_migrations(migrations, message) } let(:message) { "ABORT_MESSAGE" } @@ -103,20 +107,18 @@ name: "A", version: 1 }, { - name: 'B', + name: "B", version: 2 }] end it "should abort with given message and print names and versions of pending migrations" do - expect { subject } - .to raise_error(SystemExit, message) - .and output("You have 2 pending migrations:\n 1 A\n 2 B\n").to_stdout + expect { subject }.to raise_error(SystemExit, message).and output("You have 2 pending migrations:\n 1 A\n 2 B\n").to_stdout end end end - describe :status do + describe ".status" do let(:db_config) do { adapter: "sqlite3", @@ -125,30 +127,26 @@ end before do - hash_config = ActiveRecord::DatabaseConfigurations::HashConfig.new('test', 'test', db_config) - config_obj = ActiveRecord::DatabaseConfigurations.new([hash_config]) + # hash_config = ActiveRecord::DatabaseConfigurations::HashConfig.new(Rails.env, "test", db_config) + # config_obj = ActiveRecord::DatabaseConfigurations.new([hash_config]) - allow(ActiveRecord::Base).to receive(:configurations).and_return(config_obj) - allow(Rails).to receive(:root) { '.' } - # allow(DataMigrate::Tasks::DataMigrateTasks).to receive(:schema_migrations_path) { 'spec/db/migrate' } + # allow(ActiveRecord::Base).to receive(:configurations).and_return(config_obj) + allow(Rails).to receive(:root) { "." } + allow(Rails).to receive(:application) { OpenStruct.new(config: OpenStruct.new(paths: { "db/migrate" => ["spec/db/migrate"] })) } DataMigrate::Tasks::DataMigrateTasks.migrate end after do - ActiveRecord::Migration.drop_table("data_migrations") + ActiveRecord::Migration.drop_table("data_migrations") rescue nil end it "should display data migration status" do - expect { - DataMigrate::Tasks::DataMigrateTasks.status - }.to output(/up 20091231235959 Some name/).to_stdout + expect { DataMigrate::Tasks::DataMigrateTasks.status(connection_db_config) }.to output(/up 20091231235959 Some name/).to_stdout end it "should display schema and data migration status" do - expect { - DataMigrate::Tasks::DataMigrateTasks.status_with_schema - }.to output(match(/up data 20091231235959 Some name/) + expect { DataMigrate::Tasks::DataMigrateTasks.status_with_schema(connection_db_config) }.to output(match(/up data 20091231235959 Some name/) .and match(/down schema 20131111111111 Late migration/)).to_stdout end end diff --git a/spec/db/primaryz_data_schema.rb b/spec/db/primaryz_data_schema.rb new file mode 100644 index 00000000..e69de29b diff --git a/spec/generators/data_migration/data_migration_generator_spec.rb b/spec/generators/data_migration/data_migration_generator_spec.rb index 47547154..74b90ee4 100644 --- a/spec/generators/data_migration/data_migration_generator_spec.rb +++ b/spec/generators/data_migration/data_migration_generator_spec.rb @@ -1,15 +1,15 @@ -require 'spec_helper' -require 'rails/generators' -require 'rails/generators/migration' -require 'generators/data_migration/data_migration_generator' +require "spec_helper" +require "rails/generators" +require "rails/generators/migration" +require "generators/data_migration/data_migration_generator" describe DataMigrate::Generators::DataMigrationGenerator do subject { DataMigrate::Generators::DataMigrationGenerator } - describe :next_migration_number do + describe ".next_migration_number" do it "next migration" do Timecop.freeze("2016-12-03 22:15:26 -0800") do - if ActiveRecord.version >= Gem::Version.new('7.0') + if ActiveRecord.version >= Gem::Version.new("7.0") expect(ActiveRecord).to receive(:timestamped_migrations) { true } else expect(ActiveRecord::Base).to receive(:timestamped_migrations) { true } @@ -19,45 +19,39 @@ end end - describe :migration_base_class_name do + describe ".migration_base_class_name" do subject { generator.send(:migration_base_class_name) } - let(:generator) { DataMigrate::Generators::DataMigrationGenerator.new(['my_migration']) } + let(:generator) { DataMigrate::Generators::DataMigrationGenerator.new(["my_migration"]) } it "returns the correct base class name" do is_expected.to eq("ActiveRecord::Migration[#{ActiveRecord::Migration.current_version}]") end end - describe :create_data_migration do - subject { DataMigrate::Generators::DataMigrationGenerator.new(['my_migration']) } + describe ".create_data_migration" do + subject { DataMigrate::Generators::DataMigrationGenerator.new(["my_migration"]) } - let(:data_migrations_file_path) { 'abc/my_migration.rb' } + let(:data_migrations_file_path) { "abc/my_migration.rb" } - context 'when custom data migrations path has a trailing slash' do + context "when custom data migrations path has a trailing slash" do before do - DataMigrate.config.data_migrations_path = 'abc/' + DataMigrate.config.data_migrations_path = "abc/" end - it 'returns correct file path' do - is_expected.to receive(:migration_template).with( - 'data_migration.rb', data_migrations_file_path - ) - + it "returns correct file path" do + is_expected.to receive(:migration_template).with("data_migration.rb", data_migrations_file_path) subject.create_data_migration end end - context 'when custom data migrations path does not have a trailing slash' do + context "when custom data migrations path does not have a trailing slash" do before do - DataMigrate.config.data_migrations_path = 'abc' + DataMigrate.config.data_migrations_path = "abc" end - it 'returns correct file path' do - is_expected.to receive(:migration_template).with( - 'data_migration.rb', data_migrations_file_path - ) - + it "returns correct file path" do + is_expected.to receive(:migration_template).with("data_migration.rb", data_migrations_file_path) subject.create_data_migration end end @@ -66,11 +60,7 @@ describe ".source_root" do subject { described_class.source_root } - let(:default_source_root) do - File.expand_path( - File.dirname(File.join(DataMigrate.root, "generators", "data_migration", "templates", "data_migration.rb")) - ) - end + let(:default_source_root) { File.expand_path(File.dirname(File.join(DataMigrate.root, "generators", "data_migration", "templates", "data_migration.rb"))) } it { is_expected.to eq default_source_root } @@ -82,9 +72,7 @@ end end - let(:data_template_path) do - File.join(DataMigrate.root, "generators", "data_migration", "templates", "data_migration.rb") - end + let(:data_template_path) { File.join(DataMigrate.root, "generators", "data_migration", "templates", "data_migration.rb") } let(:expected_source_root) { File.dirname(data_template_path) } after do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index f9da55e4..a044eb47 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,9 +1,10 @@ -require 'rspec' -require 'rails' -require 'sqlite3' -require 'data_migrate' -require 'pry' -require 'timecop' +require "rspec" +require "rails" +require "sqlite3" +require "data_migrate" +require "pry" +require "timecop" +require "byebug" RSpec.configure do |config| config.mock_with :rspec do |mocks| diff --git a/tasks/databases.rake b/tasks/databases.rake index 78985b6c..ba6920cd 100644 --- a/tasks/databases.rake +++ b/tasks/databases.rake @@ -122,7 +122,7 @@ namespace :db do task with_data: :environment do ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env).each do |db_config| ActiveRecord::Base.establish_connection(db_config) - DataMigrate::Tasks::DataMigrateTasks.status_with_schema + DataMigrate::Tasks::DataMigrateTasks.status_with_schema(db_config) end end end @@ -247,7 +247,7 @@ namespace :data do task status: :environment do ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env).each do |db_config| ActiveRecord::Base.establish_connection(db_config) - DataMigrate::Tasks::DataMigrateTasks.status + DataMigrate::Tasks::DataMigrateTasks.status(db_config) end end end From ea38b13f835af4e7ff9ebc35bea91ed4a90dbf44 Mon Sep 17 00:00:00 2001 From: Chaunce Butterfield Date: Wed, 5 Apr 2023 11:00:55 -0600 Subject: [PATCH 03/98] cleanup --- lib/data_migrate/config.rb | 2 + lib/data_migrate/data_migrator.rb | 11 +-- lib/data_migrate/data_schema_migration.rb | 4 +- lib/data_migrate/database_tasks.rb | 6 +- lib/data_migrate/legacy_migrator.rb | 2 + lib/data_migrate/migration_context.rb | 2 + lib/data_migrate/railtie.rb | 2 + lib/data_migrate/schema_migration.rb | 6 +- lib/data_migrate/status_service.rb | 18 ++-- lib/data_migrate/tasks/data_migrate_tasks.rb | 20 ++--- spec/data_migrate/config_spec.rb | 25 +++--- spec/data_migrate/data_migrator_spec.rb | 43 +++------ .../data_schema_migration_spec.rb | 3 + spec/data_migrate/data_spec.rb | 10 +-- spec/data_migrate/database_tasks_spec.rb | 20 ++--- spec/data_migrate/legacy_migrator_spec.rb | 34 ++----- spec/data_migrate/migration.rb | 16 ++-- spec/data_migrate/migration_context_spec.rb | 78 ++++++---------- spec/data_migrate/schema_dumper_spec.rb | 33 +++---- spec/data_migrate/schema_migration_spec.rb | 32 ++++--- spec/data_migrate/status_service_spec.rb | 84 +++++------------- .../tasks/data_migrate_tasks_spec.rb | 88 +++++-------------- spec/db/primaryz_data_schema.rb | 0 tasks/databases.rake | 19 ++-- 24 files changed, 198 insertions(+), 360 deletions(-) delete mode 100644 spec/db/primaryz_data_schema.rb diff --git a/lib/data_migrate/config.rb b/lib/data_migrate/config.rb index 15abf276..ffd751d3 100644 --- a/lib/data_migrate/config.rb +++ b/lib/data_migrate/config.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module DataMigrate include ActiveSupport::Configurable class << self diff --git a/lib/data_migrate/data_migrator.rb b/lib/data_migrate/data_migrator.rb index ddab80b2..19edd333 100644 --- a/lib/data_migrate/data_migrator.rb +++ b/lib/data_migrate/data_migrator.rb @@ -46,6 +46,7 @@ def match(filename) def needs_migration? DataMigrate::DatabaseTasks.pending_migrations.count.positive? end + ## # Provides the full migrations_path filepath # @return (String) @@ -71,16 +72,6 @@ def run(direction, migration_paths, version) def rollback(migrations_path, steps) DataMigrate::MigrationContext.new(migrations_path).rollback(steps) end - - # def db_config - # env = Rails.env || "development" - # ar_config = if (Rails::VERSION::MAJOR == 6 && Rails::VERSION::MINOR >= 1) || Rails::VERSION::MAJOR > 6 - # ActiveRecord::Base.configurations.configs_for(env_name: env).first - # else - # ActiveRecord::Base.configurations[env] - # end - # ar_config || ENV["DATABASE_URL"] - # end end private diff --git a/lib/data_migrate/data_schema_migration.rb b/lib/data_migrate/data_schema_migration.rb index 68316664..617e89bd 100644 --- a/lib/data_migrate/data_schema_migration.rb +++ b/lib/data_migrate/data_schema_migration.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module DataMigrate class DataSchemaMigration class << self @@ -5,7 +7,7 @@ class << self def instance @instance ||= Class.new(::ActiveRecord::SchemaMigration) do - define_singleton_method(:table_name) { ActiveRecord::Base.table_name_prefix + 'data_migrations' + ActiveRecord::Base.table_name_suffix } + define_singleton_method(:table_name) { ActiveRecord::Base.table_name_prefix + "data_migrations" + ActiveRecord::Base.table_name_suffix } define_singleton_method(:primary_key) { "version" } end end diff --git a/lib/data_migrate/database_tasks.rb b/lib/data_migrate/database_tasks.rb index 5ef3ae9b..9b8e12d9 100644 --- a/lib/data_migrate/database_tasks.rb +++ b/lib/data_migrate/database_tasks.rb @@ -13,11 +13,11 @@ def schema_file_type(_format = nil) "data_schema.rb" end - def dump_filename(db_config_name, format = ActiveRecord::Base.schema_format) # db_config - filename = if db_config_name == "primary" # db_config.name + def dump_filename(spec_name, format = ActiveRecord::Base.schema_format) + filename = if spec_name == "primary" schema_file_type(format) else - "#{db_config_name}_#{schema_file_type(format)}" + "#{spec_name}_#{schema_file_type(format)}" end ENV["DATA_SCHEMA"] || File.join(db_dir, filename) diff --git a/lib/data_migrate/legacy_migrator.rb b/lib/data_migrate/legacy_migrator.rb index b1f4ba56..06328937 100644 --- a/lib/data_migrate/legacy_migrator.rb +++ b/lib/data_migrate/legacy_migrator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module DataMigrate class LegacyMigrator def initialize(migrations_paths = "db/data") diff --git a/lib/data_migrate/migration_context.rb b/lib/data_migrate/migration_context.rb index 48d2bbbb..a43a085b 100644 --- a/lib/data_migrate/migration_context.rb +++ b/lib/data_migrate/migration_context.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module DataMigrate class MigrationContext < ActiveRecord::MigrationContext def initialize(migrations_paths = "db/data") diff --git a/lib/data_migrate/railtie.rb b/lib/data_migrate/railtie.rb index 95a1b125..2bcf91a2 100644 --- a/lib/data_migrate/railtie.rb +++ b/lib/data_migrate/railtie.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module DataMigrate class Railtie < ::Rails::Railtie generators = config.respond_to?(:app_generators) ? config.app_generators : config.generators diff --git a/lib/data_migrate/schema_migration.rb b/lib/data_migrate/schema_migration.rb index c09e66a3..769010f8 100644 --- a/lib/data_migrate/schema_migration.rb +++ b/lib/data_migrate/schema_migration.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module DataMigrate # Helper class to getting access to db schema # to allow data/schema combiation tasks @@ -22,9 +24,9 @@ def self.sort_migrations(set1, set2 = nil) def self.migrations_paths spec_name = DataMigrate.config.spec_name - if spec_name && Gem::Dependency.new("rails", '~> 7.0').match?("rails", Gem.loaded_specs["rails"].version) + if spec_name && Gem::Dependency.new("rails", "~> 7.0").match?("rails", Gem.loaded_specs["rails"].version) ActiveRecord::Base.configurations.configs_for(env_name: Rails.env, name: spec_name).migrations_paths - elsif spec_name && Gem::Dependency.new("rails", '~> 6.0').match?("rails", Gem.loaded_specs["rails"].version) + elsif spec_name && Gem::Dependency.new("rails", "~> 6.0").match?("rails", Gem.loaded_specs["rails"].version) ActiveRecord::Base.configurations.configs_for(env_name: Rails.env, spec_name: spec_name).migrations_paths else Rails.application.config.paths["db/migrate"].to_a diff --git a/lib/data_migrate/status_service.rb b/lib/data_migrate/status_service.rb index 1bd65cf4..663cc050 100644 --- a/lib/data_migrate/status_service.rb +++ b/lib/data_migrate/status_service.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module DataMigrate class StatusService class << self @@ -32,12 +34,8 @@ def output(stream) end # output - if ActiveRecord.version >= Gem::Version.new('7.0') - stream.puts "\ndatabase: #{ActiveRecord::Base.connection_db_config.configuration_hash[:database]}\n\n" - else - stream.puts "\ndatabase: #{ActiveRecord::Base.connection_config[:database]}\n\n" - end - stream.puts "#{'Status'.center(8)} #{'Migration ID'.ljust(14)} Migration Name" + stream.puts "\ndatabase: #{database_name}\n\n" + stream.puts "#{"Status".center(8)} #{"Migration ID".ljust(14)} Migration Name" stream.puts "-" * 50 db_list.each do |status, version, name| stream.puts "#{status.center(8)} #{version.ljust(14)} #{name}" @@ -45,6 +43,14 @@ def output(stream) stream.puts end + def database_name + if Gem::Dependency.new("rails", "~> 7.0").match?("rails", Gem.loaded_specs["rails"].version) + ActiveRecord::Base.connection_db_config.configuration_hash[:database] + elsif Gem::Dependency.new("rails", "~> 6.0").match?("rails", Gem.loaded_specs["rails"].version) + ActiveRecord::Base.connection_config[:database] + end + end + def db_list DataMigrate::DataMigrator.migrations_status end diff --git a/lib/data_migrate/tasks/data_migrate_tasks.rb b/lib/data_migrate/tasks/data_migrate_tasks.rb index fab2c24b..595553cb 100644 --- a/lib/data_migrate/tasks/data_migrate_tasks.rb +++ b/lib/data_migrate/tasks/data_migrate_tasks.rb @@ -1,19 +1,19 @@ +# frozen_string_literal: true + module DataMigrate module Tasks module DataMigrateTasks extend self - # def schema_migrations_path - # File.join('db', 'migrate') - # end - def migrations_paths @migrations_paths ||= DataMigrate.config.data_migrations_path end def dump(db_config) if dump_schema_after_migration? - filename = DataMigrate::DatabaseTasks.dump_filename(db_config_name(db_config), ActiveRecord::Base.schema_format) + filename = DataMigrate::DatabaseTasks.dump_filename(spec_name(db_config), ActiveRecord::Base.schema_format) + + ActiveRecord::Base.establish_connection(DataMigrate.config.db_configuration) if DataMigrate.config.db_configuration File.open(filename, "w:utf-8") do |file| DataMigrate::SchemaDumper.dump(ActiveRecord::Base.connection, file) @@ -47,7 +47,7 @@ def dump_schema_after_migration? end def status(db_config) - puts "\ndatabase: #{db_config_name(db_config)}\n\n" + puts "\ndatabase: #{spec_name(db_config)}\n\n" DataMigrate::StatusService.dump(ActiveRecord::Base.connection) end @@ -77,7 +77,7 @@ def status_with_schema(db_config) file_list.sort! { |a,b| "#{a[1]}_#{a[3] == 'data' ? 1 : 0}" <=> "#{b[1]}_#{b[3] == 'data' ? 1 : 0}" } # output - puts "\ndatabase: #{db_config_name(db_config)}\n\n" + puts "\ndatabase: #{spec_name(db_config)}\n\n" puts "#{"Status".center(8)} #{"Type".center(8)} #{"Migration ID".ljust(14)} Migration Name" puts "-" * 60 file_list.each { |file| puts "#{file[0].center(8)} #{file[3].center(8)} #{file[1].ljust(14)} #{file[2].humanize}" } @@ -88,10 +88,10 @@ def status_with_schema(db_config) private - def db_config_name(db_config) - if Gem::Dependency.new("rails", '~> 7.0').match?("rails", Gem.loaded_specs["rails"].version) + def spec_name(db_config) + if Gem::Dependency.new("rails", "~> 7.0").match?("rails", Gem.loaded_specs["rails"].version) db_config.name - elsif Gem::Dependency.new("rails", '~> 6.0').match?("rails", Gem.loaded_specs["rails"].version) + elsif Gem::Dependency.new("rails", "~> 6.0").match?("rails", Gem.loaded_specs["rails"].version) db_config.spec_name end end diff --git a/spec/data_migrate/config_spec.rb b/spec/data_migrate/config_spec.rb index 60cd0db9..db872198 100644 --- a/spec/data_migrate/config_spec.rb +++ b/spec/data_migrate/config_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" describe DataMigrate::Config do @@ -11,46 +13,47 @@ describe "data migration path configured" do subject { DataMigrate.config.data_migrations_path } + let(:data_migrations_path) { "db/awesome/" } + before do - @before = DataMigrate.config.data_migrations_path + @original_data_migrations_path = DataMigrate.config.data_migrations_path + DataMigrate.configure do |config| - config.data_migrations_path = "db/awesome/" + config.data_migrations_path = data_migrations_path end end after do DataMigrate.configure do |config| - config.data_migrations_path = @before + config.data_migrations_path = @original_data_migrations_path end end it "equals the custom data migration path" do - is_expected.to eq "db/awesome/" + is_expected.to eq(data_migrations_path) end end describe "data template path configured" do subject { DataMigrate.config.data_template_path } + let(:data_template_path) { File.join(DataMigrate.root, "generators", "data_migration", "templates", "data_migration.rb") } before do - @before = DataMigrate.config.data_template_path + @original_data_migrations_path = DataMigrate.config.data_template_path + DataMigrate.configure do |config| config.data_template_path = data_template_path end end - let(:data_template_path) do - File.join(DataMigrate.root, "generators", "data_migration", "templates", "data_migration.rb") - end - after do DataMigrate.configure do |config| - config.data_template_path = @before + config.data_template_path = @original_data_migrations_path end end it "equals the custom data template path" do - is_expected.to eq data_template_path + is_expected.to eq(data_template_path) end context "when path does not exist" do diff --git a/spec/data_migrate/data_migrator_spec.rb b/spec/data_migrate/data_migrator_spec.rb index 97b70032..54e19d46 100644 --- a/spec/data_migrate/data_migrator_spec.rb +++ b/spec/data_migrate/data_migrator_spec.rb @@ -1,36 +1,29 @@ +# frozen_string_literal: true + require "spec_helper" describe DataMigrate::DataMigrator do let(:subject) { DataMigrate::DataMigrator } - let(:db_config) do - { - adapter: "sqlite3", - database: "spec/db/test.db" - } - end + let(:db_config) { { adapter: "sqlite3", database: "spec/db/test.db" } } before do ActiveRecord::Base.establish_connection(db_config) + ::ActiveRecord::SchemaMigration.create_table + DataMigrate::DataSchemaMigration.create_table end - describe ".load_migrated" do - before do - ActiveRecord::Base.establish_connection(db_config) - ::ActiveRecord::SchemaMigration.create_table - DataMigrate::DataSchemaMigration.create_table - end - - after do - ActiveRecord::Migration.drop_table("data_migrations") - ActiveRecord::Migration.drop_table("schema_migrations") - end + after do + ActiveRecord::Migration.drop_table("data_migrations") rescue nil + ActiveRecord::Migration.drop_table("schema_migrations") rescue nil + end + describe ".load_migrated" do it "loads migrated versions" do - subject.assure_data_schema_table DataMigrate::DataSchemaMigration.create(version: 20090000000000) ::ActiveRecord::SchemaMigration.create(version: 20100000000000) DataMigrate::DataSchemaMigration.create(version: 20110000000000) ::ActiveRecord::SchemaMigration.create(version: 20120000000000) + migrated = subject.new(:up, []).load_migrated expect(migrated.count).to eq 2 expect(migrated).to include 20090000000000 @@ -39,14 +32,6 @@ end describe ".assure_data_schema_table" do - before do - ActiveRecord::Base.establish_connection(db_config) - end - - after do - ActiveRecord::Migration.drop_table("data_migrations") - end - it "creates the data_migrations table" do ActiveRecord::Migration.drop_table("data_migrations") rescue nil subject.assure_data_schema_table @@ -55,12 +40,6 @@ end describe "#migrations_status" do - before do - ActiveRecord::Base.establish_connection(db_config) - ::ActiveRecord::SchemaMigration.create_table - DataMigrate::DataSchemaMigration.create_table - end - it "returns all migrations statuses" do status = subject.migrations_status expect(status.length).to eq 2 diff --git a/spec/data_migrate/data_schema_migration_spec.rb b/spec/data_migrate/data_schema_migration_spec.rb index 01943581..13597a80 100644 --- a/spec/data_migrate/data_schema_migration_spec.rb +++ b/spec/data_migrate/data_schema_migration_spec.rb @@ -1,7 +1,10 @@ +# frozen_string_literal: true + require "spec_helper" describe DataMigrate::DataSchemaMigration do let(:subject) { DataMigrate::DataSchemaMigration } + describe ".table_name" do it "returns correct table name" do expect(subject.table_name).to eq("data_migrations") diff --git a/spec/data_migrate/data_spec.rb b/spec/data_migrate/data_spec.rb index 0247d2b8..07552d67 100644 --- a/spec/data_migrate/data_spec.rb +++ b/spec/data_migrate/data_spec.rb @@ -4,15 +4,7 @@ describe DataMigrate::Data do let(:subject) { DataMigrate::Data } - let(:db_config) do - { - adapter: "sqlite3", - database: "spec/db/test.db" - } - end - let(:fixture_file_timestamps) do - %w[20091231235959 20101231235959 20111231235959] - end + let(:fixture_file_timestamps) { %w[20091231235959 20101231235959 20111231235959] } around do |example| Dir.mktmpdir do |temp_dir| diff --git a/spec/data_migrate/database_tasks_spec.rb b/spec/data_migrate/database_tasks_spec.rb index fc8c7398..d3608bb3 100644 --- a/spec/data_migrate/database_tasks_spec.rb +++ b/spec/data_migrate/database_tasks_spec.rb @@ -24,7 +24,7 @@ before do allow(DataMigrate::Tasks::DataMigrateTasks).to receive(:migrations_paths) { data_migrations_path } ActiveRecord::Base.establish_connection(db_config) - if Gem::Dependency.new("rails", ">= 6.1").match?("rails", Gem.loaded_specs["rails"].version) + if Gem::Dependency.new("rails", ">= 6.1").match?("rails", Gem.loaded_specs["rails"].version) # LOOK AT THIS IN SOURCE hash_config = ActiveRecord::DatabaseConfigurations::HashConfig.new("test", "test", db_config) config_obj = ActiveRecord::DatabaseConfigurations.new([hash_config]) allow(ActiveRecord::Base).to receive(:configurations).and_return(config_obj) @@ -35,11 +35,8 @@ context "migrations" do after do - begin - ActiveRecord::Migration.drop_table("data_migrations") - rescue ActiveRecord::StatementInvalid - end - ActiveRecord::Migration.drop_table("schema_migrations") + ActiveRecord::Migration.drop_table("data_migrations") rescue nil + ActiveRecord::Migration.drop_table("schema_migrations") rescue nil end before do @@ -47,20 +44,19 @@ allow(DataMigrate::SchemaMigration).to receive(:migrations_paths) { migration_path } allow(DataMigrate::DatabaseTasks).to receive(:data_migrations_path) { data_migrations_path }.at_least(:once) - # allow(DataMigrate::DatabaseTasks).to receive(:schema_migrations_path) { migration_path }.at_least(:once) end describe ".past_migrations" do it "returns past migration records" do subject.forward - m = subject.past_migrations - expect(m.count).to eq 1 - expect(m.first[:version]).to eq 20091231235959 + migrations = subject.past_migrations + expect(migrations.count).to eq 1 + expect(migrations.first[:version]).to eq 20091231235959 end it "shows nothing without any migrations" do - m = subject.past_migrations - expect(m.count).to eq 0 + migrations = subject.past_migrations + expect(migrations.count).to eq 0 end end diff --git a/spec/data_migrate/legacy_migrator_spec.rb b/spec/data_migrate/legacy_migrator_spec.rb index 1408a68a..dc184a04 100644 --- a/spec/data_migrate/legacy_migrator_spec.rb +++ b/spec/data_migrate/legacy_migrator_spec.rb @@ -1,50 +1,34 @@ +# frozen_string_literal: true + require "spec_helper" describe DataMigrate::LegacyMigrator do - let(:context) { - DataMigrate::MigrationContext.new("spec/db/data") - } - - after do - begin - ActiveRecord::Migration.drop_table("data_migrations") - ActiveRecord::Migration.drop_table("schema_migrations") - rescue StandardError - nil - end - end + let(:context) { DataMigrate::MigrationContext.new("spec/db/data") } before do - ActiveRecord::Base.establish_connection(db_config) ActiveRecord::SchemaMigration.create_table DataMigrate::DataSchemaMigration.create_table end - let(:db_config) do - { - adapter: "sqlite3", - database: "spec/db/test.db" - } + after do + ActiveRecord::Migration.drop_table("data_migrations") rescue nil + ActiveRecord::Migration.drop_table("schema_migrations") rescue nil end it "migrate legacy migrations to be in correct table" do - DataMigrate::DataSchemaMigration.create_table - # simulate creation of legacy data migration when - # it was recorded in schema table + # simulate creation of legacy data migration when it was recorded in schema table ActiveRecord::SchemaMigration.create(version: "20091231235959") # create one migration in correct place DataMigrate::DataSchemaMigration.create(version: "20171231235959") - migrated = DataMigrate::DataMigrator .new(:up, []).load_migrated + migrated = DataMigrate::DataMigrator.new(:up, []).load_migrated expect(migrated.count).to eq 1 DataMigrate::LegacyMigrator.new("spec/db/data").migrate - # after migacy migrator has been run, we should have records - # of both migrations + # after migacy migrator has been run, we should have records of both migrations migrated = DataMigrate::DataMigrator .new(:up, []).load_migrated expect(migrated.count).to eq 2 end - end diff --git a/spec/data_migrate/migration.rb b/spec/data_migrate/migration.rb index 409644f2..fb21a54e 100644 --- a/spec/data_migrate/migration.rb +++ b/spec/data_migrate/migration.rb @@ -1,13 +1,17 @@ +# frozen_string_literal: true + require "spec_helper" describe DataMigrate::Migration do - it "uses correct table name" do - expect(subject.table_name).to eq("data_migrations") + describe ".table_name" do + it "returns correct table name" do + expect(subject.table_name).to eq("data_migrations") + end end - it "uses correct index name" do - expect(subject).to receive(:table_name_prefix) { "" } - expect(subject).to receive(:table_name_suffix) { "" } - expect(subject.primary_key).to eq("version") + describe ".index_name" do + it "returns correct primary key name" do + expect(subject.primary_key).to eq("version") + end end end diff --git a/spec/data_migrate/migration_context_spec.rb b/spec/data_migrate/migration_context_spec.rb index ac60c0f9..2489ede2 100644 --- a/spec/data_migrate/migration_context_spec.rb +++ b/spec/data_migrate/migration_context_spec.rb @@ -1,40 +1,27 @@ +# frozen_string_literal: true + require "spec_helper" describe DataMigrate::DataMigrator do let(:context) { DataMigrate::MigrationContext.new("spec/db/data") } let(:schema_context) { ActiveRecord::MigrationContext.new("spec/db/migrate", ActiveRecord::Base.connection.schema_migration) } - after do - begin - ActiveRecord::Migration.drop_table("data_migrations") - ActiveRecord::Migration.drop_table("schema_migrations") - rescue StandardError - nil - end + before do + ActiveRecord::SchemaMigration.create_table + DataMigrate::DataSchemaMigration.create_table end - let(:db_config) do - { - adapter: "sqlite3", - database: "spec/db/test.db" - } + after do + ActiveRecord::Migration.drop_table("data_migrations") rescue nil + ActiveRecord::Migration.drop_table("schema_migrations") rescue nil end describe "migrate" do - before do - ActiveRecord::Base.establish_connection(db_config) - ActiveRecord::SchemaMigration.create_table - end - - after do - ActiveRecord::Migration.drop_table("data_migrations") - ActiveRecord::Migration.drop_table("schema_migrations") - end - it "migrates existing file" do context.migrate(nil) context.migrations_status versions = DataMigrate::DataSchemaMigration.normalized_versions + expect(versions.count).to eq(2) expect(versions).to include("20091231235959") expect(versions).to include("20171231235959") @@ -44,51 +31,42 @@ context.migrate(nil) context.run(:down, 20171231235959) versions = DataMigrate::DataSchemaMigration.normalized_versions + expect(versions.count).to eq(1) expect(versions).to include("20091231235959") end it "does not do anything if migration is undone twice" do context.migrate(nil) - expect { - context.run(:down, 20171231235959) - }.to output(/Undoing SuperUpdate/).to_stdout - expect { - context.run(:down, 20171231235959) - }.not_to output(/Undoing SuperUpdate/).to_stdout + + expect { context.run(:down, 20171231235959) }.to output(/Undoing SuperUpdate/).to_stdout + expect { context.run(:down, 20171231235959) }.not_to output(/Undoing SuperUpdate/).to_stdout end it "runs a specific migration" do context.run(:up, 20171231235959) versions = DataMigrate::DataSchemaMigration.normalized_versions + expect(versions.count).to eq(1) expect(versions).to include("20171231235959") end it "does not do anything if migration is ran twice" do - expect { - context.run(:up, 20171231235959) - }.to output(/Doing SuperUpdate/).to_stdout - expect { - context.run(:down, 20171231235959) - }.not_to output(/Doing SuperUpdate/).to_stdout + expect { context.run(:up, 20171231235959) }.to output(/Doing SuperUpdate/).to_stdout + expect { context.run(:down, 20171231235959) }.not_to output(/Doing SuperUpdate/).to_stdout end it "alerts for an invalid specific migration" do - expect { - context.run(:up, 201712312) - }.to raise_error( - ActiveRecord::UnknownMigrationVersionError, - /No migration with version number 201712312/ - ) + expect { context.run(:up, 201712312) }.to raise_error(ActiveRecord::UnknownMigrationVersionError, /No migration with version number 201712312/) end it "rolls back latest migration" do context.migrate(nil) - expect { - context.rollback - }.to output(/Undoing SuperUpdate/).to_stdout + + expect { context.rollback }.to output(/Undoing SuperUpdate/).to_stdout + versions = DataMigrate::DataSchemaMigration.normalized_versions + expect(versions.count).to eq(1) expect(versions).to include("20091231235959") end @@ -96,19 +74,21 @@ it "rolls back 2 migrations" do context.migrate(nil) schema_context.migrate(nil) - expect { - context.rollback(2) - }.to output(/Undoing SomeName/).to_stdout + + expect { context.rollback(2) }.to output(/Undoing SomeName/).to_stdout + versions = DataMigrate::DataSchemaMigration.normalized_versions + expect(versions.count).to eq(0) end it "rolls back 2 migrations" do context.migrate(nil) - expect { - context.rollback(2) - }.to output(/Undoing SomeName/).to_stdout + + expect { context.rollback(2) }.to output(/Undoing SomeName/).to_stdout + versions = DataMigrate::DataSchemaMigration.normalized_versions + expect(versions.count).to eq(0) end end diff --git a/spec/data_migrate/schema_dumper_spec.rb b/spec/data_migrate/schema_dumper_spec.rb index e469f894..934d3ae1 100644 --- a/spec/data_migrate/schema_dumper_spec.rb +++ b/spec/data_migrate/schema_dumper_spec.rb @@ -4,33 +4,20 @@ describe DataMigrate::SchemaDumper do let(:subject) { DataMigrate::SchemaDumper } - let(:db_config) do - { - adapter: "sqlite3", - database: "spec/db/test.db" - } + let(:fixture_file_timestamps) { %w[20091231235959 20101231235959 20111231235959] } + + before do + ActiveRecord::SchemaMigration.create_table + DataMigrate::DataSchemaMigration.create_table + DataMigrate::DataSchemaMigration.create(fixture_file_timestamps.map { |t| { version: t } }) end - let(:fixture_file_timestamps) do - %w[20091231235959 20101231235959 20111231235959] + + after do + ActiveRecord::Migration.drop_table("data_migrations") rescue nil + ActiveRecord::Migration.drop_table("schema_migrations") rescue nil end describe ".dump" do - before do - ActiveRecord::Base.establish_connection(db_config) - - ActiveRecord::SchemaMigration.create_table - DataMigrate::DataMigrator.assure_data_schema_table - - ActiveRecord::Base.connection.execute <<-SQL - INSERT INTO #{DataMigrate::DataSchemaMigration.table_name} - VALUES #{fixture_file_timestamps.map { |t| "(#{t})" }.join(", ")} - SQL - end - - after do - ActiveRecord::Migration.drop_table("data_migrations") - end - it "writes the define method with the version key to the stream" do stream = StringIO.new DataMigrate::SchemaDumper.dump(ActiveRecord::Base.connection, stream) diff --git a/spec/data_migrate/schema_migration_spec.rb b/spec/data_migrate/schema_migration_spec.rb index 210b79c9..b10aa6d0 100644 --- a/spec/data_migrate/schema_migration_spec.rb +++ b/spec/data_migrate/schema_migration_spec.rb @@ -3,32 +3,24 @@ require "spec_helper" describe DataMigrate::SchemaMigration do - let(:migration_path) { "spec/db/migrate" } let(:subject) { DataMigrate::SchemaMigration } - let(:db_config) do - { - adapter: "sqlite3", - database: "spec/db/test.db" - } - end - let(:fixture_file_timestamps) do - %w[20091231235959 20101231235959 20111231235959] - end + let(:migration_path) { "spec/db/migrate" } + let(:fixture_file_timestamps) { %w[20091231235959 20101231235959 20111231235959] } before do - ActiveRecord::Base.establish_connection(db_config) ActiveRecord::SchemaMigration.create_table + DataMigrate::DataSchemaMigration.create_table end after do - ActiveRecord::Migration.drop_table("schema_migrations") + ActiveRecord::Migration.drop_table("data_migrations") rescue nil + ActiveRecord::Migration.drop_table("schema_migrations") rescue nil end describe ".pending_schema_migrations" do it "list sorted schema migrations" do - expect(subject).to receive(:migrations_paths) { - migration_path - } + expect(subject).to receive(:migrations_paths) { migration_path } + migrations = subject.pending_schema_migrations expect(migrations.count).to eq 2 @@ -40,14 +32,19 @@ describe ".run" do it "can run up task" do expect { subject.run(:up, migration_path, 20202020202011) }.to output(/20202020202011 DbMigration: migrating/).to_stdout + versions = ActiveRecord::SchemaMigration.normalized_versions + expect(versions.first).to eq("20202020202011") end it "can run down task" do subject.run(:up, migration_path, 20202020202011) + expect { subject.run(:down, migration_path, 20202020202011) }.to output(/Undoing DbMigration/).to_stdout + versions = ActiveRecord::SchemaMigration.normalized_versions + expect(versions.count).to eq(0) end end @@ -66,7 +63,8 @@ end before do - @spec_name = DataMigrate.config.spec_name + @original_config_spec_name = DataMigrate.config.spec_name + DataMigrate.configure do |config| config.spec_name = specification_name end @@ -77,7 +75,7 @@ after do DataMigrate.configure do |config| - config.spec_name = @spec_name + config.spec_name = @original_config_spec_name end end diff --git a/spec/data_migrate/status_service_spec.rb b/spec/data_migrate/status_service_spec.rb index 1dd325aa..a47a75e8 100644 --- a/spec/data_migrate/status_service_spec.rb +++ b/spec/data_migrate/status_service_spec.rb @@ -1,16 +1,11 @@ # frozen_string_literal: true + require "spec_helper" describe DataMigrate::StatusService do - let(:subject) { DataMigrate::SchemaDumper } - let(:db_config) do - { - adapter: "sqlite3", - database: "spec/db/test.db" - } - end - let(:service) { DataMigrate::StatusService } - + let(:subject) { DataMigrate::StatusService } + let(:stream) { StringIO.new } + let(:stream_data) { stream.read } let(:connection_db_config) do if Gem::Dependency.new("rails", ">= 6.1").match?("rails", Gem.loaded_specs["rails"].version) ActiveRecord::Base.connection_db_config @@ -21,89 +16,52 @@ context "table does not exists" do before do - ActiveRecord::Base.establish_connection(db_config) + allow_any_instance_of(subject).to receive(:table_name) { "bogus" } + + subject.dump(connection_db_config, stream) + stream.rewind end it "show error message" do - allow_any_instance_of(service).to receive(:table_name) { "bogus"} - stream = StringIO.new - - service.dump(connection_db_config, stream) - - stream.rewind - expected = "Data migrations table does not exist" - expect(stream.read).to include expected + expect(stream_data).to include("Data migrations table does not exist") end end context "table exists" do - let(:fixture_file_timestamps) do - %w[20091231235959 20101231235959 20111231235959] - end + let(:fixture_file_timestamps) { %w[20091231235959 20101231235959 20111231235959] } before do - # allow(DataMigrate::DataMigrator).to receive(:db_config) { db_config }.at_least(:once) - ActiveRecord::Base.establish_connection(db_config) - ActiveRecord::SchemaMigration.create_table - DataMigrate::DataMigrator.assure_data_schema_table - - ActiveRecord::Base.connection.execute <<-SQL - INSERT INTO #{DataMigrate::DataSchemaMigration.table_name} - VALUES #{fixture_file_timestamps.map { |t| "(#{t})" }.join(", ")} - SQL + DataMigrate::DataSchemaMigration.create_table + DataMigrate::DataSchemaMigration.create(fixture_file_timestamps.map { |t| { version: t } }) - allow_any_instance_of(service).to receive(:root_folder) { "./" } + subject.dump(connection_db_config, stream) + stream.rewind end after do - ActiveRecord::Migration.drop_table("data_migrations") + ActiveRecord::Migration.drop_table("data_migrations") rescue nil + ActiveRecord::Migration.drop_table("schema_migrations") rescue nil end it "shows successfully executed migration" do - stream = StringIO.new - service.dump(connection_db_config, stream) - stream.rewind - - expected = " up 20091231235959 Some name" - expect(stream.read).to include expected + expect(stream_data).to include(" up 20091231235959 Some name") end it "excludes files without .rb extension" do - stream = StringIO.new - service.dump(connection_db_config, stream) - stream.rewind - - expected = "20181128000207 Excluded file" - expect(stream.read).to_not include expected + expect(stream_data).to_not include("20181128000207 Excluded file") end it "shows missing file migration" do - stream = StringIO.new - service.dump(connection_db_config, stream) - stream.rewind - - expected = " up 20101231235959 ********** NO FILE **********" - s = stream.read - expect(s).to include expected + expect(stream_data).to include(" up 20101231235959 ********** NO FILE **********") end it "shows migration that has not run yet" do - stream = StringIO.new - service.dump(connection_db_config, stream) - stream.rewind - - expected = " down 20171231235959 Super update" - s = stream.read - expect(s).to include expected + expect(stream_data).to include(" down 20171231235959 Super update") end it "outputs migrations in chronological order" do - stream = StringIO.new - service.dump(connection_db_config, stream) - stream.rewind - s = stream.read - expect(s.index("20091231235959")).to be < s.index("20111231235959") + expect(stream_data.index("20091231235959")).to be < stream_data.index("20111231235959") end end end diff --git a/spec/data_migrate/tasks/data_migrate_tasks_spec.rb b/spec/data_migrate/tasks/data_migrate_tasks_spec.rb index 4f264534..95b74489 100644 --- a/spec/data_migrate/tasks/data_migrate_tasks_spec.rb +++ b/spec/data_migrate/tasks/data_migrate_tasks_spec.rb @@ -11,42 +11,33 @@ end end - describe ".dump" do - let(:db_config) do - { - adapter: "sqlite3", - database: "spec/db/other_test.db" - } - end - + before do + ActiveRecord::SchemaMigration.create_table + DataMigrate::DataSchemaMigration.create_table + end + after do + ActiveRecord::Migration.drop_table("data_migrations") rescue nil + ActiveRecord::Migration.drop_table("schema_migrations") rescue nil + end + + describe ".dump" do before do allow(DataMigrate::DatabaseTasks).to receive(:db_dir).and_return("spec/db") - end - - after do - ActiveRecord::Migration.drop_table("data_migrations") rescue nil + DataMigrate::Tasks::DataMigrateTasks.migrate end context "when not given a separate db config" do - it "does not override the default connection" do - DataMigrate::Tasks::DataMigrateTasks.migrate + it "does not override the default connection" do expect(ActiveRecord::Base).not_to receive(:establish_connection) expect(DataMigrate::SchemaDumper).to receive(:dump) + DataMigrate::Tasks::DataMigrateTasks.dump(connection_db_config) end end - context "when given " do - let(:override_config) do - { - "host" => "127.0.0.1", - "database" => "other_test", - "adapter" => "sqlite3", - "username" => "root", - "password" => nil, - } - end + context "when given a separate db config" do + let(:override_config) { { "host" => "127.0.0.1", "database" => "other_test", "adapter" => "sqlite3", "username" => "root", "password" => nil } } let(:paths) { ["spec/db/migrate"] } before do @@ -56,31 +47,16 @@ end it "overrides the default connection" do - DataMigrate::Tasks::DataMigrateTasks.migrate - # expect(ActiveRecord::Base).to receive(:establish_connection).with(override_config) + expect(ActiveRecord::Base).to receive(:establish_connection).with(override_config) + DataMigrate::Tasks::DataMigrateTasks.dump(connection_db_config) end end end describe ".migrate" do - let(:db_config) do - { - adapter: "sqlite3", - database: "spec/db/test.db" - } - end - - before do - ActiveRecord::Base.establish_connection(db_config) - end - - after do - ActiveRecord::Migration.drop_table("data_migrations") rescue nil - end - it "first run should run the first pending migration" do - expect { DataMigrate::Tasks::DataMigrateTasks.migrate }.to output(/20091231235959 SomeName: migrating/).to_stdout + expect { DataMigrate::Tasks::DataMigrateTasks.migrate }.to output(/20091231235959 SomeName: migrating/).to_stdout end it "second run should run the second pending migration" do @@ -102,45 +78,23 @@ end context "when there are pending migrations" do - let(:migrations) do - [{ - name: "A", - version: 1 - }, { - name: "B", - version: 2 - }] - end + let(:migrations) { [{ name: "A", version: 1 }, { name: "B", version: 2 }] } it "should abort with given message and print names and versions of pending migrations" do - expect { subject }.to raise_error(SystemExit, message).and output("You have 2 pending migrations:\n 1 A\n 2 B\n").to_stdout + expect { subject }.to raise_error(SystemExit, message).and output(match(/You have #{migrations.count} pending migrations:/) + .and match(Regexp.new(migrations.map { |m| m.slice(:version, :name).values.join("\\W+") }.join("\\W+")))).to_stdout end end end describe ".status" do - let(:db_config) do - { - adapter: "sqlite3", - database: "spec/db/test.db" - } - end - before do - # hash_config = ActiveRecord::DatabaseConfigurations::HashConfig.new(Rails.env, "test", db_config) - # config_obj = ActiveRecord::DatabaseConfigurations.new([hash_config]) - - # allow(ActiveRecord::Base).to receive(:configurations).and_return(config_obj) allow(Rails).to receive(:root) { "." } allow(Rails).to receive(:application) { OpenStruct.new(config: OpenStruct.new(paths: { "db/migrate" => ["spec/db/migrate"] })) } DataMigrate::Tasks::DataMigrateTasks.migrate end - after do - ActiveRecord::Migration.drop_table("data_migrations") rescue nil - end - it "should display data migration status" do expect { DataMigrate::Tasks::DataMigrateTasks.status(connection_db_config) }.to output(/up 20091231235959 Some name/).to_stdout end diff --git a/spec/db/primaryz_data_schema.rb b/spec/db/primaryz_data_schema.rb deleted file mode 100644 index e69de29b..00000000 diff --git a/tasks/databases.rake b/tasks/databases.rake index ba6920cd..6a05c854 100644 --- a/tasks/databases.rake +++ b/tasks/databases.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "data_migrate/tasks/data_migrate_tasks" namespace :db do @@ -175,11 +177,7 @@ namespace :db do desc "Load both schema.rb and data_schema.rb file into the database" task with_data: :environment do Rake::Task["db:schema:load"].invoke - - DataMigrate::DatabaseTasks.load_schema_current( - :ruby, - ENV["DATA_SCHEMA"] - ) + DataMigrate::DatabaseTasks.load_schema_current(:ruby, ENV["DATA_SCHEMA"]) end end end @@ -189,11 +187,7 @@ namespace :db do desc "Load both structure.sql and data_schema.rb file into the database" task with_data: :environment do Rake::Task["db:structure:load"].invoke - - DataMigrate::DatabaseTasks.load_schema_current( - :ruby, - ENV["DATA_SCHEMA"] - ) + DataMigrate::DatabaseTasks.load_schema_current(:ruby, ENV["DATA_SCHEMA"]) end end end @@ -301,10 +295,7 @@ namespace :data do namespace :schema do desc "Load data_schema.rb file into the database" task load: :environment do - DataMigrate::DatabaseTasks.load_schema_current( - :ruby, - ENV["DATA_SCHEMA"] - ) + DataMigrate::DatabaseTasks.load_schema_current(:ruby, ENV["DATA_SCHEMA"]) end end end From 5a549e52ff714e34ae93b0cd9e0b49162de2e522 Mon Sep 17 00:00:00 2001 From: Chaunce Butterfield Date: Wed, 5 Apr 2023 11:01:51 -0600 Subject: [PATCH 04/98] remove byebug --- data_migrate.gemspec | 1 - spec/spec_helper.rb | 1 - 2 files changed, 2 deletions(-) diff --git a/data_migrate.gemspec b/data_migrate.gemspec index 93a4a2f4..5824e2db 100644 --- a/data_migrate.gemspec +++ b/data_migrate.gemspec @@ -32,7 +32,6 @@ Gem::Specification.new do |s| s.add_development_dependency "timecop" s.add_development_dependency "rubocop" s.add_development_dependency "overcommit" - s.add_development_dependency "byebug" s.files = `git ls-files`.split("\n") diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index a044eb47..40b68072 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -4,7 +4,6 @@ require "data_migrate" require "pry" require "timecop" -require "byebug" RSpec.configure do |config| config.mock_with :rspec do |mocks| From 14fdc0810c22d5aee9114794115b8e5bb8cbd10d Mon Sep 17 00:00:00 2001 From: Chaunce Butterfield Date: Wed, 5 Apr 2023 11:24:42 -0600 Subject: [PATCH 05/98] correct supported version --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 75c523b2..875b3d82 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ table to track all migrations. ## Rails Support -Support Rails 6.1 through 7.0 +Support Rails 6.0 through 7.0 #### v1 From 410f5efbf8739cfa2c80b5aa98c4a2db8295a403 Mon Sep 17 00:00:00 2001 From: Annie Gomez Date: Thu, 13 Apr 2023 17:33:17 -0400 Subject: [PATCH 06/98] Update README.md Proposing a change to make the order of migrations more clear. --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f550b048..83788f84 100644 --- a/README.md +++ b/README.md @@ -92,11 +92,13 @@ You can generate a data migration as you would a schema migration: rake db:version:with_data # Retrieves the current schema version numbers for data and schema migrations -Tasks work as they would with the 'vanilla' db version. The 'with_data' addition to the 'db' tasks will run the task in the context of both the data and schema migrations. That is, rake db:rollback:with_data will check to see if it was a schema or data migration invoked last, and do that. Tasks invoked in that space also have an additional line of output, indicating if the action is performed on data or schema. +Tasks work as they would with the 'vanilla' db version. The 'with_data' addition to the 'db' tasks will run the task in the context of both the data and schema migrations. That is, rake db:rollback:with_data will check to see if it was a schema or data migration invoked last, and do that. Tasks invoked in that space also have an additional line of output, indicating if the action is performed on data or schema. + +When using 'with_data' migrations will be run in ascending order by their version. So if you have a data migration and a schema migration with different version numbers, expect them to run in that order. With 'up' and 'down', you can specify the option 'BOTH', which defaults to false. Using true, will migrate both the data and schema (in the desired direction) if they both match the version provided. Again, going up, schema is given precedence. Down its data. -`rake db:migrate:status:with_data` provides and additional column to indicate which type of migration. +`rake db:migrate:status:with_data` provides an additional column to indicate which type of migration. ### Configuration From c642001fc578a71ff372fdbf3d7e927d1601f337 Mon Sep 17 00:00:00 2001 From: Annie Gomez Date: Thu, 13 Apr 2023 18:19:11 -0400 Subject: [PATCH 07/98] Update README.md Update for clarity --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 83788f84..b03f9d12 100644 --- a/README.md +++ b/README.md @@ -94,10 +94,10 @@ You can generate a data migration as you would a schema migration: Tasks work as they would with the 'vanilla' db version. The 'with_data' addition to the 'db' tasks will run the task in the context of both the data and schema migrations. That is, rake db:rollback:with_data will check to see if it was a schema or data migration invoked last, and do that. Tasks invoked in that space also have an additional line of output, indicating if the action is performed on data or schema. -When using 'with_data' migrations will be run in ascending order by their version. So if you have a data migration and a schema migration with different version numbers, expect them to run in that order. - With 'up' and 'down', you can specify the option 'BOTH', which defaults to false. Using true, will migrate both the data and schema (in the desired direction) if they both match the version provided. Again, going up, schema is given precedence. Down its data. +When using `rake db:migrate:with_data` migrations will be run in ascending order by their version. For example, if you have a data migration with version 20230410000000 and a schema migration with version 20230415000000, expect the data migration to run first. + `rake db:migrate:status:with_data` provides an additional column to indicate which type of migration. ### Configuration From f5a2b5d422869a63ed27f752d5296cd8a878b189 Mon Sep 17 00:00:00 2001 From: Chaunce Butterfield Date: Fri, 21 Apr 2023 10:46:16 -0600 Subject: [PATCH 08/98] revert formatting changes --- gemfiles/rails_6.0.gemfile | 2 +- gemfiles/rails_6.1.gemfile | 2 +- lib/data_migrate/data_migrator.rb | 4 +- lib/data_migrate/data_schema_migration.rb | 2 +- lib/data_migrate/database_tasks.rb | 15 +++++-- lib/data_migrate/schema_migration.rb | 2 +- lib/data_migrate/tasks/data_migrate_tasks.rb | 26 ++++++++----- spec/data_migrate/data_migrator_spec.rb | 11 +++++- spec/data_migrate/data_spec.rb | 17 +++++--- spec/data_migrate/database_tasks_spec.rb | 20 +++++++--- spec/data_migrate/legacy_migrator_spec.rb | 10 +++-- spec/data_migrate/migration_context_spec.rb | 28 +++++++++---- spec/data_migrate/schema_dumper_spec.rb | 4 +- spec/data_migrate/schema_migration_spec.rb | 23 ++++++++--- spec/data_migrate/status_service_spec.rb | 16 +++++--- .../tasks/data_migrate_tasks_spec.rb | 39 +++++++++++++++---- 16 files changed, 159 insertions(+), 62 deletions(-) diff --git a/gemfiles/rails_6.0.gemfile b/gemfiles/rails_6.0.gemfile index fd25237e..172f9d56 100644 --- a/gemfiles/rails_6.0.gemfile +++ b/gemfiles/rails_6.0.gemfile @@ -2,7 +2,7 @@ source "http://rubygems.org" -gem "sqlite3", "~> 1.4" gem "rails", "~> 6.0.0" +gem "sqlite3", "~> 1.4" gemspec path: "../" diff --git a/gemfiles/rails_6.1.gemfile b/gemfiles/rails_6.1.gemfile index 20ae603a..eff39ac3 100644 --- a/gemfiles/rails_6.1.gemfile +++ b/gemfiles/rails_6.1.gemfile @@ -2,7 +2,7 @@ source "http://rubygems.org" -gem "sqlite3", "~> 1.4" gem "rails", "~> 6.1.0" +gem "sqlite3", "~> 1.4" gemspec path: "../" diff --git a/lib/data_migrate/data_migrator.rb b/lib/data_migrate/data_migrator.rb index 19edd333..36840112 100644 --- a/lib/data_migrate/data_migrator.rb +++ b/lib/data_migrate/data_migrator.rb @@ -26,7 +26,8 @@ def initialize(direction, migrations, target_version = nil) end def load_migrated - @migrated_versions = DataMigrate::DataSchemaMigration.normalized_versions.map(&:to_i).sort + @migrated_versions = + DataMigrate::DataSchemaMigration.normalized_versions.map(&:to_i).sort end class << self @@ -46,7 +47,6 @@ def match(filename) def needs_migration? DataMigrate::DatabaseTasks.pending_migrations.count.positive? end - ## # Provides the full migrations_path filepath # @return (String) diff --git a/lib/data_migrate/data_schema_migration.rb b/lib/data_migrate/data_schema_migration.rb index 617e89bd..80f7c982 100644 --- a/lib/data_migrate/data_schema_migration.rb +++ b/lib/data_migrate/data_schema_migration.rb @@ -7,7 +7,7 @@ class << self def instance @instance ||= Class.new(::ActiveRecord::SchemaMigration) do - define_singleton_method(:table_name) { ActiveRecord::Base.table_name_prefix + "data_migrations" + ActiveRecord::Base.table_name_suffix } + define_singleton_method(:table_name) { ActiveRecord::Base.table_name_prefix + 'data_migrations' + ActiveRecord::Base.table_name_suffix } define_singleton_method(:primary_key) { "version" } end end diff --git a/lib/data_migrate/database_tasks.rb b/lib/data_migrate/database_tasks.rb index 9b8e12d9..687641fe 100644 --- a/lib/data_migrate/database_tasks.rb +++ b/lib/data_migrate/database_tasks.rb @@ -31,7 +31,10 @@ def check_schema_file(filename) end def pending_migrations - sort_migrations(pending_schema_migrations, pending_data_migrations) + sort_migrations( + pending_schema_migrations, + pending_data_migrations + ) end def sort_migrations(*migrations) @@ -48,11 +51,15 @@ def data_migrations_path def run_migration(migration, direction) if migration[:kind] == :data - ::ActiveRecord::Migration.write("== %s %s" % ["Data", "=" * 71]) + ::ActiveRecord::Migration.write("== %s %s" % ['Data', "=" * 71]) ::DataMigrate::DataMigrator.run(direction, data_migrations_path, migration[:version]) else - ::ActiveRecord::Migration.write("== %s %s" % ["Schema", "=" * 69]) - ::DataMigrate::SchemaMigration.run(direction, ::DataMigrate::SchemaMigration.migrations_paths, migration[:version]) + ::ActiveRecord::Migration.write("== %s %s" % ['Schema', "=" * 69]) + ::DataMigrate::SchemaMigration.run( + direction, + ::DataMigrate::SchemaMigration.migrations_paths, + migration[:version] + ) end end diff --git a/lib/data_migrate/schema_migration.rb b/lib/data_migrate/schema_migration.rb index 769010f8..1fe70a78 100644 --- a/lib/data_migrate/schema_migration.rb +++ b/lib/data_migrate/schema_migration.rb @@ -19,7 +19,7 @@ def self.run(direction, migration_paths, version) def self.sort_migrations(set1, set2 = nil) migrations = set1 + (set2 || []) - migrations.sort { |a, b| sort_string(a) <=> sort_string(b) } + migrations.sort {|a, b| sort_string(a) <=> sort_string(b) } end def self.migrations_paths diff --git a/lib/data_migrate/tasks/data_migrate_tasks.rb b/lib/data_migrate/tasks/data_migrate_tasks.rb index 595553cb..90ed9903 100644 --- a/lib/data_migrate/tasks/data_migrate_tasks.rb +++ b/lib/data_migrate/tasks/data_migrate_tasks.rb @@ -52,15 +52,17 @@ def status(db_config) end def status_with_schema(db_config) - db_list_data = ActiveRecord::Base.connection.select_values("SELECT version FROM #{DataMigrate::DataSchemaMigration.table_name}") + db_list_data = ActiveRecord::Base.connection.select_values( + "SELECT version FROM #{DataMigrate::DataSchemaMigration.table_name}" + ) db_list_schema = ActiveRecord::SchemaMigration.all.pluck(:version) file_list = [] Dir.foreach(File.join(Rails.root, migrations_paths)) do |file| # only files matching "20091231235959_some_name.rb" pattern if match_data = /(\d{14})_(.+)\.rb/.match(file) - status = db_list_data.delete(match_data[1]) ? "up" : "down" - file_list << [status, match_data[1], match_data[2], "data"] + status = db_list_data.delete(match_data[1]) ? 'up' : 'down' + file_list << [status, match_data[1], match_data[2], 'data'] end end @@ -69,20 +71,26 @@ def status_with_schema(db_config) end.flatten.compact.each do |file| # only files matching "20091231235959_some_name.rb" pattern if match_data = /(\d{14})_(.+)\.rb/.match(file) - status = db_list_schema.delete(match_data[1]) ? "up" : "down" - file_list << [status, match_data[1], match_data[2], "schema"] + status = db_list_schema.delete(match_data[1]) ? 'up' : 'down' + file_list << [status, match_data[1], match_data[2], 'schema'] end end - file_list.sort! { |a,b| "#{a[1]}_#{a[3] == 'data' ? 1 : 0}" <=> "#{b[1]}_#{b[3] == 'data' ? 1 : 0}" } + file_list.sort!{|a,b| "#{a[1]}_#{a[3] == 'data' ? 1 : 0}" <=> "#{b[1]}_#{b[3] == 'data' ? 1 : 0}" } # output puts "\ndatabase: #{spec_name(db_config)}\n\n" puts "#{"Status".center(8)} #{"Type".center(8)} #{"Migration ID".ljust(14)} Migration Name" puts "-" * 60 - file_list.each { |file| puts "#{file[0].center(8)} #{file[3].center(8)} #{file[1].ljust(14)} #{file[2].humanize}" } - db_list_schema.each { |version| puts "#{'up'.center(8)} #{version.ljust(14)} *** NO SCHEMA FILE ***" } - db_list_data.each { |version| puts "#{'up'.center(8)} #{version.ljust(14)} *** NO DATA FILE ***" } + file_list.each do |file| + puts "#{file[0].center(8)} #{file[3].center(8)} #{file[1].ljust(14)} #{file[2].humanize}" + end + db_list_schema.each do |version| + puts "#{'up'.center(8)} #{version.ljust(14)} *** NO SCHEMA FILE ***" + end + db_list_data.each do |version| + puts "#{'up'.center(8)} #{version.ljust(14)} *** NO DATA FILE ***" + end puts end diff --git a/spec/data_migrate/data_migrator_spec.rb b/spec/data_migrate/data_migrator_spec.rb index 54e19d46..1f081d9f 100644 --- a/spec/data_migrate/data_migrator_spec.rb +++ b/spec/data_migrate/data_migrator_spec.rb @@ -4,7 +4,12 @@ describe DataMigrate::DataMigrator do let(:subject) { DataMigrate::DataMigrator } - let(:db_config) { { adapter: "sqlite3", database: "spec/db/test.db" } } + let(:db_config) do + { + adapter: "sqlite3", + database: "spec/db/test.db" + } + end before do ActiveRecord::Base.establish_connection(db_config) @@ -35,7 +40,9 @@ it "creates the data_migrations table" do ActiveRecord::Migration.drop_table("data_migrations") rescue nil subject.assure_data_schema_table - expect(ActiveRecord::Base.connection.table_exists?("data_migrations")).to eq true + expect( + ActiveRecord::Base.connection.table_exists?("data_migrations") + ).to eq true end end diff --git a/spec/data_migrate/data_spec.rb b/spec/data_migrate/data_spec.rb index 07552d67..4060f00a 100644 --- a/spec/data_migrate/data_spec.rb +++ b/spec/data_migrate/data_spec.rb @@ -4,7 +4,9 @@ describe DataMigrate::Data do let(:subject) { DataMigrate::Data } - let(:fixture_file_timestamps) { %w[20091231235959 20101231235959 20111231235959] } + let(:fixture_file_timestamps) do + %w[20091231235959 20101231235959 20111231235959] + end around do |example| Dir.mktmpdir do |temp_dir| @@ -32,7 +34,8 @@ context "when a version is supplied" do before do - allow(DataMigrate::DataMigrator).to receive(:full_migrations_path).and_return(@temp_dir) + allow(DataMigrate::DataMigrator). + to receive(:full_migrations_path).and_return(@temp_dir) end it "sets the current version to the supplied version" do @@ -43,7 +46,8 @@ expect(DataMigrate::DataMigrator.current_version).to eq version.to_i end - it "creates entries for migration versions that come before the supplied version" do + it "creates entries for migration versions that come " \ + "before the supplied version" do version = fixture_file_timestamps[1] subject.define(version: version) @@ -53,8 +57,11 @@ FROM #{DataMigrate::DataSchemaMigration.table_name} SQL - db_list_data = ActiveRecord::Base.connection.select_values(sql_select).map(&:to_i) - expect(db_list_data).to match_array([fixture_file_timestamps[0], fixture_file_timestamps[1]].map(&:to_i)) + db_list_data = ActiveRecord::Base.connection. + select_values(sql_select).map(&:to_i) + expect(db_list_data).to match_array( + [fixture_file_timestamps[0], fixture_file_timestamps[1]].map(&:to_i) + ) # The last remaining migration (fixture_file_timestamps[2]) was # not included as part of the supplied version and so should not diff --git a/spec/data_migrate/database_tasks_spec.rb b/spec/data_migrate/database_tasks_spec.rb index d3608bb3..3cb5c5b7 100644 --- a/spec/data_migrate/database_tasks_spec.rb +++ b/spec/data_migrate/database_tasks_spec.rb @@ -5,7 +5,9 @@ describe DataMigrate::DatabaseTasks do let(:subject) { DataMigrate::DatabaseTasks } let(:migration_path) { "spec/db/migrate" } - let(:data_migrations_path) { DataMigrate.config.data_migrations_path } + let(:data_migrations_path) { + DataMigrate.config.data_migrations_path + } let(:db_config) do { adapter: "sqlite3", @@ -22,10 +24,12 @@ end before do - allow(DataMigrate::Tasks::DataMigrateTasks).to receive(:migrations_paths) { data_migrations_path } + allow(DataMigrate::Tasks::DataMigrateTasks).to receive(:migrations_paths) { + data_migrations_path + } ActiveRecord::Base.establish_connection(db_config) - if Gem::Dependency.new("rails", ">= 6.1").match?("rails", Gem.loaded_specs["rails"].version) # LOOK AT THIS IN SOURCE - hash_config = ActiveRecord::DatabaseConfigurations::HashConfig.new("test", "test", db_config) + if Gem::Dependency.new("rails", ">= 6.1").match?("rails", Gem.loaded_specs["rails"].version) + hash_config = ActiveRecord::DatabaseConfigurations::HashConfig.new('test', 'test', db_config) config_obj = ActiveRecord::DatabaseConfigurations.new([hash_config]) allow(ActiveRecord::Base).to receive(:configurations).and_return(config_obj) else @@ -42,8 +46,12 @@ before do ActiveRecord::SchemaMigration.create_table - allow(DataMigrate::SchemaMigration).to receive(:migrations_paths) { migration_path } - allow(DataMigrate::DatabaseTasks).to receive(:data_migrations_path) { data_migrations_path }.at_least(:once) + allow(DataMigrate::SchemaMigration).to receive(:migrations_paths) { + migration_path + } + allow(DataMigrate::DatabaseTasks).to receive(:data_migrations_path) { + data_migrations_path + }.at_least(:once) end describe ".past_migrations" do diff --git a/spec/data_migrate/legacy_migrator_spec.rb b/spec/data_migrate/legacy_migrator_spec.rb index dc184a04..b9d4ee59 100644 --- a/spec/data_migrate/legacy_migrator_spec.rb +++ b/spec/data_migrate/legacy_migrator_spec.rb @@ -3,7 +3,9 @@ require "spec_helper" describe DataMigrate::LegacyMigrator do - let(:context) { DataMigrate::MigrationContext.new("spec/db/data") } + let(:context) { + DataMigrate::MigrationContext.new("spec/db/data") + } before do ActiveRecord::SchemaMigration.create_table @@ -16,7 +18,8 @@ end it "migrate legacy migrations to be in correct table" do - # simulate creation of legacy data migration when it was recorded in schema table + # simulate creation of legacy data migration when + # it was recorded in schema table ActiveRecord::SchemaMigration.create(version: "20091231235959") # create one migration in correct place @@ -27,7 +30,8 @@ DataMigrate::LegacyMigrator.new("spec/db/data").migrate - # after migacy migrator has been run, we should have records of both migrations + # after migacy migrator has been run, we should have records + # of both migrations migrated = DataMigrate::DataMigrator .new(:up, []).load_migrated expect(migrated.count).to eq 2 end diff --git a/spec/data_migrate/migration_context_spec.rb b/spec/data_migrate/migration_context_spec.rb index 2489ede2..05a73724 100644 --- a/spec/data_migrate/migration_context_spec.rb +++ b/spec/data_migrate/migration_context_spec.rb @@ -39,8 +39,12 @@ it "does not do anything if migration is undone twice" do context.migrate(nil) - expect { context.run(:down, 20171231235959) }.to output(/Undoing SuperUpdate/).to_stdout - expect { context.run(:down, 20171231235959) }.not_to output(/Undoing SuperUpdate/).to_stdout + expect { + context.run(:down, 20171231235959) + }.to output(/Undoing SuperUpdate/).to_stdout + expect { + context.run(:down, 20171231235959) + }.not_to output(/Undoing SuperUpdate/).to_stdout end it "runs a specific migration" do @@ -52,8 +56,12 @@ end it "does not do anything if migration is ran twice" do - expect { context.run(:up, 20171231235959) }.to output(/Doing SuperUpdate/).to_stdout - expect { context.run(:down, 20171231235959) }.not_to output(/Doing SuperUpdate/).to_stdout + expect { + context.run(:up, 20171231235959) + }.to output(/Doing SuperUpdate/).to_stdout + expect { + context.run(:down, 20171231235959) + }.not_to output(/Doing SuperUpdate/).to_stdout end it "alerts for an invalid specific migration" do @@ -63,7 +71,9 @@ it "rolls back latest migration" do context.migrate(nil) - expect { context.rollback }.to output(/Undoing SuperUpdate/).to_stdout + expect { + context.rollback + }.to output(/Undoing SuperUpdate/).to_stdout versions = DataMigrate::DataSchemaMigration.normalized_versions @@ -75,7 +85,9 @@ context.migrate(nil) schema_context.migrate(nil) - expect { context.rollback(2) }.to output(/Undoing SomeName/).to_stdout + expect { + context.rollback(2) + }.to output(/Undoing SomeName/).to_stdout versions = DataMigrate::DataSchemaMigration.normalized_versions @@ -85,7 +97,9 @@ it "rolls back 2 migrations" do context.migrate(nil) - expect { context.rollback(2) }.to output(/Undoing SomeName/).to_stdout + expect { + context.rollback(2) + }.to output(/Undoing SomeName/).to_stdout versions = DataMigrate::DataSchemaMigration.normalized_versions diff --git a/spec/data_migrate/schema_dumper_spec.rb b/spec/data_migrate/schema_dumper_spec.rb index 934d3ae1..1d57588c 100644 --- a/spec/data_migrate/schema_dumper_spec.rb +++ b/spec/data_migrate/schema_dumper_spec.rb @@ -4,7 +4,9 @@ describe DataMigrate::SchemaDumper do let(:subject) { DataMigrate::SchemaDumper } - let(:fixture_file_timestamps) { %w[20091231235959 20101231235959 20111231235959] } + let(:fixture_file_timestamps) do + %w[20091231235959 20101231235959 20111231235959] + end before do ActiveRecord::SchemaMigration.create_table diff --git a/spec/data_migrate/schema_migration_spec.rb b/spec/data_migrate/schema_migration_spec.rb index b10aa6d0..61d86e22 100644 --- a/spec/data_migrate/schema_migration_spec.rb +++ b/spec/data_migrate/schema_migration_spec.rb @@ -5,7 +5,9 @@ describe DataMigrate::SchemaMigration do let(:subject) { DataMigrate::SchemaMigration } let(:migration_path) { "spec/db/migrate" } - let(:fixture_file_timestamps) { %w[20091231235959 20101231235959 20111231235959] } + let(:fixture_file_timestamps) do + %w[20091231235959 20101231235959 20111231235959] + end before do ActiveRecord::SchemaMigration.create_table @@ -19,7 +21,9 @@ describe ".pending_schema_migrations" do it "list sorted schema migrations" do - expect(subject).to receive(:migrations_paths) { migration_path } + expect(subject).to receive(:migrations_paths) { + migration_path + } migrations = subject.pending_schema_migrations @@ -31,7 +35,9 @@ describe ".run" do it "can run up task" do - expect { subject.run(:up, migration_path, 20202020202011) }.to output(/20202020202011 DbMigration: migrating/).to_stdout + expect { + subject.run(:up, migration_path, 20202020202011) + }.to output(/20202020202011 DbMigration: migrating/).to_stdout versions = ActiveRecord::SchemaMigration.normalized_versions @@ -41,7 +47,9 @@ it "can run down task" do subject.run(:up, migration_path, 20202020202011) - expect { subject.run(:down, migration_path, 20202020202011) }.to output(/Undoing DbMigration/).to_stdout + expect { + subject.run(:down, migration_path, 20202020202011) + }.to output(/Undoing DbMigration/).to_stdout versions = ActiveRecord::SchemaMigration.normalized_versions @@ -52,7 +60,7 @@ describe ".migrations_paths" do context "when a db_name is configured" do let(:config) { double(:config) } - let(:paths) { ["spec/db/migrate", "spec/db/migrate/other"] } + let(:paths) { ['spec/db/migrate', 'spec/db/migrate/other'] } let(:specification_name) { "primary" } let(:config_options) do if Gem::Dependency.new("rails", "~> 6.0").match?("rails", Gem.loaded_specs["rails"].version) @@ -69,7 +77,10 @@ config.spec_name = specification_name end - allow(ActiveRecord::Base.configurations).to receive(:configs_for).with(config_options).and_return(config) + allow(ActiveRecord::Base.configurations) + .to receive(:configs_for) + .with(config_options) + .and_return(config) allow(config).to receive(:migrations_paths).and_return(paths) end diff --git a/spec/data_migrate/status_service_spec.rb b/spec/data_migrate/status_service_spec.rb index a47a75e8..49e231e8 100644 --- a/spec/data_migrate/status_service_spec.rb +++ b/spec/data_migrate/status_service_spec.rb @@ -28,7 +28,9 @@ end context "table exists" do - let(:fixture_file_timestamps) { %w[20091231235959 20101231235959 20111231235959] } + let(:fixture_file_timestamps) do + %w[20091231235959 20101231235959 20111231235959] + end before do ActiveRecord::SchemaMigration.create_table @@ -45,19 +47,23 @@ end it "shows successfully executed migration" do - expect(stream_data).to include(" up 20091231235959 Some name") + expected = " up 20091231235959 Some name" + expect(stream_data).to include expected end it "excludes files without .rb extension" do - expect(stream_data).to_not include("20181128000207 Excluded file") + expected = "20181128000207 Excluded file" + expect(stream_data).to_not include expected end it "shows missing file migration" do - expect(stream_data).to include(" up 20101231235959 ********** NO FILE **********") + expected = " up 20101231235959 ********** NO FILE **********" + expect(stream_data).to include expected end it "shows migration that has not run yet" do - expect(stream_data).to include(" down 20171231235959 Super update") + expected = " down 20171231235959 Super update" + expect(stream_data).to include expected end it "outputs migrations in chronological order" do diff --git a/spec/data_migrate/tasks/data_migrate_tasks_spec.rb b/spec/data_migrate/tasks/data_migrate_tasks_spec.rb index 95b74489..d7ca942c 100644 --- a/spec/data_migrate/tasks/data_migrate_tasks_spec.rb +++ b/spec/data_migrate/tasks/data_migrate_tasks_spec.rb @@ -27,8 +27,8 @@ DataMigrate::Tasks::DataMigrateTasks.migrate end - context "when not given a separate db config" do - it "does not override the default connection" do + context 'when not given a separate db config' do + it 'does not override the default connection' do expect(ActiveRecord::Base).not_to receive(:establish_connection) expect(DataMigrate::SchemaDumper).to receive(:dump) @@ -37,7 +37,15 @@ end context "when given a separate db config" do - let(:override_config) { { "host" => "127.0.0.1", "database" => "other_test", "adapter" => "sqlite3", "username" => "root", "password" => nil } } + let(:override_config) do + { + "host" => "127.0.0.1", + "database" => "other_test", + "adapter" => "sqlite3", + "username" => "root", + "password" => nil + } + end let(:paths) { ["spec/db/migrate"] } before do @@ -78,11 +86,22 @@ end context "when there are pending migrations" do - let(:migrations) { [{ name: "A", version: 1 }, { name: "B", version: 2 }] } + let(:migrations) do + [{ + name: "A", + version: 1 + }, { + name: "B", + version: 2 + }] + end it "should abort with given message and print names and versions of pending migrations" do - expect { subject }.to raise_error(SystemExit, message).and output(match(/You have #{migrations.count} pending migrations:/) - .and match(Regexp.new(migrations.map { |m| m.slice(:version, :name).values.join("\\W+") }.join("\\W+")))).to_stdout + expect { subject } + .to raise_error(SystemExit, message) + .and output(match(/You have #{migrations.count} pending migrations:/) + .and match(Regexp.new(migrations.map { |m| m.slice(:version, :name) + .values.join("\\W+") }.join("\\W+")))).to_stdout end end end @@ -96,11 +115,15 @@ end it "should display data migration status" do - expect { DataMigrate::Tasks::DataMigrateTasks.status(connection_db_config) }.to output(/up 20091231235959 Some name/).to_stdout + expect { + DataMigrate::Tasks::DataMigrateTasks.status(connection_db_config) + }.to output(/up 20091231235959 Some name/).to_stdout end it "should display schema and data migration status" do - expect { DataMigrate::Tasks::DataMigrateTasks.status_with_schema(connection_db_config) }.to output(match(/up data 20091231235959 Some name/) + expect { + DataMigrate::Tasks::DataMigrateTasks.status_with_schema(connection_db_config) + }.to output(match(/up data 20091231235959 Some name/) .and match(/down schema 20131111111111 Late migration/)).to_stdout end end From 8d69882683ce7c4c02bf6629011e9b83684ef49a Mon Sep 17 00:00:00 2001 From: Chaunce Butterfield Date: Fri, 21 Apr 2023 11:21:49 -0600 Subject: [PATCH 09/98] revert formatting changes --- lib/data_migrate/database_tasks.rb | 60 ++++++++--------- lib/data_migrate/schema_migration.rb | 4 +- lib/data_migrate/tasks/data_migrate_tasks.rb | 20 +++--- spec/data_migrate/config_spec.rb | 2 +- .../data_schema_migration_spec.rb | 2 +- spec/data_migrate/migration.rb | 2 +- .../tasks/data_migrate_tasks_spec.rb | 14 ++-- .../data_migration_generator_spec.rb | 38 ++++++----- spec/spec_helper.rb | 12 ++-- tasks/databases.rake | 65 ++++++++++--------- 10 files changed, 115 insertions(+), 104 deletions(-) diff --git a/lib/data_migrate/database_tasks.rb b/lib/data_migrate/database_tasks.rb index 687641fe..e4e82184 100644 --- a/lib/data_migrate/database_tasks.rb +++ b/lib/data_migrate/database_tasks.rb @@ -41,7 +41,7 @@ def sort_migrations(*migrations) migrations.flatten.sort { |a, b| sort_string(a) <=> sort_string(b) } end - def sort_string(migration) + def sort_string migration "#{migration[:version]}_#{migration[:kind] == :data ? 1 : 0}" end @@ -56,44 +56,44 @@ def run_migration(migration, direction) else ::ActiveRecord::Migration.write("== %s %s" % ['Schema', "=" * 69]) ::DataMigrate::SchemaMigration.run( - direction, - ::DataMigrate::SchemaMigration.migrations_paths, - migration[:version] - ) + direction, + ::DataMigrate::SchemaMigration.migrations_paths, + migration[:version] + ) end end + end - def forward(step = 1) - DataMigrate::DataMigrator.assure_data_schema_table - migrations = pending_migrations.reverse.pop(step).reverse - migrations.each do | pending_migration | - if pending_migration[:kind] == :data - ActiveRecord::Migration.write("== %s %s" % ["Data", "=" * 71]) - DataMigrate::DataMigrator.run(:up, data_migrations_path, pending_migration[:version]) - elsif pending_migration[:kind] == :schema - ActiveRecord::Migration.write("== %s %s" % ["Schema", "=" * 69]) - DataMigrate::SchemaMigration.run(:up, DataMigrate::SchemaMigration.migrations_paths, pending_migration[:version]) - end + def self.forward(step = 1) + DataMigrate::DataMigrator.assure_data_schema_table + migrations = pending_migrations.reverse.pop(step).reverse + migrations.each do | pending_migration | + if pending_migration[:kind] == :data + ActiveRecord::Migration.write("== %s %s" % ["Data", "=" * 71]) + DataMigrate::DataMigrator.run(:up, data_migrations_path, pending_migration[:version]) + elsif pending_migration[:kind] == :schema + ActiveRecord::Migration.write("== %s %s" % ["Schema", "=" * 69]) + DataMigrate::SchemaMigration.run(:up, DataMigrate::SchemaMigration.migrations_paths, pending_migration[:version]) end end + end - def pending_data_migrations - data_migrations = DataMigrate::DataMigrator.migrations(data_migrations_path) - sort_migrations(DataMigrate::DataMigrator.new(:up, data_migrations ). - pending_migrations.map {|m| { version: m.version, name: m.name, kind: :data }}) - end + def self.pending_data_migrations + data_migrations = DataMigrate::DataMigrator.migrations(data_migrations_path) + sort_migrations(DataMigrate::DataMigrator.new(:up, data_migrations ). + pending_migrations.map {|m| { version: m.version, name: m.name, kind: :data }}) + end - def pending_schema_migrations - ::DataMigrate::SchemaMigration.pending_schema_migrations - end + def self.pending_schema_migrations + ::DataMigrate::SchemaMigration.pending_schema_migrations + end - def past_migrations(sort = nil) - data_versions = DataMigrate::DataSchemaMigration.table_exists? ? DataMigrate::DataSchemaMigration.normalized_versions : [] - schema_versions = ActiveRecord::SchemaMigration.normalized_versions - migrations = data_versions.map { |v| { version: v.to_i, kind: :data } } + schema_versions.map { |v| { version: v.to_i, kind: :schema } } + def self.past_migrations(sort = nil) + data_versions = DataMigrate::DataSchemaMigration.table_exists? ? DataMigrate::DataSchemaMigration.normalized_versions : [] + schema_versions = ActiveRecord::SchemaMigration.normalized_versions + migrations = data_versions.map { |v| { version: v.to_i, kind: :data } } + schema_versions.map { |v| { version: v.to_i, kind: :schema } } - sort&.downcase == "asc" ? sort_migrations(migrations) : sort_migrations(migrations).reverse - end + sort&.downcase == "asc" ? sort_migrations(migrations) : sort_migrations(migrations).reverse end end end diff --git a/lib/data_migrate/schema_migration.rb b/lib/data_migrate/schema_migration.rb index 1fe70a78..4c220f05 100644 --- a/lib/data_migrate/schema_migration.rb +++ b/lib/data_migrate/schema_migration.rb @@ -9,7 +9,7 @@ def self.pending_schema_migrations sort_migrations( ActiveRecord::Migrator.new(:up, all_migrations, ActiveRecord::Base.connection.schema_migration). pending_migrations. - map { |m| { version: m.version, kind: :schema } } + map {|m| { version: m.version, kind: :schema } } ) end @@ -19,7 +19,7 @@ def self.run(direction, migration_paths, version) def self.sort_migrations(set1, set2 = nil) migrations = set1 + (set2 || []) - migrations.sort {|a, b| sort_string(a) <=> sort_string(b) } + migrations.sort {|a, b| sort_string(a) <=> sort_string(b)} end def self.migrations_paths diff --git a/lib/data_migrate/tasks/data_migrate_tasks.rb b/lib/data_migrate/tasks/data_migrate_tasks.rb index 90ed9903..8d7ffad0 100644 --- a/lib/data_migrate/tasks/data_migrate_tasks.rb +++ b/lib/data_migrate/tasks/data_migrate_tasks.rb @@ -53,8 +53,8 @@ def status(db_config) def status_with_schema(db_config) db_list_data = ActiveRecord::Base.connection.select_values( - "SELECT version FROM #{DataMigrate::DataSchemaMigration.table_name}" - ) + "SELECT version FROM #{DataMigrate::DataSchemaMigration.table_name}" + ) db_list_schema = ActiveRecord::SchemaMigration.all.pluck(:version) file_list = [] @@ -83,14 +83,14 @@ def status_with_schema(db_config) puts "#{"Status".center(8)} #{"Type".center(8)} #{"Migration ID".ljust(14)} Migration Name" puts "-" * 60 file_list.each do |file| - puts "#{file[0].center(8)} #{file[3].center(8)} #{file[1].ljust(14)} #{file[2].humanize}" - end - db_list_schema.each do |version| - puts "#{'up'.center(8)} #{version.ljust(14)} *** NO SCHEMA FILE ***" - end - db_list_data.each do |version| - puts "#{'up'.center(8)} #{version.ljust(14)} *** NO DATA FILE ***" - end + puts "#{file[0].center(8)} #{file[3].center(8)} #{file[1].ljust(14)} #{file[2].humanize}" + end + db_list_schema.each do |version| + puts "#{'up'.center(8)} #{version.ljust(14)} *** NO SCHEMA FILE ***" + end + db_list_data.each do |version| + puts "#{'up'.center(8)} #{version.ljust(14)} *** NO DATA FILE ***" + end puts end diff --git a/spec/data_migrate/config_spec.rb b/spec/data_migrate/config_spec.rb index db872198..d02893d8 100644 --- a/spec/data_migrate/config_spec.rb +++ b/spec/data_migrate/config_spec.rb @@ -53,7 +53,7 @@ end it "equals the custom data template path" do - is_expected.to eq(data_template_path) + is_expected.to eq data_template_path end context "when path does not exist" do diff --git a/spec/data_migrate/data_schema_migration_spec.rb b/spec/data_migrate/data_schema_migration_spec.rb index 13597a80..af531f8c 100644 --- a/spec/data_migrate/data_schema_migration_spec.rb +++ b/spec/data_migrate/data_schema_migration_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require "spec_helper" +require 'spec_helper' describe DataMigrate::DataSchemaMigration do let(:subject) { DataMigrate::DataSchemaMigration } diff --git a/spec/data_migrate/migration.rb b/spec/data_migrate/migration.rb index fb21a54e..eab15cf2 100644 --- a/spec/data_migrate/migration.rb +++ b/spec/data_migrate/migration.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require "spec_helper" +require 'spec_helper' describe DataMigrate::Migration do describe ".table_name" do diff --git a/spec/data_migrate/tasks/data_migrate_tasks_spec.rb b/spec/data_migrate/tasks/data_migrate_tasks_spec.rb index d7ca942c..d6620b79 100644 --- a/spec/data_migrate/tasks/data_migrate_tasks_spec.rb +++ b/spec/data_migrate/tasks/data_migrate_tasks_spec.rb @@ -36,14 +36,14 @@ end end - context "when given a separate db config" do + context 'when given a separate db config' do let(:override_config) do { - "host" => "127.0.0.1", - "database" => "other_test", - "adapter" => "sqlite3", - "username" => "root", - "password" => nil + 'host' => '127.0.0.1', + 'database' => 'other_test', + 'adapter' => 'sqlite3', + 'username' => 'root', + 'password' => nil } end let(:paths) { ["spec/db/migrate"] } @@ -91,7 +91,7 @@ name: "A", version: 1 }, { - name: "B", + name: 'B', version: 2 }] end diff --git a/spec/generators/data_migration/data_migration_generator_spec.rb b/spec/generators/data_migration/data_migration_generator_spec.rb index 74b90ee4..3c319135 100644 --- a/spec/generators/data_migration/data_migration_generator_spec.rb +++ b/spec/generators/data_migration/data_migration_generator_spec.rb @@ -1,12 +1,12 @@ -require "spec_helper" -require "rails/generators" -require "rails/generators/migration" -require "generators/data_migration/data_migration_generator" +require 'spec_helper' +require 'rails/generators' +require 'rails/generators/migration' +require 'generators/data_migration/data_migration_generator' describe DataMigrate::Generators::DataMigrationGenerator do subject { DataMigrate::Generators::DataMigrationGenerator } - describe ".next_migration_number" do + describe :next_migration_number do it "next migration" do Timecop.freeze("2016-12-03 22:15:26 -0800") do if ActiveRecord.version >= Gem::Version.new("7.0") @@ -19,7 +19,7 @@ end end - describe ".migration_base_class_name" do + describe :migration_base_class_name do subject { generator.send(:migration_base_class_name) } let(:generator) { DataMigrate::Generators::DataMigrationGenerator.new(["my_migration"]) } @@ -29,14 +29,14 @@ end end - describe ".create_data_migration" do - subject { DataMigrate::Generators::DataMigrationGenerator.new(["my_migration"]) } + describe :create_data_migration do + subject { DataMigrate::Generators::DataMigrationGenerator.new(['my_migration']) } let(:data_migrations_file_path) { "abc/my_migration.rb" } context "when custom data migrations path has a trailing slash" do before do - DataMigrate.config.data_migrations_path = "abc/" + DataMigrate.config.data_migrations_path = 'abc/' end it "returns correct file path" do @@ -45,13 +45,15 @@ end end - context "when custom data migrations path does not have a trailing slash" do + context 'when custom data migrations path does not have a trailing slash' do before do - DataMigrate.config.data_migrations_path = "abc" + DataMigrate.config.data_migrations_path = 'abc' end - it "returns correct file path" do - is_expected.to receive(:migration_template).with("data_migration.rb", data_migrations_file_path) + it 'returns correct file path' do + is_expected.to receive(:migration_template).with( + 'data_migration.rb', data_migrations_file_path + ) subject.create_data_migration end end @@ -60,7 +62,11 @@ describe ".source_root" do subject { described_class.source_root } - let(:default_source_root) { File.expand_path(File.dirname(File.join(DataMigrate.root, "generators", "data_migration", "templates", "data_migration.rb"))) } + let(:default_source_root) do + File.expand_path(File.dirname( + File.join(DataMigrate.root, "generators", "data_migration", "templates", "data_migration.rb")) + ) + end it { is_expected.to eq default_source_root } @@ -72,7 +78,9 @@ end end - let(:data_template_path) { File.join(DataMigrate.root, "generators", "data_migration", "templates", "data_migration.rb") } + let(:data_template_path) do + File.join(DataMigrate.root, "generators", "data_migration", "templates", "data_migration.rb") + end let(:expected_source_root) { File.dirname(data_template_path) } after do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 40b68072..f9da55e4 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,9 +1,9 @@ -require "rspec" -require "rails" -require "sqlite3" -require "data_migrate" -require "pry" -require "timecop" +require 'rspec' +require 'rails' +require 'sqlite3' +require 'data_migrate' +require 'pry' +require 'timecop' RSpec.configure do |config| config.mock_with :rspec do |mocks| diff --git a/tasks/databases.rake b/tasks/databases.rake index 6a05c854..b1d5e1b0 100644 --- a/tasks/databases.rake +++ b/tasks/databases.rake @@ -1,6 +1,6 @@ # frozen_string_literal: true -require "data_migrate/tasks/data_migrate_tasks" +require 'data_migrate/tasks/data_migrate_tasks' namespace :db do namespace :migrate do @@ -16,22 +16,22 @@ namespace :db do migrations = [] if target_version.nil? - migrations = DataMigrate::DatabaseTasks.pending_migrations.map { |m| m.merge(direction: :up) } + migrations = DataMigrate::DatabaseTasks.pending_migrations.map{ |m| m.merge(:direction =>:up) } else current_schema_version = ActiveRecord::Migrator.current_version schema_migrations = if target_version > current_schema_version - DataMigrate::DatabaseTasks.pending_schema_migrations.keep_if{ |m| m[:version] <= target_version }.map{ |m| m.merge(direction: :up) } + DataMigrate::DatabaseTasks.pending_schema_migrations.keep_if{ |m| m[:version] <= target_version }.map{ |m| m.merge(:direction =>:up) } elsif target_version < current_schema_version - DataMigrate::DatabaseTasks.past_migrations.keep_if{ |m| m[:version] > target_version }.map{ |m| m.merge(direction: :down) } + DataMigrate::DatabaseTasks.past_migrations.keep_if{ |m| m[:version] > target_version }.map{ |m| m.merge(:direction =>:down) } else # == [] end current_data_version = DataMigrate::DataMigrator.current_version data_migrations = if target_version > current_data_version - DataMigrate::DatabaseTasks.pending_data_migrations.keep_if{ |m| m[:version] <= target_version }.map{ |m| m.merge(direction: :up) } + DataMigrate::DatabaseTasks.pending_data_migrations.keep_if{ |m| m[:version] <= target_version }.map{ |m| m.merge(:direction =>:up) } elsif target_version < current_data_version - DataMigrate::DatabaseTasks.past_migrations.keep_if{ |m| m[:version] > target_version }.map{ |m| m.merge(direction: :down) } + DataMigrate::DatabaseTasks.past_migrations.keep_if{ |m| m[:version] > target_version }.map{ |m| m.merge(:direction =>:down) } else # == [] end @@ -62,8 +62,8 @@ namespace :db do end namespace :redo do - desc "Rollbacks the database one migration and re migrate up (options: STEP=x, VERSION=x)." - task with_data: :environment do + desc 'Rollbacks the database one migration and re migrate up (options: STEP=x, VERSION=x).' + task :with_data => :environment do DataMigrate::DataMigrator.assure_data_schema_table if ENV["VERSION"] Rake::Task["db:migrate:down:with_data"].invoke @@ -77,7 +77,7 @@ namespace :db do namespace :up do desc 'Runs the "up" for a given migration VERSION. (options both=false)' - task with_data: :environment do + task :with_data => :environment do version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil raise "VERSION is required" unless version DataMigrate::DataMigrator.assure_data_schema_table @@ -99,7 +99,7 @@ namespace :db do namespace :down do desc 'Runs the "down" for a given migration VERSION. (option BOTH=false)' - task with_data: :environment do + task :with_data => :environment do version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil raise "VERSION is required" unless version DataMigrate::DataMigrator.assure_data_schema_table @@ -121,7 +121,7 @@ namespace :db do namespace :status do desc "Display status of data and schema migrations" - task with_data: :environment do + task :with_data => :environment do ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env).each do |db_config| ActiveRecord::Base.establish_connection(db_config) DataMigrate::Tasks::DataMigrateTasks.status_with_schema(db_config) @@ -131,9 +131,9 @@ namespace :db do end # END OF MIGRATE NAME SPACE namespace :rollback do - desc "Rolls the schema back to the previous version (specify steps w/ STEP=n)." - task with_data: :environment do - step = ENV["STEP"] ? ENV["STEP"].to_i : 1 + desc 'Rolls the schema back to the previous version (specify steps w/ STEP=n).' + task :with_data => :environment do + step = ENV['STEP'] ? ENV['STEP'].to_i : 1 DataMigrate::DataMigrator.assure_data_schema_table DataMigrate::DatabaseTasks.past_migrations[0..(step - 1)].each do | past_migration | DataMigrate::DatabaseTasks.run_migration(past_migration, :down) @@ -146,7 +146,7 @@ namespace :db do namespace :forward do desc "Pushes the schema to the next version (specify steps w/ STEP=n)." - task with_data: :environment do + task :with_data => :environment do DataMigrate::DataMigrator.assure_data_schema_table step = ENV["STEP"] ? ENV["STEP"].to_i : 1 DataMigrate::DatabaseTasks.forward(step) @@ -157,7 +157,7 @@ namespace :db do namespace :version do desc "Retrieves the current schema version numbers for data and schema migrations" - task with_data: :environment do + task :with_data => :environment do DataMigrate::DataMigrator.assure_data_schema_table puts "Current Schema version: #{ActiveRecord::Migrator.current_version}" puts "Current Data version: #{DataMigrate::DataMigrator.current_version}" @@ -194,8 +194,8 @@ namespace :db do end namespace :data do - desc "Migrate data migrations (options: VERSION=x, VERBOSE=false)" - task migrate: :environment do + desc 'Migrate data migrations (options: VERSION=x, VERBOSE=false)' + task :migrate => :environment do original_db_config = ActiveRecord::Base.connection_db_config ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env).each do |db_config| ActiveRecord::Base.establish_connection(db_config) @@ -207,8 +207,8 @@ namespace :data do end namespace :migrate do - desc "Rollbacks the database one migration and re migrate up (options: STEP=x, VERSION=x)." - task redo: :environment do + desc 'Rollbacks the database one migration and re migrate up (options: STEP=x, VERSION=x).' + task :redo => :environment do DataMigrate::DataMigrator.assure_data_schema_table if ENV["VERSION"] Rake::Task["data:migrate:down"].invoke @@ -220,7 +220,7 @@ namespace :data do end desc 'Runs the "up" for a given migration VERSION.' - task up: :environment do + task :up => :environment do DataMigrate::DataMigrator.assure_data_schema_table version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil raise "VERSION is required" unless version @@ -229,7 +229,7 @@ namespace :data do end desc 'Runs the "down" for a given migration VERSION.' - task down: :environment do + task :down => :environment do version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil raise "VERSION is required" unless version DataMigrate::DataMigrator.assure_data_schema_table @@ -246,20 +246,20 @@ namespace :data do end end - desc "Rolls the schema back to the previous version (specify steps w/ STEP=n)." - task rollback: :environment do + desc 'Rolls the schema back to the previous version (specify steps w/ STEP=n).' + task :rollback => :environment do DataMigrate::DataMigrator.assure_data_schema_table - step = ENV["STEP"] ? ENV["STEP"].to_i : 1 + step = ENV['STEP'] ? ENV['STEP'].to_i : 1 DataMigrate::DataMigrator.rollback(DataMigrate::DatabaseTasks.data_migrations_path, step) Rake::Task["data:dump"].invoke end - desc "Pushes the schema to the next version (specify steps w/ STEP=n)." - task forward: :environment do + desc 'Pushes the schema to the next version (specify steps w/ STEP=n).' + task :forward => :environment do DataMigrate::DataMigrator.assure_data_schema_table - step = ENV["STEP"] ? ENV["STEP"].to_i : 1 + step = ENV['STEP'] ? ENV['STEP'].to_i : 1 # TODO: No worky for .forward - # DataMigrate::DataMigrator.forward("db/data/", step) + # DataMigrate::DataMigrator.forward('db/data/', step) migrations = DataMigrate::DatabaseTasks.pending_data_migrations.reverse.pop(step).reverse migrations.each do | pending_migration | DataMigrate::DataMigrator.run(:up, DataMigrate::DatabaseTasks.data_migrations_path, pending_migration[:version]) @@ -268,7 +268,7 @@ namespace :data do end desc "Retrieves the current schema version number for data migrations" - task version: :environment do + task :version => :environment do DataMigrate::DataMigrator.assure_data_schema_table puts "Current data version: #{DataMigrate::DataMigrator.current_version}" end @@ -295,7 +295,10 @@ namespace :data do namespace :schema do desc "Load data_schema.rb file into the database" task load: :environment do - DataMigrate::DatabaseTasks.load_schema_current(:ruby, ENV["DATA_SCHEMA"]) + DataMigrate::DatabaseTasks.load_schema_current( + :ruby, + ENV["DATA_SCHEMA"] + ) end end end From 9c2715660458232aaff5380ccfd9b675bd07364e Mon Sep 17 00:00:00 2001 From: Chaunce Butterfield Date: Fri, 21 Apr 2023 11:39:40 -0600 Subject: [PATCH 10/98] revert formatting changes --- lib/data_migrate/schema_migration.rb | 2 +- lib/data_migrate/tasks/data_migrate_tasks.rb | 2 - spec/data_migrate/data_migrator_spec.rb | 4 +- .../data_schema_migration_spec.rb | 4 +- spec/data_migrate/data_spec.rb | 3 +- spec/data_migrate/database_tasks_spec.rb | 4 +- spec/data_migrate/migration_context_spec.rb | 20 ++--- spec/data_migrate/schema_migration_spec.rb | 12 ++- spec/data_migrate/status_service_spec.rb | 2 +- .../tasks/data_migrate_tasks_spec.rb | 6 +- .../data_migration_generator_spec.rb | 18 ++-- tasks/databases.rake | 90 ++++++++++--------- 12 files changed, 82 insertions(+), 85 deletions(-) diff --git a/lib/data_migrate/schema_migration.rb b/lib/data_migrate/schema_migration.rb index 4c220f05..3369c4d9 100644 --- a/lib/data_migrate/schema_migration.rb +++ b/lib/data_migrate/schema_migration.rb @@ -9,7 +9,7 @@ def self.pending_schema_migrations sort_migrations( ActiveRecord::Migrator.new(:up, all_migrations, ActiveRecord::Base.connection.schema_migration). pending_migrations. - map {|m| { version: m.version, kind: :schema } } + map {|m| { version: m.version, kind: :schema }} ) end diff --git a/lib/data_migrate/tasks/data_migrate_tasks.rb b/lib/data_migrate/tasks/data_migrate_tasks.rb index 8d7ffad0..12a45cc3 100644 --- a/lib/data_migrate/tasks/data_migrate_tasks.rb +++ b/lib/data_migrate/tasks/data_migrate_tasks.rb @@ -12,9 +12,7 @@ def migrations_paths def dump(db_config) if dump_schema_after_migration? filename = DataMigrate::DatabaseTasks.dump_filename(spec_name(db_config), ActiveRecord::Base.schema_format) - ActiveRecord::Base.establish_connection(DataMigrate.config.db_configuration) if DataMigrate.config.db_configuration - File.open(filename, "w:utf-8") do |file| DataMigrate::SchemaDumper.dump(ActiveRecord::Base.connection, file) end diff --git a/spec/data_migrate/data_migrator_spec.rb b/spec/data_migrate/data_migrator_spec.rb index 1f081d9f..d43a752f 100644 --- a/spec/data_migrate/data_migrator_spec.rb +++ b/spec/data_migrate/data_migrator_spec.rb @@ -36,7 +36,7 @@ end end - describe ".assure_data_schema_table" do + describe :assure_data_schema_table do it "creates the data_migrations table" do ActiveRecord::Migration.drop_table("data_migrations") rescue nil subject.assure_data_schema_table @@ -55,7 +55,7 @@ end end - describe ".match" do + describe :match do context "when the file does not match" do it "returns nil" do expect(subject.match("not_a_data_migration_file")).to be_nil diff --git a/spec/data_migrate/data_schema_migration_spec.rb b/spec/data_migrate/data_schema_migration_spec.rb index af531f8c..b2dd8ff2 100644 --- a/spec/data_migrate/data_schema_migration_spec.rb +++ b/spec/data_migrate/data_schema_migration_spec.rb @@ -5,13 +5,13 @@ describe DataMigrate::DataSchemaMigration do let(:subject) { DataMigrate::DataSchemaMigration } - describe ".table_name" do + describe :table_name do it "returns correct table name" do expect(subject.table_name).to eq("data_migrations") end end - describe ".index_name" do + describe :index_name do it "returns correct primary key name" do expect(subject.primary_key).to eq("version") end diff --git a/spec/data_migrate/data_spec.rb b/spec/data_migrate/data_spec.rb index 4060f00a..f1416f27 100644 --- a/spec/data_migrate/data_spec.rb +++ b/spec/data_migrate/data_spec.rb @@ -21,7 +21,7 @@ end end - describe ".define" do + describe :define do after do ActiveRecord::Migration.drop_table("data_migrations") end @@ -48,6 +48,7 @@ it "creates entries for migration versions that come " \ "before the supplied version" do + version = fixture_file_timestamps[1] subject.define(version: version) diff --git a/spec/data_migrate/database_tasks_spec.rb b/spec/data_migrate/database_tasks_spec.rb index 3cb5c5b7..fd3a1307 100644 --- a/spec/data_migrate/database_tasks_spec.rb +++ b/spec/data_migrate/database_tasks_spec.rb @@ -54,7 +54,7 @@ }.at_least(:once) end - describe ".past_migrations" do + describe :past_migrations do it "returns past migration records" do subject.forward migrations = subject.past_migrations @@ -68,7 +68,7 @@ end end - describe ".forward" do + describe :forward do it "run forward default amount of times" do subject.forward versions = DataMigrate::DataSchemaMigration.normalized_versions diff --git a/spec/data_migrate/migration_context_spec.rb b/spec/data_migrate/migration_context_spec.rb index 05a73724..182948fb 100644 --- a/spec/data_migrate/migration_context_spec.rb +++ b/spec/data_migrate/migration_context_spec.rb @@ -21,7 +21,6 @@ context.migrate(nil) context.migrations_status versions = DataMigrate::DataSchemaMigration.normalized_versions - expect(versions.count).to eq(2) expect(versions).to include("20091231235959") expect(versions).to include("20171231235959") @@ -31,14 +30,12 @@ context.migrate(nil) context.run(:down, 20171231235959) versions = DataMigrate::DataSchemaMigration.normalized_versions - expect(versions.count).to eq(1) expect(versions).to include("20091231235959") end it "does not do anything if migration is undone twice" do context.migrate(nil) - expect { context.run(:down, 20171231235959) }.to output(/Undoing SuperUpdate/).to_stdout @@ -50,7 +47,6 @@ it "runs a specific migration" do context.run(:up, 20171231235959) versions = DataMigrate::DataSchemaMigration.normalized_versions - expect(versions.count).to eq(1) expect(versions).to include("20171231235959") end @@ -65,18 +61,20 @@ end it "alerts for an invalid specific migration" do - expect { context.run(:up, 201712312) }.to raise_error(ActiveRecord::UnknownMigrationVersionError, /No migration with version number 201712312/) + expect { + context.run(:up, 201712312) + }.to raise_error( + ActiveRecord::UnknownMigrationVersionError, + /No migration with version number 201712312/ + ) end it "rolls back latest migration" do context.migrate(nil) - expect { context.rollback }.to output(/Undoing SuperUpdate/).to_stdout - versions = DataMigrate::DataSchemaMigration.normalized_versions - expect(versions.count).to eq(1) expect(versions).to include("20091231235959") end @@ -84,25 +82,19 @@ it "rolls back 2 migrations" do context.migrate(nil) schema_context.migrate(nil) - expect { context.rollback(2) }.to output(/Undoing SomeName/).to_stdout - versions = DataMigrate::DataSchemaMigration.normalized_versions - expect(versions.count).to eq(0) end it "rolls back 2 migrations" do context.migrate(nil) - expect { context.rollback(2) }.to output(/Undoing SomeName/).to_stdout - versions = DataMigrate::DataSchemaMigration.normalized_versions - expect(versions.count).to eq(0) end end diff --git a/spec/data_migrate/schema_migration_spec.rb b/spec/data_migrate/schema_migration_spec.rb index 61d86e22..82b538c7 100644 --- a/spec/data_migrate/schema_migration_spec.rb +++ b/spec/data_migrate/schema_migration_spec.rb @@ -19,7 +19,7 @@ ActiveRecord::Migration.drop_table("schema_migrations") rescue nil end - describe ".pending_schema_migrations" do + describe :pending_schema_migrations do it "list sorted schema migrations" do expect(subject).to receive(:migrations_paths) { migration_path @@ -33,14 +33,12 @@ end end - describe ".run" do + describe :run do it "can run up task" do expect { subject.run(:up, migration_path, 20202020202011) }.to output(/20202020202011 DbMigration: migrating/).to_stdout - versions = ActiveRecord::SchemaMigration.normalized_versions - expect(versions.first).to eq("20202020202011") end @@ -57,8 +55,8 @@ end end - describe ".migrations_paths" do - context "when a db_name is configured" do + describe :migrations_paths do + context 'when a db_name is configured' do let(:config) { double(:config) } let(:paths) { ['spec/db/migrate', 'spec/db/migrate/other'] } let(:specification_name) { "primary" } @@ -90,7 +88,7 @@ end end - it "lists schema migration paths" do + it 'lists schema migration paths' do expect(subject.migrations_paths.size).to eq(paths.count) expect(subject.migrations_paths).to eq(paths) end diff --git a/spec/data_migrate/status_service_spec.rb b/spec/data_migrate/status_service_spec.rb index 49e231e8..79a4f6af 100644 --- a/spec/data_migrate/status_service_spec.rb +++ b/spec/data_migrate/status_service_spec.rb @@ -16,7 +16,7 @@ context "table does not exists" do before do - allow_any_instance_of(subject).to receive(:table_name) { "bogus" } + allow_any_instance_of(subject).to receive(:table_name) { "bogus"} subject.dump(connection_db_config, stream) stream.rewind diff --git a/spec/data_migrate/tasks/data_migrate_tasks_spec.rb b/spec/data_migrate/tasks/data_migrate_tasks_spec.rb index d6620b79..463690dd 100644 --- a/spec/data_migrate/tasks/data_migrate_tasks_spec.rb +++ b/spec/data_migrate/tasks/data_migrate_tasks_spec.rb @@ -43,7 +43,7 @@ 'database' => 'other_test', 'adapter' => 'sqlite3', 'username' => 'root', - 'password' => nil + 'password' => nil, } end let(:paths) { ["spec/db/migrate"] } @@ -62,7 +62,7 @@ end end - describe ".migrate" do + describe :migrate do it "first run should run the first pending migration" do expect { DataMigrate::Tasks::DataMigrateTasks.migrate }.to output(/20091231235959 SomeName: migrating/).to_stdout end @@ -72,7 +72,7 @@ end end - describe ".abort_if_pending_migrations" do + describe :abort_if_pending_migrations do subject { DataMigrate::Tasks::DataMigrateTasks.abort_if_pending_migrations(migrations, message) } let(:message) { "ABORT_MESSAGE" } diff --git a/spec/generators/data_migration/data_migration_generator_spec.rb b/spec/generators/data_migration/data_migration_generator_spec.rb index 3c319135..8e20b7e1 100644 --- a/spec/generators/data_migration/data_migration_generator_spec.rb +++ b/spec/generators/data_migration/data_migration_generator_spec.rb @@ -9,7 +9,7 @@ describe :next_migration_number do it "next migration" do Timecop.freeze("2016-12-03 22:15:26 -0800") do - if ActiveRecord.version >= Gem::Version.new("7.0") + if ActiveRecord.version >= Gem::Version.new('7.0') expect(ActiveRecord).to receive(:timestamped_migrations) { true } else expect(ActiveRecord::Base).to receive(:timestamped_migrations) { true } @@ -22,7 +22,7 @@ describe :migration_base_class_name do subject { generator.send(:migration_base_class_name) } - let(:generator) { DataMigrate::Generators::DataMigrationGenerator.new(["my_migration"]) } + let(:generator) { DataMigrate::Generators::DataMigrationGenerator.new(['my_migration']) } it "returns the correct base class name" do is_expected.to eq("ActiveRecord::Migration[#{ActiveRecord::Migration.current_version}]") @@ -32,15 +32,17 @@ describe :create_data_migration do subject { DataMigrate::Generators::DataMigrationGenerator.new(['my_migration']) } - let(:data_migrations_file_path) { "abc/my_migration.rb" } + let(:data_migrations_file_path) { 'abc/my_migration.rb' } - context "when custom data migrations path has a trailing slash" do + context 'when custom data migrations path has a trailing slash' do before do DataMigrate.config.data_migrations_path = 'abc/' end - it "returns correct file path" do - is_expected.to receive(:migration_template).with("data_migration.rb", data_migrations_file_path) + it 'returns correct file path' do + is_expected.to receive(:migration_template).with( + 'data_migration.rb', data_migrations_file_path + ) subject.create_data_migration end end @@ -63,8 +65,8 @@ subject { described_class.source_root } let(:default_source_root) do - File.expand_path(File.dirname( - File.join(DataMigrate.root, "generators", "data_migration", "templates", "data_migration.rb")) + File.expand_path( + File.dirname(File.join(DataMigrate.root, "generators", "data_migration", "templates", "data_migration.rb")) ) end diff --git a/tasks/databases.rake b/tasks/databases.rake index b1d5e1b0..41e4c173 100644 --- a/tasks/databases.rake +++ b/tasks/databases.rake @@ -5,54 +5,54 @@ require 'data_migrate/tasks/data_migrate_tasks' namespace :db do namespace :migrate do desc "Migrate the database data and schema (options: VERSION=x, VERBOSE=false)." - task with_data: :environment do + task :with_data => :environment do original_db_config = ActiveRecord::Base.connection_db_config ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env).each do |db_config| ActiveRecord::Base.establish_connection(db_config) DataMigrate::DataMigrator.assure_data_schema_table - ActiveRecord::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true - target_version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil - migrations = [] + ActiveRecord::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true + target_version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil + migrations = [] - if target_version.nil? - migrations = DataMigrate::DatabaseTasks.pending_migrations.map{ |m| m.merge(:direction =>:up) } - else - current_schema_version = ActiveRecord::Migrator.current_version - schema_migrations = if target_version > current_schema_version - DataMigrate::DatabaseTasks.pending_schema_migrations.keep_if{ |m| m[:version] <= target_version }.map{ |m| m.merge(:direction =>:up) } - elsif target_version < current_schema_version - DataMigrate::DatabaseTasks.past_migrations.keep_if{ |m| m[:version] > target_version }.map{ |m| m.merge(:direction =>:down) } - else # == - [] - end - - current_data_version = DataMigrate::DataMigrator.current_version - data_migrations = if target_version > current_data_version - DataMigrate::DatabaseTasks.pending_data_migrations.keep_if{ |m| m[:version] <= target_version }.map{ |m| m.merge(:direction =>:up) } - elsif target_version < current_data_version + if target_version.nil? + migrations = DataMigrate::DatabaseTasks.pending_migrations.map{ |m| m.merge(:direction =>:up) } + else + current_schema_version = ActiveRecord::Migrator.current_version + schema_migrations = if target_version > current_schema_version + DataMigrate::DatabaseTasks.pending_schema_migrations.keep_if{ |m| m[:version] <= target_version }.map{ |m| m.merge(:direction =>:up) } + elsif target_version < current_schema_version DataMigrate::DatabaseTasks.past_migrations.keep_if{ |m| m[:version] > target_version }.map{ |m| m.merge(:direction =>:down) } else # == [] end - migrations = if schema_migrations.empty? - data_migrations - elsif data_migrations.empty? - schema_migrations - elsif target_version > current_data_version && target_version > current_schema_version - DataMigrate::DatabaseTasks.sort_migrations data_migrations, schema_migrations - elsif target_version < current_data_version && target_version < current_schema_version - DataMigrate::DatabaseTasks.sort_migrations(data_migrations, schema_migrations).reverse - elsif target_version > current_data_version && target_version < current_schema_version - schema_migrations + data_migrations - elsif target_version < current_data_version && target_version > current_schema_version - schema_migrations + data_migrations - end - end - migrations.each do |migration| - DataMigrate::DatabaseTasks.run_migration(migration, migration[:direction]) - end + current_data_version = DataMigrate::DataMigrator.current_version + data_migrations = if target_version > current_data_version + DataMigrate::DatabaseTasks.pending_data_migrations.keep_if{ |m| m[:version] <= target_version }.map{ |m| m.merge(:direction =>:up) } + elsif target_version < current_data_version + DataMigrate::DatabaseTasks.past_migrations.keep_if{ |m| m[:version] > target_version }.map{ |m| m.merge(:direction =>:down) } + else # == + [] + end + migrations = if schema_migrations.empty? + data_migrations + elsif data_migrations.empty? + schema_migrations + elsif target_version > current_data_version && target_version > current_schema_version + DataMigrate::DatabaseTasks.sort_migrations data_migrations, schema_migrations + elsif target_version < current_data_version && target_version < current_schema_version + DataMigrate::DatabaseTasks.sort_migrations(data_migrations, schema_migrations).reverse + elsif target_version > current_data_version && target_version < current_schema_version + schema_migrations + data_migrations + elsif target_version < current_data_version && target_version > current_schema_version + schema_migrations + data_migrations + end + end + + migrations.each do |migration| + DataMigrate::DatabaseTasks.run_migration(migration, migration[:direction]) + end end Rake::Task["db:_dump"].invoke @@ -145,10 +145,10 @@ namespace :db do end namespace :forward do - desc "Pushes the schema to the next version (specify steps w/ STEP=n)." + desc 'Pushes the schema to the next version (specify steps w/ STEP=n).' task :with_data => :environment do DataMigrate::DataMigrator.assure_data_schema_table - step = ENV["STEP"] ? ENV["STEP"].to_i : 1 + step = ENV['STEP'] ? ENV['STEP'].to_i : 1 DataMigrate::DatabaseTasks.forward(step) Rake::Task["db:_dump"].invoke Rake::Task["data:dump"].invoke @@ -177,7 +177,10 @@ namespace :db do desc "Load both schema.rb and data_schema.rb file into the database" task with_data: :environment do Rake::Task["db:schema:load"].invoke - DataMigrate::DatabaseTasks.load_schema_current(:ruby, ENV["DATA_SCHEMA"]) + DataMigrate::DatabaseTasks.load_schema_current( + :ruby, + ENV["DATA_SCHEMA"] + ) end end end @@ -187,7 +190,10 @@ namespace :db do desc "Load both structure.sql and data_schema.rb file into the database" task with_data: :environment do Rake::Task["db:structure:load"].invoke - DataMigrate::DatabaseTasks.load_schema_current(:ruby, ENV["DATA_SCHEMA"]) + DataMigrate::DatabaseTasks.load_schema_current( + :ruby, + ENV["DATA_SCHEMA"] + ) end end end @@ -207,7 +213,7 @@ namespace :data do end namespace :migrate do - desc 'Rollbacks the database one migration and re migrate up (options: STEP=x, VERSION=x).' + desc 'Rollbacks the database one migration and re migrate up (options: STEP=x, VERSION=x).' task :redo => :environment do DataMigrate::DataMigrator.assure_data_schema_table if ENV["VERSION"] From 64911508ae4e8fc1d333d860bd5d2ac5b38d187a Mon Sep 17 00:00:00 2001 From: Chaunce Butterfield Date: Fri, 21 Apr 2023 11:49:12 -0600 Subject: [PATCH 11/98] revert formatting changes --- spec/data_migrate/data_migrator_spec.rb | 1 - spec/data_migrate/data_schema_migration_spec.rb | 1 - spec/data_migrate/database_tasks_spec.rb | 1 + spec/data_migrate/tasks/data_migrate_tasks_spec.rb | 4 ++-- .../data_migration/data_migration_generator_spec.rb | 2 ++ tasks/databases.rake | 4 +++- 6 files changed, 8 insertions(+), 5 deletions(-) diff --git a/spec/data_migrate/data_migrator_spec.rb b/spec/data_migrate/data_migrator_spec.rb index d43a752f..ec6ccbe1 100644 --- a/spec/data_migrate/data_migrator_spec.rb +++ b/spec/data_migrate/data_migrator_spec.rb @@ -28,7 +28,6 @@ ::ActiveRecord::SchemaMigration.create(version: 20100000000000) DataMigrate::DataSchemaMigration.create(version: 20110000000000) ::ActiveRecord::SchemaMigration.create(version: 20120000000000) - migrated = subject.new(:up, []).load_migrated expect(migrated.count).to eq 2 expect(migrated).to include 20090000000000 diff --git a/spec/data_migrate/data_schema_migration_spec.rb b/spec/data_migrate/data_schema_migration_spec.rb index b2dd8ff2..70750dcf 100644 --- a/spec/data_migrate/data_schema_migration_spec.rb +++ b/spec/data_migrate/data_schema_migration_spec.rb @@ -4,7 +4,6 @@ describe DataMigrate::DataSchemaMigration do let(:subject) { DataMigrate::DataSchemaMigration } - describe :table_name do it "returns correct table name" do expect(subject.table_name).to eq("data_migrations") diff --git a/spec/data_migrate/database_tasks_spec.rb b/spec/data_migrate/database_tasks_spec.rb index fd3a1307..563fb8cb 100644 --- a/spec/data_migrate/database_tasks_spec.rb +++ b/spec/data_migrate/database_tasks_spec.rb @@ -69,6 +69,7 @@ end describe :forward do + it "run forward default amount of times" do subject.forward versions = DataMigrate::DataSchemaMigration.normalized_versions diff --git a/spec/data_migrate/tasks/data_migrate_tasks_spec.rb b/spec/data_migrate/tasks/data_migrate_tasks_spec.rb index 463690dd..ffcd8897 100644 --- a/spec/data_migrate/tasks/data_migrate_tasks_spec.rb +++ b/spec/data_migrate/tasks/data_migrate_tasks_spec.rb @@ -21,7 +21,7 @@ ActiveRecord::Migration.drop_table("schema_migrations") rescue nil end - describe ".dump" do + describe :dump do before do allow(DataMigrate::DatabaseTasks).to receive(:db_dir).and_return("spec/db") DataMigrate::Tasks::DataMigrateTasks.migrate @@ -54,7 +54,7 @@ end end - it "overrides the default connection" do + it 'overrides the default connection' do expect(ActiveRecord::Base).to receive(:establish_connection).with(override_config) DataMigrate::Tasks::DataMigrateTasks.dump(connection_db_config) diff --git a/spec/generators/data_migration/data_migration_generator_spec.rb b/spec/generators/data_migration/data_migration_generator_spec.rb index 8e20b7e1..47547154 100644 --- a/spec/generators/data_migration/data_migration_generator_spec.rb +++ b/spec/generators/data_migration/data_migration_generator_spec.rb @@ -43,6 +43,7 @@ is_expected.to receive(:migration_template).with( 'data_migration.rb', data_migrations_file_path ) + subject.create_data_migration end end @@ -56,6 +57,7 @@ is_expected.to receive(:migration_template).with( 'data_migration.rb', data_migrations_file_path ) + subject.create_data_migration end end diff --git a/tasks/databases.rake b/tasks/databases.rake index 41e4c173..c9623202 100644 --- a/tasks/databases.rake +++ b/tasks/databases.rake @@ -177,6 +177,7 @@ namespace :db do desc "Load both schema.rb and data_schema.rb file into the database" task with_data: :environment do Rake::Task["db:schema:load"].invoke + DataMigrate::DatabaseTasks.load_schema_current( :ruby, ENV["DATA_SCHEMA"] @@ -190,6 +191,7 @@ namespace :db do desc "Load both structure.sql and data_schema.rb file into the database" task with_data: :environment do Rake::Task["db:structure:load"].invoke + DataMigrate::DatabaseTasks.load_schema_current( :ruby, ENV["DATA_SCHEMA"] @@ -244,7 +246,7 @@ namespace :data do end desc "Display status of data migrations" - task status: :environment do + task :status => :environment do ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env).each do |db_config| ActiveRecord::Base.establish_connection(db_config) DataMigrate::Tasks::DataMigrateTasks.status(db_config) From 130349b89998c7e45d4f1ff09c0d386f07909915 Mon Sep 17 00:00:00 2001 From: Chaunce Butterfield Date: Fri, 21 Apr 2023 11:55:40 -0600 Subject: [PATCH 12/98] revert formatting changes --- lib/data_migrate/config.rb | 2 -- lib/data_migrate/data_schema_migration.rb | 2 -- lib/data_migrate/legacy_migrator.rb | 2 -- lib/data_migrate/migration_context.rb | 2 -- lib/data_migrate/railtie.rb | 2 -- spec/data_migrate/data_schema_migration_spec.rb | 2 -- 6 files changed, 12 deletions(-) diff --git a/lib/data_migrate/config.rb b/lib/data_migrate/config.rb index ffd751d3..15abf276 100644 --- a/lib/data_migrate/config.rb +++ b/lib/data_migrate/config.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - module DataMigrate include ActiveSupport::Configurable class << self diff --git a/lib/data_migrate/data_schema_migration.rb b/lib/data_migrate/data_schema_migration.rb index 80f7c982..68316664 100644 --- a/lib/data_migrate/data_schema_migration.rb +++ b/lib/data_migrate/data_schema_migration.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - module DataMigrate class DataSchemaMigration class << self diff --git a/lib/data_migrate/legacy_migrator.rb b/lib/data_migrate/legacy_migrator.rb index 06328937..b1f4ba56 100644 --- a/lib/data_migrate/legacy_migrator.rb +++ b/lib/data_migrate/legacy_migrator.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - module DataMigrate class LegacyMigrator def initialize(migrations_paths = "db/data") diff --git a/lib/data_migrate/migration_context.rb b/lib/data_migrate/migration_context.rb index a43a085b..48d2bbbb 100644 --- a/lib/data_migrate/migration_context.rb +++ b/lib/data_migrate/migration_context.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - module DataMigrate class MigrationContext < ActiveRecord::MigrationContext def initialize(migrations_paths = "db/data") diff --git a/lib/data_migrate/railtie.rb b/lib/data_migrate/railtie.rb index 2bcf91a2..95a1b125 100644 --- a/lib/data_migrate/railtie.rb +++ b/lib/data_migrate/railtie.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - module DataMigrate class Railtie < ::Rails::Railtie generators = config.respond_to?(:app_generators) ? config.app_generators : config.generators diff --git a/spec/data_migrate/data_schema_migration_spec.rb b/spec/data_migrate/data_schema_migration_spec.rb index 70750dcf..f7133b78 100644 --- a/spec/data_migrate/data_schema_migration_spec.rb +++ b/spec/data_migrate/data_schema_migration_spec.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - require 'spec_helper' describe DataMigrate::DataSchemaMigration do From c3624a5dd32e71d66c4347c8622e450c67f6349a Mon Sep 17 00:00:00 2001 From: Chaunce Butterfield Date: Fri, 21 Apr 2023 12:08:03 -0600 Subject: [PATCH 13/98] remove deprecated method Dir.exists? --- lib/data_migrate/tasks/data_migrate_tasks.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/data_migrate/tasks/data_migrate_tasks.rb b/lib/data_migrate/tasks/data_migrate_tasks.rb index 12a45cc3..c72e1aa3 100644 --- a/lib/data_migrate/tasks/data_migrate_tasks.rb +++ b/lib/data_migrate/tasks/data_migrate_tasks.rb @@ -65,7 +65,7 @@ def status_with_schema(db_config) end DataMigrate::SchemaMigration.migrations_paths.map do |path| - Dir.children(path) if Dir.exists?(path) + Dir.children(path) if Dir.exist?(path) end.flatten.compact.each do |file| # only files matching "20091231235959_some_name.rb" pattern if match_data = /(\d{14})_(.+)\.rb/.match(file) From 2be73e133b391f3ea8776fbf1f6965a9a60ebcbc Mon Sep 17 00:00:00 2001 From: Ilya Katz Date: Sun, 23 Apr 2023 16:12:53 -0700 Subject: [PATCH 14/98] Bump version to rc1 --- Changelog.md | 8 ++++++++ lib/data_migrate/version.rb | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Changelog.md b/Changelog.md index f9f039ed..2f8b279f 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,13 @@ # Changelog +## 10.0.0.rc1 + +- Changes by [chaunce](https//:github.com/chaunce) +- Multiple databases support +- Refactor to clean things up +- Deprecate rails 5.2 support for real + + ## 9.0.0 Ruby 3.2 support [mehanoid](https://github.com/mehanoid) diff --git a/lib/data_migrate/version.rb b/lib/data_migrate/version.rb index 6873c591..2f854e0c 100644 --- a/lib/data_migrate/version.rb +++ b/lib/data_migrate/version.rb @@ -1,3 +1,3 @@ module DataMigrate - VERSION = "9.0.0".freeze + VERSION = "10.0.0.rc1".freeze end From 4cb99fa6bcee098351fd8b5ab7ad3615bb0327df Mon Sep 17 00:00:00 2001 From: Ilya Katz Date: Sun, 23 Apr 2023 16:13:49 -0700 Subject: [PATCH 15/98] Push RC version from feature branch --- .github/workflows/gempush.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/gempush.yml b/.github/workflows/gempush.yml index 4ba95cb6..f2f0bfff 100644 --- a/.github/workflows/gempush.yml +++ b/.github/workflows/gempush.yml @@ -4,6 +4,7 @@ on: push: branches: - main + - chaunce-multiple_connection_support jobs: build: From ff47fcfac967560028959ef5396572ab8c88af1e Mon Sep 17 00:00:00 2001 From: Ilya Katz Date: Tue, 6 Jun 2023 12:31:14 -0700 Subject: [PATCH 16/98] Bumping version --- Changelog.md | 4 ++++ lib/data_migrate/version.rb | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Changelog.md b/Changelog.md index 2f8b279f..66be83b7 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,9 @@ # Changelog +# 10.0.0 + +Releasing 10.0.0 + ## 10.0.0.rc1 - Changes by [chaunce](https//:github.com/chaunce) diff --git a/lib/data_migrate/version.rb b/lib/data_migrate/version.rb index 2f854e0c..6df1d5c9 100644 --- a/lib/data_migrate/version.rb +++ b/lib/data_migrate/version.rb @@ -1,3 +1,3 @@ module DataMigrate - VERSION = "10.0.0.rc1".freeze + VERSION = "10.0.0".freeze end From 4d23e385af0af3bea0e564b262b57c0083f64f23 Mon Sep 17 00:00:00 2001 From: chaunce Date: Mon, 12 Jun 2023 22:01:39 -0600 Subject: [PATCH 17/98] add conditional code for Rails v6 and v7 --- tasks/databases.rake | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tasks/databases.rake b/tasks/databases.rake index c9623202..a0c8fc84 100644 --- a/tasks/databases.rake +++ b/tasks/databases.rake @@ -6,7 +6,12 @@ namespace :db do namespace :migrate do desc "Migrate the database data and schema (options: VERSION=x, VERBOSE=false)." task :with_data => :environment do - original_db_config = ActiveRecord::Base.connection_db_config + original_db_config = if Gem::Dependency.new("rails", "~> 7.0").match?("rails", Gem.loaded_specs["rails"].version) + ActiveRecord::Base.connection_db_config + elsif Gem::Dependency.new("rails", "~> 6.0").match?("rails", Gem.loaded_specs["rails"].version) + ActiveRecord::Base.connection_config + end + ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env).each do |db_config| ActiveRecord::Base.establish_connection(db_config) DataMigrate::DataMigrator.assure_data_schema_table @@ -204,7 +209,12 @@ end namespace :data do desc 'Migrate data migrations (options: VERSION=x, VERBOSE=false)' task :migrate => :environment do - original_db_config = ActiveRecord::Base.connection_db_config + original_db_config = if Gem::Dependency.new("rails", "~> 7.0").match?("rails", Gem.loaded_specs["rails"].version) + ActiveRecord::Base.connection_db_config + elsif Gem::Dependency.new("rails", "~> 6.0").match?("rails", Gem.loaded_specs["rails"].version) + ActiveRecord::Base.connection_config + end + ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env).each do |db_config| ActiveRecord::Base.establish_connection(db_config) DataMigrate::Tasks::DataMigrateTasks.migrate From eabc24a5532e547bd759291ef18182f41d82bb37 Mon Sep 17 00:00:00 2001 From: Ilya Katz Date: Tue, 13 Jun 2023 11:56:02 -0700 Subject: [PATCH 18/98] Bump version --- Changelog.md | 4 ++++ lib/data_migrate/version.rb | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Changelog.md b/Changelog.md index 66be83b7..58a638ca 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,9 @@ # Changelog +# 10.0.1 + +- Bug fix for Rails 6 config [chaunce](https//:github.com/chaunce) + # 10.0.0 Releasing 10.0.0 diff --git a/lib/data_migrate/version.rb b/lib/data_migrate/version.rb index 6df1d5c9..6c665011 100644 --- a/lib/data_migrate/version.rb +++ b/lib/data_migrate/version.rb @@ -1,3 +1,3 @@ module DataMigrate - VERSION = "10.0.0".freeze + VERSION = "10.0.1".freeze end From 7b96296955f063e422bad56edd7546ba721e3322 Mon Sep 17 00:00:00 2001 From: Igor Pstyga Date: Mon, 12 Jun 2023 08:36:01 -0700 Subject: [PATCH 19/98] Use railties version check instead of rails Fixes #259 --- lib/data_migrate/schema_migration.rb | 4 ++-- lib/data_migrate/status_service.rb | 4 ++-- lib/data_migrate/tasks/data_migrate_tasks.rb | 4 ++-- spec/data_migrate/database_tasks_spec.rb | 2 +- spec/data_migrate/schema_migration_spec.rb | 4 ++-- spec/data_migrate/status_service_spec.rb | 2 +- spec/data_migrate/tasks/data_migrate_tasks_spec.rb | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/data_migrate/schema_migration.rb b/lib/data_migrate/schema_migration.rb index 3369c4d9..aa7469f5 100644 --- a/lib/data_migrate/schema_migration.rb +++ b/lib/data_migrate/schema_migration.rb @@ -24,9 +24,9 @@ def self.sort_migrations(set1, set2 = nil) def self.migrations_paths spec_name = DataMigrate.config.spec_name - if spec_name && Gem::Dependency.new("rails", "~> 7.0").match?("rails", Gem.loaded_specs["rails"].version) + if spec_name && Gem::Dependency.new("railties", "~> 7.0").match?("railties", Gem.loaded_specs["railties"].version) ActiveRecord::Base.configurations.configs_for(env_name: Rails.env, name: spec_name).migrations_paths - elsif spec_name && Gem::Dependency.new("rails", "~> 6.0").match?("rails", Gem.loaded_specs["rails"].version) + elsif spec_name && Gem::Dependency.new("railties", "~> 6.0").match?("railties", Gem.loaded_specs["railties"].version) ActiveRecord::Base.configurations.configs_for(env_name: Rails.env, spec_name: spec_name).migrations_paths else Rails.application.config.paths["db/migrate"].to_a diff --git a/lib/data_migrate/status_service.rb b/lib/data_migrate/status_service.rb index 663cc050..e912faca 100644 --- a/lib/data_migrate/status_service.rb +++ b/lib/data_migrate/status_service.rb @@ -44,9 +44,9 @@ def output(stream) end def database_name - if Gem::Dependency.new("rails", "~> 7.0").match?("rails", Gem.loaded_specs["rails"].version) + if Gem::Dependency.new("railties", "~> 7.0").match?("railties", Gem.loaded_specs["railties"].version) ActiveRecord::Base.connection_db_config.configuration_hash[:database] - elsif Gem::Dependency.new("rails", "~> 6.0").match?("rails", Gem.loaded_specs["rails"].version) + elsif Gem::Dependency.new("railties", "~> 6.0").match?("railties", Gem.loaded_specs["railties"].version) ActiveRecord::Base.connection_config[:database] end end diff --git a/lib/data_migrate/tasks/data_migrate_tasks.rb b/lib/data_migrate/tasks/data_migrate_tasks.rb index c72e1aa3..7d5acf2f 100644 --- a/lib/data_migrate/tasks/data_migrate_tasks.rb +++ b/lib/data_migrate/tasks/data_migrate_tasks.rb @@ -95,9 +95,9 @@ def status_with_schema(db_config) private def spec_name(db_config) - if Gem::Dependency.new("rails", "~> 7.0").match?("rails", Gem.loaded_specs["rails"].version) + if Gem::Dependency.new("railties", "~> 7.0").match?("railties", Gem.loaded_specs["railties"].version) db_config.name - elsif Gem::Dependency.new("rails", "~> 6.0").match?("rails", Gem.loaded_specs["rails"].version) + elsif Gem::Dependency.new("railties", "~> 6.0").match?("railties", Gem.loaded_specs["railties"].version) db_config.spec_name end end diff --git a/spec/data_migrate/database_tasks_spec.rb b/spec/data_migrate/database_tasks_spec.rb index 563fb8cb..77afc946 100644 --- a/spec/data_migrate/database_tasks_spec.rb +++ b/spec/data_migrate/database_tasks_spec.rb @@ -28,7 +28,7 @@ data_migrations_path } ActiveRecord::Base.establish_connection(db_config) - if Gem::Dependency.new("rails", ">= 6.1").match?("rails", Gem.loaded_specs["rails"].version) + if Gem::Dependency.new("railties", ">= 6.1").match?("railties", Gem.loaded_specs["railties"].version) hash_config = ActiveRecord::DatabaseConfigurations::HashConfig.new('test', 'test', db_config) config_obj = ActiveRecord::DatabaseConfigurations.new([hash_config]) allow(ActiveRecord::Base).to receive(:configurations).and_return(config_obj) diff --git a/spec/data_migrate/schema_migration_spec.rb b/spec/data_migrate/schema_migration_spec.rb index 82b538c7..00f6ad26 100644 --- a/spec/data_migrate/schema_migration_spec.rb +++ b/spec/data_migrate/schema_migration_spec.rb @@ -61,9 +61,9 @@ let(:paths) { ['spec/db/migrate', 'spec/db/migrate/other'] } let(:specification_name) { "primary" } let(:config_options) do - if Gem::Dependency.new("rails", "~> 6.0").match?("rails", Gem.loaded_specs["rails"].version) + if Gem::Dependency.new("railties", "~> 6.0").match?("railties", Gem.loaded_specs["railties"].version) { env_name: Rails.env, spec_name: specification_name } - elsif Gem::Dependency.new("rails", "~> 7.0").match?("rails", Gem.loaded_specs["rails"].version) + elsif Gem::Dependency.new("railties", "~> 7.0").match?("railties", Gem.loaded_specs["railties"].version) { env_name: Rails.env, name: specification_name } end end diff --git a/spec/data_migrate/status_service_spec.rb b/spec/data_migrate/status_service_spec.rb index 79a4f6af..ad610a89 100644 --- a/spec/data_migrate/status_service_spec.rb +++ b/spec/data_migrate/status_service_spec.rb @@ -7,7 +7,7 @@ let(:stream) { StringIO.new } let(:stream_data) { stream.read } let(:connection_db_config) do - if Gem::Dependency.new("rails", ">= 6.1").match?("rails", Gem.loaded_specs["rails"].version) + if Gem::Dependency.new("railties", ">= 6.1").match?("railties", Gem.loaded_specs["railties"].version) ActiveRecord::Base.connection_db_config else ActiveRecord::Base.configurations.configs_for.first diff --git a/spec/data_migrate/tasks/data_migrate_tasks_spec.rb b/spec/data_migrate/tasks/data_migrate_tasks_spec.rb index ffcd8897..4aa3d7af 100644 --- a/spec/data_migrate/tasks/data_migrate_tasks_spec.rb +++ b/spec/data_migrate/tasks/data_migrate_tasks_spec.rb @@ -4,7 +4,7 @@ describe DataMigrate::Tasks::DataMigrateTasks do let(:connection_db_config) do - if Gem::Dependency.new("rails", ">= 6.1").match?("rails", Gem.loaded_specs["rails"].version) + if Gem::Dependency.new("railties", ">= 6.1").match?("railties", Gem.loaded_specs["railties"].version) ActiveRecord::Base.connection_db_config else ActiveRecord::Base.configurations.configs_for.first From 6ac81fa8e05571c89e9896b69868817115480fa3 Mon Sep 17 00:00:00 2001 From: Ilya Katz Date: Tue, 13 Jun 2023 11:59:31 -0700 Subject: [PATCH 20/98] Railties bug fix documentation --- Changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/Changelog.md b/Changelog.md index 58a638ca..442877aa 100644 --- a/Changelog.md +++ b/Changelog.md @@ -3,6 +3,7 @@ # 10.0.1 - Bug fix for Rails 6 config [chaunce](https//:github.com/chaunce) +- Railties bug fix by [opti](https://github.com/opti) # 10.0.0 From 7de11e2888fc44ae833fa78732a7cea66f18e914 Mon Sep 17 00:00:00 2001 From: Ilya Katz Date: Tue, 13 Jun 2023 22:37:19 -0700 Subject: [PATCH 21/98] Change 'rails' dependencies to 'railties' --- Changelog.md | 5 +++++ lib/data_migrate/version.rb | 2 +- tasks/databases.rake | 8 ++++---- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Changelog.md b/Changelog.md index 442877aa..507e6906 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,10 @@ # Changelog +# 10.0.2 + +Change "rails" dependencies to "railties" + + # 10.0.1 - Bug fix for Rails 6 config [chaunce](https//:github.com/chaunce) diff --git a/lib/data_migrate/version.rb b/lib/data_migrate/version.rb index 6c665011..c2bb25a9 100644 --- a/lib/data_migrate/version.rb +++ b/lib/data_migrate/version.rb @@ -1,3 +1,3 @@ module DataMigrate - VERSION = "10.0.1".freeze + VERSION = "10.0.2".freeze end diff --git a/tasks/databases.rake b/tasks/databases.rake index a0c8fc84..caf32fa0 100644 --- a/tasks/databases.rake +++ b/tasks/databases.rake @@ -6,9 +6,9 @@ namespace :db do namespace :migrate do desc "Migrate the database data and schema (options: VERSION=x, VERBOSE=false)." task :with_data => :environment do - original_db_config = if Gem::Dependency.new("rails", "~> 7.0").match?("rails", Gem.loaded_specs["rails"].version) + original_db_config = if Gem::Dependency.new("railties", "~> 7.0").match?("railties", Gem.loaded_specs["railties"].version) ActiveRecord::Base.connection_db_config - elsif Gem::Dependency.new("rails", "~> 6.0").match?("rails", Gem.loaded_specs["rails"].version) + elsif Gem::Dependency.new("railties", "~> 6.0").match?("railties", Gem.loaded_specs["railties"].version) ActiveRecord::Base.connection_config end @@ -209,9 +209,9 @@ end namespace :data do desc 'Migrate data migrations (options: VERSION=x, VERBOSE=false)' task :migrate => :environment do - original_db_config = if Gem::Dependency.new("rails", "~> 7.0").match?("rails", Gem.loaded_specs["rails"].version) + original_db_config = if Gem::Dependency.new("railties", "~> 7.0").match?("railties", Gem.loaded_specs["railties"].version) ActiveRecord::Base.connection_db_config - elsif Gem::Dependency.new("rails", "~> 6.0").match?("rails", Gem.loaded_specs["rails"].version) + elsif Gem::Dependency.new("railties", "~> 6.0").match?("railties", Gem.loaded_specs["railties"].version) ActiveRecord::Base.connection_config end From 269ce1cb0b897d25918febbdffacb2254ff38e88 Mon Sep 17 00:00:00 2001 From: Leo Arnold Date: Wed, 24 May 2023 01:54:23 +0200 Subject: [PATCH 22/98] Remove traces of defunct Travis CI --- .gitignore | 4 +++- .ruby-version | 1 - .travis.yml | 14 -------------- README.md | 4 ++-- 4 files changed, 5 insertions(+), 18 deletions(-) delete mode 100644 .ruby-version delete mode 100644 .travis.yml diff --git a/.gitignore b/.gitignore index 871a7ade..93cd6e23 100644 --- a/.gitignore +++ b/.gitignore @@ -7,5 +7,7 @@ spec/db/other_test.db spec/db/data_schema.rb .vscode/ .DS_Store +.ruby-gemset +.ruby-version .idea/ -vendor/ \ No newline at end of file +vendor/ diff --git a/.ruby-version b/.ruby-version deleted file mode 100644 index a603bb50..00000000 --- a/.ruby-version +++ /dev/null @@ -1 +0,0 @@ -2.7.5 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 11da9415..00000000 --- a/.travis.yml +++ /dev/null @@ -1,14 +0,0 @@ -language: ruby -rvm: - - 2.7 - - 3.0 - - 3.2 -script: bundle exec rspec -gemfile: - - gemfiles/rails_6.0.gemfile - - gemfiles/rails_6.1.gemfile - - gemfiles/rails_7.0.gemfile -jobs: - exclude: - - rvm: 3.0 - - rvm: 3.2 diff --git a/README.md b/README.md index b4a03d18..48346a1f 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ - [![Version](http://img.shields.io/gem/v/data_migrate.svg?style=flat-square)](https://rubygems.org/gems/data_migrate) - [![License](http://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](http://opensource.org/licenses/MIT) -- [![Travis](https://img.shields.io/travis/ilyakatz/data-migrate.svg)](https://travis-ci.org/ilyakatz/data-migrate) +- ![.github/workflows/build.yml](https://github.com/ilyakatz/data-migrate/actions/workflows/.github/workflows/build.yml/badge.svg) - [![Reviewed by Hound](https://img.shields.io/badge/Reviewed_by-Hound-8E64B0.svg)](https://houndci.com) Run data migrations alongside schema migrations. @@ -12,7 +12,7 @@ migrations, except they should be reserved for data migrations. For instance, if you realize you need to titleize all your titles, this is the place to do it. -![Travis](./screenshot.png) +![directory tree example](./screenshot.png) ## Why should I use this? From e9c9edf76b49111fde1ad2c1b37f1289b7ddc7e9 Mon Sep 17 00:00:00 2001 From: Ilya Katz Date: Tue, 13 Jun 2023 22:55:03 -0700 Subject: [PATCH 23/98] Update docs for upcoming version --- Changelog.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Changelog.md b/Changelog.md index 442877aa..e7a54a30 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,8 @@ # Changelog +# 10.0.3 (upcoming) + +- Remove all travis references [leoarnold](https//:github.com/leoarnold) # 10.0.1 - Bug fix for Rails 6 config [chaunce](https//:github.com/chaunce) From 2ecc0ef32d8e4be00fcc5ffb6e7490861dbf0ebe Mon Sep 17 00:00:00 2001 From: Ilya Katz Date: Wed, 14 Jun 2023 22:22:29 -0700 Subject: [PATCH 24/98] Document breaking changes --- Changelog.md | 8 +++++++- lib/data_migrate/version.rb | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Changelog.md b/Changelog.md index beb6c16a..6d7909fa 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,8 +1,9 @@ # Changelog -## 10.0.3 (upcoming) +## 10.0.3.rc - Remove all travis references [leoarnold](https//:github.com/leoarnold) +- Changing to rc because of ongoing discussion how to properly handle multiple database environments ## 10.0.2 @@ -17,6 +18,11 @@ Change "rails" dependencies to "railties" Releasing 10.0.0 +!!! Breaking changes !!! + +- This version introduces a breaking change which may lead to undesired +behavior in multi-database environments. See https://github.com/ilyakatz/data-migrate/issues/181 + ## 10.0.0.rc1 - Changes by [chaunce](https//:github.com/chaunce) diff --git a/lib/data_migrate/version.rb b/lib/data_migrate/version.rb index c2bb25a9..6c8a2f02 100644 --- a/lib/data_migrate/version.rb +++ b/lib/data_migrate/version.rb @@ -1,3 +1,3 @@ module DataMigrate - VERSION = "10.0.2".freeze + VERSION = "10.0.3.rc".freeze end From 3932c509611ee70054d8e2a0583baf9643d64178 Mon Sep 17 00:00:00 2001 From: Maple Ong Date: Thu, 22 Jun 2023 12:06:49 -0400 Subject: [PATCH 25/98] Remove looping over multi-database --- lib/data_migrate/database_tasks.rb | 4 ++ lib/data_migrate/tasks/data_migrate_tasks.rb | 4 +- tasks/databases.rake | 44 ++++---------------- 3 files changed, 13 insertions(+), 39 deletions(-) diff --git a/lib/data_migrate/database_tasks.rb b/lib/data_migrate/database_tasks.rb index e4e82184..a237ceee 100644 --- a/lib/data_migrate/database_tasks.rb +++ b/lib/data_migrate/database_tasks.rb @@ -9,6 +9,10 @@ class DatabaseTasks extend ActiveRecord::Tasks::DatabaseTasks class << self + def schema_file(_format = nil) + File.join(db_dir, "data_schema.rb") + end + def schema_file_type(_format = nil) "data_schema.rb" end diff --git a/lib/data_migrate/tasks/data_migrate_tasks.rb b/lib/data_migrate/tasks/data_migrate_tasks.rb index 7d5acf2f..9bdaddfb 100644 --- a/lib/data_migrate/tasks/data_migrate_tasks.rb +++ b/lib/data_migrate/tasks/data_migrate_tasks.rb @@ -9,9 +9,9 @@ def migrations_paths @migrations_paths ||= DataMigrate.config.data_migrations_path end - def dump(db_config) + def dump if dump_schema_after_migration? - filename = DataMigrate::DatabaseTasks.dump_filename(spec_name(db_config), ActiveRecord::Base.schema_format) + filename = DataMigrate::DatabaseTasks.schema_file ActiveRecord::Base.establish_connection(DataMigrate.config.db_configuration) if DataMigrate.config.db_configuration File.open(filename, "w:utf-8") do |file| DataMigrate::SchemaDumper.dump(ActiveRecord::Base.connection, file) diff --git a/tasks/databases.rake b/tasks/databases.rake index caf32fa0..54aca294 100644 --- a/tasks/databases.rake +++ b/tasks/databases.rake @@ -6,15 +6,7 @@ namespace :db do namespace :migrate do desc "Migrate the database data and schema (options: VERSION=x, VERBOSE=false)." task :with_data => :environment do - original_db_config = if Gem::Dependency.new("railties", "~> 7.0").match?("railties", Gem.loaded_specs["railties"].version) - ActiveRecord::Base.connection_db_config - elsif Gem::Dependency.new("railties", "~> 6.0").match?("railties", Gem.loaded_specs["railties"].version) - ActiveRecord::Base.connection_config - end - - ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env).each do |db_config| - ActiveRecord::Base.establish_connection(db_config) - DataMigrate::DataMigrator.assure_data_schema_table + DataMigrate::DataMigrator.assure_data_schema_table ActiveRecord::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true target_version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil @@ -58,18 +50,16 @@ namespace :db do migrations.each do |migration| DataMigrate::DatabaseTasks.run_migration(migration, migration[:direction]) end - end Rake::Task["db:_dump"].invoke Rake::Task["data:dump"].invoke - ensure - ActiveRecord::Base.establish_connection(original_db_config) end namespace :redo do desc 'Rollbacks the database one migration and re migrate up (options: STEP=x, VERSION=x).' task :with_data => :environment do - DataMigrate::DataMigrator.assure_data_schema_table + DataMigrate::DataMigrator.create_data_schema_table + if ENV["VERSION"] Rake::Task["db:migrate:down:with_data"].invoke Rake::Task["db:migrate:up:with_data"].invoke @@ -127,10 +117,7 @@ namespace :db do namespace :status do desc "Display status of data and schema migrations" task :with_data => :environment do - ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env).each do |db_config| - ActiveRecord::Base.establish_connection(db_config) - DataMigrate::Tasks::DataMigrateTasks.status_with_schema(db_config) - end + DataMigrate::Tasks::DataMigrateTasks.status_with_schema end end end # END OF MIGRATE NAME SPACE @@ -209,19 +196,8 @@ end namespace :data do desc 'Migrate data migrations (options: VERSION=x, VERBOSE=false)' task :migrate => :environment do - original_db_config = if Gem::Dependency.new("railties", "~> 7.0").match?("railties", Gem.loaded_specs["railties"].version) - ActiveRecord::Base.connection_db_config - elsif Gem::Dependency.new("railties", "~> 6.0").match?("railties", Gem.loaded_specs["railties"].version) - ActiveRecord::Base.connection_config - end - - ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env).each do |db_config| - ActiveRecord::Base.establish_connection(db_config) - DataMigrate::Tasks::DataMigrateTasks.migrate - end + DataMigrate::Tasks::DataMigrateTasks.migrate Rake::Task["data:dump"].invoke - ensure - ActiveRecord::Base.establish_connection(original_db_config) end namespace :migrate do @@ -257,10 +233,7 @@ namespace :data do desc "Display status of data migrations" task :status => :environment do - ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env).each do |db_config| - ActiveRecord::Base.establish_connection(db_config) - DataMigrate::Tasks::DataMigrateTasks.status(db_config) - end + DataMigrate::Tasks::DataMigrateTasks.status end end @@ -299,10 +272,7 @@ namespace :data do desc "Create a db/data_schema.rb file that stores the current data version" task dump: :environment do - ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env).each do |db_config| - ActiveRecord::Base.establish_connection(db_config) - DataMigrate::Tasks::DataMigrateTasks.dump(db_config) - end + DataMigrate::Tasks::DataMigrateTasks.dump # Allow this task to be called as many times as required. An example # is the migrate:redo task, which calls other two internally From f6bc225417062c3740f0d560bfffc64143bc45f8 Mon Sep 17 00:00:00 2001 From: Maple Ong Date: Thu, 22 Jun 2023 12:07:50 -0400 Subject: [PATCH 26/98] Rename method --- lib/data_migrate/data_migrator.rb | 2 +- lib/data_migrate/data_schema.rb | 2 +- lib/data_migrate/database_tasks.rb | 2 +- lib/data_migrate/tasks/data_migrate_tasks.rb | 2 +- spec/data_migrate/data_migrator_spec.rb | 4 ++-- tasks/databases.rake | 25 ++++++++++---------- 6 files changed, 18 insertions(+), 19 deletions(-) diff --git a/lib/data_migrate/data_migrator.rb b/lib/data_migrate/data_migrator.rb index 36840112..78cfe86e 100644 --- a/lib/data_migrate/data_migrator.rb +++ b/lib/data_migrate/data_migrator.rb @@ -9,7 +9,7 @@ def self.migrations_paths [DataMigrate.config.data_migrations_path] end - def self.assure_data_schema_table + def self.create_data_schema_table DataMigrate::DataSchemaMigration.create_table end diff --git a/lib/data_migrate/data_schema.rb b/lib/data_migrate/data_schema.rb index 605fbfbc..07e9fb78 100644 --- a/lib/data_migrate/data_schema.rb +++ b/lib/data_migrate/data_schema.rb @@ -9,7 +9,7 @@ class Data < ActiveRecord::Schema # ActiveRecord::ConnectionAdapters::SchemaStatements # #assume_migrated_upto_version def define(info) - DataMigrate::DataMigrator.assure_data_schema_table + DataMigrate::DataMigrator.create_data_schema_table return if info[:version].blank? diff --git a/lib/data_migrate/database_tasks.rb b/lib/data_migrate/database_tasks.rb index a237ceee..72db845f 100644 --- a/lib/data_migrate/database_tasks.rb +++ b/lib/data_migrate/database_tasks.rb @@ -69,7 +69,7 @@ def run_migration(migration, direction) end def self.forward(step = 1) - DataMigrate::DataMigrator.assure_data_schema_table + DataMigrate::DataMigrator.create_data_schema_table migrations = pending_migrations.reverse.pop(step).reverse migrations.each do | pending_migration | if pending_migration[:kind] == :data diff --git a/lib/data_migrate/tasks/data_migrate_tasks.rb b/lib/data_migrate/tasks/data_migrate_tasks.rb index 9bdaddfb..b6e88ad7 100644 --- a/lib/data_migrate/tasks/data_migrate_tasks.rb +++ b/lib/data_migrate/tasks/data_migrate_tasks.rb @@ -22,7 +22,7 @@ def dump def migrate target_version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil - DataMigrate::DataMigrator.assure_data_schema_table + DataMigrate::DataMigrator.create_data_schema_table DataMigrate::MigrationContext.new(migrations_paths).migrate(target_version) end diff --git a/spec/data_migrate/data_migrator_spec.rb b/spec/data_migrate/data_migrator_spec.rb index ec6ccbe1..82d8a073 100644 --- a/spec/data_migrate/data_migrator_spec.rb +++ b/spec/data_migrate/data_migrator_spec.rb @@ -35,10 +35,10 @@ end end - describe :assure_data_schema_table do + describe :create_data_schema_table do it "creates the data_migrations table" do ActiveRecord::Migration.drop_table("data_migrations") rescue nil - subject.assure_data_schema_table + subject.create_data_schema_table expect( ActiveRecord::Base.connection.table_exists?("data_migrations") ).to eq true diff --git a/tasks/databases.rake b/tasks/databases.rake index 54aca294..e02e7f7b 100644 --- a/tasks/databases.rake +++ b/tasks/databases.rake @@ -6,7 +6,7 @@ namespace :db do namespace :migrate do desc "Migrate the database data and schema (options: VERSION=x, VERBOSE=false)." task :with_data => :environment do - DataMigrate::DataMigrator.assure_data_schema_table + DataMigrate::DataMigrator.create_data_schema_table ActiveRecord::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true target_version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil @@ -59,7 +59,6 @@ namespace :db do desc 'Rollbacks the database one migration and re migrate up (options: STEP=x, VERSION=x).' task :with_data => :environment do DataMigrate::DataMigrator.create_data_schema_table - if ENV["VERSION"] Rake::Task["db:migrate:down:with_data"].invoke Rake::Task["db:migrate:up:with_data"].invoke @@ -75,7 +74,7 @@ namespace :db do task :with_data => :environment do version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil raise "VERSION is required" unless version - DataMigrate::DataMigrator.assure_data_schema_table + DataMigrate::DataMigrator.create_data_schema_table run_both = ENV["BOTH"] == "true" migrations = DataMigrate::DatabaseTasks.pending_migrations.keep_if{|m| m[:version] == version} @@ -97,7 +96,7 @@ namespace :db do task :with_data => :environment do version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil raise "VERSION is required" unless version - DataMigrate::DataMigrator.assure_data_schema_table + DataMigrate::DataMigrator.create_data_schema_table run_both = ENV["BOTH"] == "true" migrations = DataMigrate::DatabaseTasks.past_migrations.keep_if{|m| m[:version] == version} @@ -126,7 +125,7 @@ namespace :db do desc 'Rolls the schema back to the previous version (specify steps w/ STEP=n).' task :with_data => :environment do step = ENV['STEP'] ? ENV['STEP'].to_i : 1 - DataMigrate::DataMigrator.assure_data_schema_table + DataMigrate::DataMigrator.create_data_schema_table DataMigrate::DatabaseTasks.past_migrations[0..(step - 1)].each do | past_migration | DataMigrate::DatabaseTasks.run_migration(past_migration, :down) end @@ -139,7 +138,7 @@ namespace :db do namespace :forward do desc 'Pushes the schema to the next version (specify steps w/ STEP=n).' task :with_data => :environment do - DataMigrate::DataMigrator.assure_data_schema_table + DataMigrate::DataMigrator.create_data_schema_table step = ENV['STEP'] ? ENV['STEP'].to_i : 1 DataMigrate::DatabaseTasks.forward(step) Rake::Task["db:_dump"].invoke @@ -150,7 +149,7 @@ namespace :db do namespace :version do desc "Retrieves the current schema version numbers for data and schema migrations" task :with_data => :environment do - DataMigrate::DataMigrator.assure_data_schema_table + DataMigrate::DataMigrator.create_data_schema_table puts "Current Schema version: #{ActiveRecord::Migrator.current_version}" puts "Current Data version: #{DataMigrate::DataMigrator.current_version}" end @@ -203,7 +202,7 @@ namespace :data do namespace :migrate do desc 'Rollbacks the database one migration and re migrate up (options: STEP=x, VERSION=x).' task :redo => :environment do - DataMigrate::DataMigrator.assure_data_schema_table + DataMigrate::DataMigrator.create_data_schema_table if ENV["VERSION"] Rake::Task["data:migrate:down"].invoke Rake::Task["data:migrate:up"].invoke @@ -215,7 +214,7 @@ namespace :data do desc 'Runs the "up" for a given migration VERSION.' task :up => :environment do - DataMigrate::DataMigrator.assure_data_schema_table + DataMigrate::DataMigrator.create_data_schema_table version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil raise "VERSION is required" unless version DataMigrate::DataMigrator.run(:up, DataMigrate::DatabaseTasks.data_migrations_path, version) @@ -226,7 +225,7 @@ namespace :data do task :down => :environment do version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil raise "VERSION is required" unless version - DataMigrate::DataMigrator.assure_data_schema_table + DataMigrate::DataMigrator.create_data_schema_table DataMigrate::DataMigrator.run(:down, DataMigrate::DatabaseTasks.data_migrations_path, version) Rake::Task["data:dump"].invoke end @@ -239,7 +238,7 @@ namespace :data do desc 'Rolls the schema back to the previous version (specify steps w/ STEP=n).' task :rollback => :environment do - DataMigrate::DataMigrator.assure_data_schema_table + DataMigrate::DataMigrator.create_data_schema_table step = ENV['STEP'] ? ENV['STEP'].to_i : 1 DataMigrate::DataMigrator.rollback(DataMigrate::DatabaseTasks.data_migrations_path, step) Rake::Task["data:dump"].invoke @@ -247,7 +246,7 @@ namespace :data do desc 'Pushes the schema to the next version (specify steps w/ STEP=n).' task :forward => :environment do - DataMigrate::DataMigrator.assure_data_schema_table + DataMigrate::DataMigrator.create_data_schema_table step = ENV['STEP'] ? ENV['STEP'].to_i : 1 # TODO: No worky for .forward # DataMigrate::DataMigrator.forward('db/data/', step) @@ -260,7 +259,7 @@ namespace :data do desc "Retrieves the current schema version number for data migrations" task :version => :environment do - DataMigrate::DataMigrator.assure_data_schema_table + DataMigrate::DataMigrator.create_data_schema_table puts "Current data version: #{DataMigrate::DataMigrator.current_version}" end From c498729ec705f588998546a5f71e014cee17723f Mon Sep 17 00:00:00 2001 From: Maple Ong Date: Tue, 27 Jun 2023 15:06:08 -0400 Subject: [PATCH 27/98] Publish to rubygems on releases Update ruby to 3.2 --- .github/workflows/gempush.yml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/.github/workflows/gempush.yml b/.github/workflows/gempush.yml index f2f0bfff..84c9d09b 100644 --- a/.github/workflows/gempush.yml +++ b/.github/workflows/gempush.yml @@ -1,10 +1,8 @@ -name: Ruby Gem +name: Release Gem on: - push: - branches: - - main - - chaunce-multiple_connection_support + release: + types: [released] jobs: build: @@ -13,10 +11,10 @@ jobs: steps: - uses: actions/checkout@master - - name: Set up Ruby 2.6 + - name: Set up Ruby 3.2 uses: actions/setup-ruby@v1 with: - version: 2.6.x + ruby-version: '3.2' - name: Publish to RubyGems run: | From 92d2e8b6296c122d3fc42704773fe2068cc72746 Mon Sep 17 00:00:00 2001 From: Maple Ong Date: Tue, 27 Jun 2023 15:36:01 -0400 Subject: [PATCH 28/98] Fix specs --- spec/data_migrate/tasks/data_migrate_tasks_spec.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/spec/data_migrate/tasks/data_migrate_tasks_spec.rb b/spec/data_migrate/tasks/data_migrate_tasks_spec.rb index 4aa3d7af..600cc3b6 100644 --- a/spec/data_migrate/tasks/data_migrate_tasks_spec.rb +++ b/spec/data_migrate/tasks/data_migrate_tasks_spec.rb @@ -28,11 +28,11 @@ end context 'when not given a separate db config' do - it 'does not override the default connection' do + it 'does not override the default connection' do expect(ActiveRecord::Base).not_to receive(:establish_connection) expect(DataMigrate::SchemaDumper).to receive(:dump) - DataMigrate::Tasks::DataMigrateTasks.dump(connection_db_config) + DataMigrate::Tasks::DataMigrateTasks.dump end end @@ -56,8 +56,7 @@ it 'overrides the default connection' do expect(ActiveRecord::Base).to receive(:establish_connection).with(override_config) - - DataMigrate::Tasks::DataMigrateTasks.dump(connection_db_config) + DataMigrate::Tasks::DataMigrateTasks.dump end end end From d32953dfce2d00298079232c8ff16d78e75897ff Mon Sep 17 00:00:00 2001 From: Maple Ong Date: Tue, 27 Jun 2023 15:38:21 -0400 Subject: [PATCH 29/98] Remove ruby 2.7 from version matrix --- .github/workflows/build.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fecdd468..18d5494b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,7 +11,6 @@ jobs: matrix: os: [ "ubuntu-20.04" ] ruby: - - '2.7' - '3.0' - '3.1' - '3.2' @@ -32,4 +31,4 @@ jobs: ruby-version: ${{ matrix.ruby }} bundler-cache: true - name: Run tests - run: bundle exec rspec \ No newline at end of file + run: bundle exec rspec From ec8fbf2864debe9f19ee32e914faa12411c8bd76 Mon Sep 17 00:00:00 2001 From: Maple Ong Date: Tue, 27 Jun 2023 15:45:59 -0400 Subject: [PATCH 30/98] Update changelog to reflect yanked versions --- Changelog.md | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Changelog.md b/Changelog.md index 6d7909fa..cb0ef863 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,20 +1,20 @@ # Changelog -## 10.0.3.rc +## [YANKED] 10.0.3.rc - Remove all travis references [leoarnold](https//:github.com/leoarnold) - Changing to rc because of ongoing discussion how to properly handle multiple database environments -## 10.0.2 +## [YANKED] 10.0.2 Change "rails" dependencies to "railties" -## 10.0.1 +## [YANKED] 10.0.1 - Bug fix for Rails 6 config [chaunce](https//:github.com/chaunce) - Railties bug fix by [opti](https://github.com/opti) -## 10.0.0 +## [YANKED] 10.0.0 Releasing 10.0.0 @@ -23,14 +23,13 @@ Releasing 10.0.0 - This version introduces a breaking change which may lead to undesired behavior in multi-database environments. See https://github.com/ilyakatz/data-migrate/issues/181 -## 10.0.0.rc1 +## [YANKED] 10.0.0.rc1 - Changes by [chaunce](https//:github.com/chaunce) - Multiple databases support - Refactor to clean things up - Deprecate rails 5.2 support for real - ## 9.0.0 Ruby 3.2 support [mehanoid](https://github.com/mehanoid) From ddf0c632cf4ddf762c03e16bc1b19fe634c61e3d Mon Sep 17 00:00:00 2001 From: Maple Ong Date: Wed, 28 Jun 2023 13:23:41 -0400 Subject: [PATCH 31/98] Fix status and status:with_data rake tasks --- lib/data_migrate/tasks/data_migrate_tasks.rb | 15 +++++++-------- .../data_migrate/tasks/data_migrate_tasks_spec.rb | 4 ++-- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/data_migrate/tasks/data_migrate_tasks.rb b/lib/data_migrate/tasks/data_migrate_tasks.rb index b6e88ad7..52f9b84c 100644 --- a/lib/data_migrate/tasks/data_migrate_tasks.rb +++ b/lib/data_migrate/tasks/data_migrate_tasks.rb @@ -44,12 +44,11 @@ def dump_schema_after_migration? end end - def status(db_config) - puts "\ndatabase: #{spec_name(db_config)}\n\n" - DataMigrate::StatusService.dump(ActiveRecord::Base.connection) + def status + DataMigrate::StatusService.dump end - def status_with_schema(db_config) + def status_with_schema db_list_data = ActiveRecord::Base.connection.select_values( "SELECT version FROM #{DataMigrate::DataSchemaMigration.table_name}" ) @@ -77,7 +76,7 @@ def status_with_schema(db_config) file_list.sort!{|a,b| "#{a[1]}_#{a[3] == 'data' ? 1 : 0}" <=> "#{b[1]}_#{b[3] == 'data' ? 1 : 0}" } # output - puts "\ndatabase: #{spec_name(db_config)}\n\n" + puts "\ndatabase: #{database_name}\n\n" puts "#{"Status".center(8)} #{"Type".center(8)} #{"Migration ID".ljust(14)} Migration Name" puts "-" * 60 file_list.each do |file| @@ -94,11 +93,11 @@ def status_with_schema(db_config) private - def spec_name(db_config) + def database_name if Gem::Dependency.new("railties", "~> 7.0").match?("railties", Gem.loaded_specs["railties"].version) - db_config.name + ActiveRecord::Base.connection_db_config.database elsif Gem::Dependency.new("railties", "~> 6.0").match?("railties", Gem.loaded_specs["railties"].version) - db_config.spec_name + ActiveRecord::Base.connection_config[:database] end end end diff --git a/spec/data_migrate/tasks/data_migrate_tasks_spec.rb b/spec/data_migrate/tasks/data_migrate_tasks_spec.rb index 600cc3b6..50792d95 100644 --- a/spec/data_migrate/tasks/data_migrate_tasks_spec.rb +++ b/spec/data_migrate/tasks/data_migrate_tasks_spec.rb @@ -115,13 +115,13 @@ it "should display data migration status" do expect { - DataMigrate::Tasks::DataMigrateTasks.status(connection_db_config) + DataMigrate::Tasks::DataMigrateTasks.status }.to output(/up 20091231235959 Some name/).to_stdout end it "should display schema and data migration status" do expect { - DataMigrate::Tasks::DataMigrateTasks.status_with_schema(connection_db_config) + DataMigrate::Tasks::DataMigrateTasks.status_with_schema }.to output(match(/up data 20091231235959 Some name/) .and match(/down schema 20131111111111 Late migration/)).to_stdout end From 6b8ac7862ec42465da90e3e064bf3c14902e7f1d Mon Sep 17 00:00:00 2001 From: Maple Ong Date: Wed, 28 Jun 2023 15:06:48 -0400 Subject: [PATCH 32/98] Ensure the correct sha is written to internal_metadata table --- lib/data_migrate/database_tasks.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/data_migrate/database_tasks.rb b/lib/data_migrate/database_tasks.rb index 72db845f..f32c526d 100644 --- a/lib/data_migrate/database_tasks.rb +++ b/lib/data_migrate/database_tasks.rb @@ -66,6 +66,18 @@ def run_migration(migration, direction) ) end end + + def schema_dump_path(db_config, format = ActiveRecord.schema_format) + return ENV["DATA_SCHEMA"] if ENV["DATA_SCHEMA"] + super.gsub(/(_)?schema\.rb\z/, '\1data_schema.rb') + end + + # Override this method from `ActiveRecord::Tasks::DatabaseTasks` + # to ensure that the sha saved in ar_internal_metadata table + # is from the original schema.rb file + def schema_sha1(file) + super(file.gsub(/data_schema.rb\z/, 'schema.rb')) + end end def self.forward(step = 1) From dba5299f6cee4eaab5d5cc6d78fa3bdf8d8529b0 Mon Sep 17 00:00:00 2001 From: Maple Ong Date: Wed, 28 Jun 2023 15:07:22 -0400 Subject: [PATCH 33/98] Remove the need for empty data_schema files for non-primary databases --- lib/data_migrate/database_tasks.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/data_migrate/database_tasks.rb b/lib/data_migrate/database_tasks.rb index f32c526d..ee96a7d6 100644 --- a/lib/data_migrate/database_tasks.rb +++ b/lib/data_migrate/database_tasks.rb @@ -69,6 +69,10 @@ def run_migration(migration, direction) def schema_dump_path(db_config, format = ActiveRecord.schema_format) return ENV["DATA_SCHEMA"] if ENV["DATA_SCHEMA"] + + # We only require a schema.rb file for the primary database + return unless db_config.primary? + super.gsub(/(_)?schema\.rb\z/, '\1data_schema.rb') end From 88c8bf207c10fa5ea03988b2b221e4833abed33e Mon Sep 17 00:00:00 2001 From: Ngan Pham Date: Thu, 29 Jun 2023 10:09:40 -0700 Subject: [PATCH 34/98] Prepare v9.1.0 for release --- Changelog.md | 5 +++++ lib/data_migrate/version.rb | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Changelog.md b/Changelog.md index cb0ef863..2a0093ee 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,10 @@ # Changelog +## 9.1.0 + +- Fix a bug that caused `schema_sha1` in `ar_internal_metadata` to be reset to the `data_schema.rb` file. (#272) +- Remove the need for empty data_schema files for non-primary databases. (#273) + ## [YANKED] 10.0.3.rc - Remove all travis references [leoarnold](https//:github.com/leoarnold) diff --git a/lib/data_migrate/version.rb b/lib/data_migrate/version.rb index 6c8a2f02..3533a8cd 100644 --- a/lib/data_migrate/version.rb +++ b/lib/data_migrate/version.rb @@ -1,3 +1,3 @@ module DataMigrate - VERSION = "10.0.3.rc".freeze + VERSION = "9.1.0".freeze end From 7bc28b8766c3c3b718d9835c91f88ae12444f9cf Mon Sep 17 00:00:00 2001 From: Ngan Pham Date: Thu, 29 Jun 2023 10:19:30 -0700 Subject: [PATCH 35/98] Switch to ruby/setup-ruby --- .github/workflows/gempush.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/gempush.yml b/.github/workflows/gempush.yml index 84c9d09b..e88a876d 100644 --- a/.github/workflows/gempush.yml +++ b/.github/workflows/gempush.yml @@ -12,7 +12,7 @@ jobs: steps: - uses: actions/checkout@master - name: Set up Ruby 3.2 - uses: actions/setup-ruby@v1 + uses: ruby/setup-ruby@v1 with: ruby-version: '3.2' From efc989180e952f54429e2849a5792ddab328f39d Mon Sep 17 00:00:00 2001 From: Maple Ong Date: Tue, 11 Jul 2023 14:55:11 -0400 Subject: [PATCH 36/98] Inherit from AR SchemaMigration directly --- lib/data_migrate/data_schema_migration.rb | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/data_migrate/data_schema_migration.rb b/lib/data_migrate/data_schema_migration.rb index 68316664..c04c470e 100644 --- a/lib/data_migrate/data_schema_migration.rb +++ b/lib/data_migrate/data_schema_migration.rb @@ -1,13 +1,12 @@ module DataMigrate - class DataSchemaMigration + class DataSchemaMigration < ActiveRecord::SchemaMigration class << self - delegate :table_name, :primary_key, :create_table, :normalized_versions, :create, :create!, :table_exists?, :exists?, :where, to: :instance + def table_name + ActiveRecord::Base.table_name_prefix + 'data_migrations' + ActiveRecord::Base.table_name_suffix + end - def instance - @instance ||= Class.new(::ActiveRecord::SchemaMigration) do - define_singleton_method(:table_name) { ActiveRecord::Base.table_name_prefix + 'data_migrations' + ActiveRecord::Base.table_name_suffix } - define_singleton_method(:primary_key) { "version" } - end + def primary_key + "version" end end end From 25d13b8a1cec38d16a294633c80596d22612c73c Mon Sep 17 00:00:00 2001 From: Maple Ong Date: Fri, 14 Jul 2023 14:34:48 -0400 Subject: [PATCH 37/98] Commit *.lock files --- .gitignore | 1 - Gemfile.lock | 148 +++++++++++++++++++++ gemfiles/rails_6.0.gemfile | 2 +- gemfiles/rails_6.0.gemfile.lock | 225 +++++++++++++++++++++++++++++++ gemfiles/rails_6.1.gemfile | 2 +- gemfiles/rails_6.1.gemfile.lock | 224 +++++++++++++++++++++++++++++++ gemfiles/rails_7.0.gemfile.lock | 226 ++++++++++++++++++++++++++++++++ 7 files changed, 825 insertions(+), 3 deletions(-) create mode 100644 Gemfile.lock create mode 100644 gemfiles/rails_6.0.gemfile.lock create mode 100644 gemfiles/rails_6.1.gemfile.lock create mode 100644 gemfiles/rails_7.0.gemfile.lock diff --git a/.gitignore b/.gitignore index 93cd6e23..136b8a80 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ /.rvmrc *.gem -*.lock gemfiles/.bundle spec/db/test.db spec/db/other_test.db diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 00000000..a4583362 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,148 @@ +PATH + remote: . + specs: + data_migrate (9.1.0) + activerecord (>= 6.0) + railties (>= 6.0) + +GEM + remote: http://rubygems.org/ + specs: + actionpack (7.0.6) + actionview (= 7.0.6) + activesupport (= 7.0.6) + rack (~> 2.0, >= 2.2.4) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.2.0) + actionview (7.0.6) + activesupport (= 7.0.6) + builder (~> 3.1) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.1, >= 1.2.0) + activemodel (7.0.6) + activesupport (= 7.0.6) + activerecord (7.0.6) + activemodel (= 7.0.6) + activesupport (= 7.0.6) + activesupport (7.0.6) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + appraisal (2.5.0) + bundler + rake + thor (>= 0.14.0) + ast (2.4.2) + builder (3.2.4) + childprocess (4.1.0) + coderay (1.1.3) + concurrent-ruby (1.2.2) + crass (1.0.6) + diff-lcs (1.5.0) + erubi (1.12.0) + i18n (1.14.1) + concurrent-ruby (~> 1.0) + iniparse (1.5.0) + json (2.6.3) + language_server-protocol (3.17.0.3) + loofah (2.21.3) + crass (~> 1.0.2) + nokogiri (>= 1.12.0) + method_source (1.0.0) + minitest (5.18.1) + nokogiri (1.15.3-arm64-darwin) + racc (~> 1.4) + nokogiri (1.15.3-x86_64-linux) + racc (~> 1.4) + overcommit (0.60.0) + childprocess (>= 0.6.3, < 5) + iniparse (~> 1.4) + rexml (~> 3.2) + parallel (1.23.0) + parser (3.2.2.3) + ast (~> 2.4.1) + racc + pry (0.14.2) + coderay (~> 1.1) + method_source (~> 1.0) + racc (1.7.1) + rack (2.2.7) + rack-test (2.1.0) + rack (>= 1.3) + rails-dom-testing (2.1.1) + activesupport (>= 5.0.0) + minitest + nokogiri (>= 1.6) + rails-html-sanitizer (1.6.0) + loofah (~> 2.21) + nokogiri (~> 1.14) + railties (7.0.6) + actionpack (= 7.0.6) + activesupport (= 7.0.6) + method_source + rake (>= 12.2) + thor (~> 1.0) + zeitwerk (~> 2.5) + rainbow (3.1.1) + rake (13.0.6) + rb-readline (0.5.5) + regexp_parser (2.8.1) + rexml (3.2.5) + rspec (3.12.0) + rspec-core (~> 3.12.0) + rspec-expectations (~> 3.12.0) + rspec-mocks (~> 3.12.0) + rspec-core (3.12.2) + rspec-support (~> 3.12.0) + rspec-expectations (3.12.3) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.12.0) + rspec-mocks (3.12.6) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.12.0) + rspec-support (3.12.1) + rubocop (1.54.2) + json (~> 2.3) + language_server-protocol (>= 3.17.0) + parallel (~> 1.10) + parser (>= 3.2.2.3) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.8, < 3.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.28.0, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.29.0) + parser (>= 3.2.1.0) + ruby-progressbar (1.13.0) + sqlite3 (1.6.3-arm64-darwin) + sqlite3 (1.6.3-x86_64-linux) + thor (1.2.2) + timecop (0.9.6) + tzinfo (2.0.6) + concurrent-ruby (~> 1.0) + unicode-display_width (2.4.2) + zeitwerk (2.6.8) + +PLATFORMS + arm64-darwin-22 + x86_64-linux + +DEPENDENCIES + appraisal + data_migrate! + overcommit + pry + rake + rb-readline + rspec + rspec-core + rubocop + sqlite3 (~> 1.4) + timecop + +BUNDLED WITH + 2.4.17 diff --git a/gemfiles/rails_6.0.gemfile b/gemfiles/rails_6.0.gemfile index 172f9d56..fd25237e 100644 --- a/gemfiles/rails_6.0.gemfile +++ b/gemfiles/rails_6.0.gemfile @@ -2,7 +2,7 @@ source "http://rubygems.org" -gem "rails", "~> 6.0.0" gem "sqlite3", "~> 1.4" +gem "rails", "~> 6.0.0" gemspec path: "../" diff --git a/gemfiles/rails_6.0.gemfile.lock b/gemfiles/rails_6.0.gemfile.lock new file mode 100644 index 00000000..5a94c489 --- /dev/null +++ b/gemfiles/rails_6.0.gemfile.lock @@ -0,0 +1,225 @@ +PATH + remote: .. + specs: + data_migrate (9.1.0) + activerecord (>= 6.0) + railties (>= 6.0) + +GEM + remote: http://rubygems.org/ + specs: + actioncable (6.0.0) + actionpack (= 6.0.0) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailbox (6.0.0) + actionpack (= 6.0.0) + activejob (= 6.0.0) + activerecord (= 6.0.0) + activestorage (= 6.0.0) + activesupport (= 6.0.0) + mail (>= 2.7.1) + actionmailer (6.0.0) + actionpack (= 6.0.0) + actionview (= 6.0.0) + activejob (= 6.0.0) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 2.0) + actionpack (6.0.0) + actionview (= 6.0.0) + activesupport (= 6.0.0) + rack (~> 2.0) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.2.0) + actiontext (6.0.0) + actionpack (= 6.0.0) + activerecord (= 6.0.0) + activestorage (= 6.0.0) + activesupport (= 6.0.0) + nokogiri (>= 1.8.5) + actionview (6.0.0) + activesupport (= 6.0.0) + builder (~> 3.1) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.1, >= 1.2.0) + activejob (6.0.0) + activesupport (= 6.0.0) + globalid (>= 0.3.6) + activemodel (6.0.0) + activesupport (= 6.0.0) + activerecord (6.0.0) + activemodel (= 6.0.0) + activesupport (= 6.0.0) + activestorage (6.0.0) + actionpack (= 6.0.0) + activejob (= 6.0.0) + activerecord (= 6.0.0) + marcel (~> 0.3.1) + activesupport (6.0.0) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 0.7, < 2) + minitest (~> 5.1) + tzinfo (~> 1.1) + zeitwerk (~> 2.1, >= 2.1.8) + appraisal (2.4.1) + bundler + rake + thor (>= 0.14.0) + ast (2.4.2) + builder (3.2.4) + childprocess (4.1.0) + coderay (1.1.3) + concurrent-ruby (1.2.2) + crass (1.0.6) + date (3.3.3) + diff-lcs (1.5.0) + erubi (1.12.0) + globalid (1.1.0) + activesupport (>= 5.0) + i18n (1.14.1) + concurrent-ruby (~> 1.0) + iniparse (1.5.0) + json (2.6.3) + loofah (2.21.3) + crass (~> 1.0.2) + nokogiri (>= 1.12.0) + mail (2.8.1) + mini_mime (>= 0.1.1) + net-imap + net-pop + net-smtp + marcel (0.3.3) + mimemagic (~> 0.3.2) + method_source (1.0.0) + mimemagic (0.3.10) + nokogiri (~> 1) + rake + mini_mime (1.1.2) + minitest (5.18.1) + net-imap (0.3.4) + date + net-protocol + net-pop (0.1.2) + net-protocol + net-protocol (0.2.1) + timeout + net-smtp (0.3.3) + net-protocol + nio4r (2.5.9) + nokogiri (1.15.2-arm64-darwin) + racc (~> 1.4) + overcommit (0.60.0) + childprocess (>= 0.6.3, < 5) + iniparse (~> 1.4) + rexml (~> 3.2) + parallel (1.23.0) + parser (3.2.2.3) + ast (~> 2.4.1) + racc + pry (0.14.2) + coderay (~> 1.1) + method_source (~> 1.0) + racc (1.7.1) + rack (2.2.7) + rack-test (2.1.0) + rack (>= 1.3) + rails (6.0.0) + actioncable (= 6.0.0) + actionmailbox (= 6.0.0) + actionmailer (= 6.0.0) + actionpack (= 6.0.0) + actiontext (= 6.0.0) + actionview (= 6.0.0) + activejob (= 6.0.0) + activemodel (= 6.0.0) + activerecord (= 6.0.0) + activestorage (= 6.0.0) + activesupport (= 6.0.0) + bundler (>= 1.3.0) + railties (= 6.0.0) + sprockets-rails (>= 2.0.0) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) + rails-html-sanitizer (1.6.0) + loofah (~> 2.21) + nokogiri (~> 1.14) + railties (6.0.0) + actionpack (= 6.0.0) + activesupport (= 6.0.0) + method_source + rake (>= 0.8.7) + thor (>= 0.20.3, < 2.0) + rainbow (3.1.1) + rake (13.0.6) + rb-readline (0.5.5) + regexp_parser (2.8.1) + rexml (3.2.5) + rspec (3.12.0) + rspec-core (~> 3.12.0) + rspec-expectations (~> 3.12.0) + rspec-mocks (~> 3.12.0) + rspec-core (3.12.2) + rspec-support (~> 3.12.0) + rspec-expectations (3.12.3) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.12.0) + rspec-mocks (3.12.5) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.12.0) + rspec-support (3.12.0) + rubocop (1.52.1) + json (~> 2.3) + parallel (~> 1.10) + parser (>= 3.2.2.3) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.8, < 3.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.28.0, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.29.0) + parser (>= 3.2.1.0) + ruby-progressbar (1.13.0) + sprockets (4.2.0) + concurrent-ruby (~> 1.0) + rack (>= 2.2.4, < 4) + sprockets-rails (3.4.2) + actionpack (>= 5.2) + activesupport (>= 5.2) + sprockets (>= 3.0.0) + sqlite3 (1.6.3-arm64-darwin) + thor (1.2.2) + thread_safe (0.3.6) + timecop (0.9.6) + timeout (0.3.2) + tzinfo (1.2.11) + thread_safe (~> 0.1) + unicode-display_width (2.4.2) + websocket-driver (0.7.5) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + zeitwerk (2.6.8) + +PLATFORMS + arm64-darwin-22 + x86_64-linux + +DEPENDENCIES + appraisal + data_migrate! + overcommit + pry + rails (~> 6.0.0) + rake + rb-readline + rspec + rspec-core + rubocop + sqlite3 (~> 1.4) + timecop + +BUNDLED WITH + 2.4.14 diff --git a/gemfiles/rails_6.1.gemfile b/gemfiles/rails_6.1.gemfile index eff39ac3..20ae603a 100644 --- a/gemfiles/rails_6.1.gemfile +++ b/gemfiles/rails_6.1.gemfile @@ -2,7 +2,7 @@ source "http://rubygems.org" -gem "rails", "~> 6.1.0" gem "sqlite3", "~> 1.4" +gem "rails", "~> 6.1.0" gemspec path: "../" diff --git a/gemfiles/rails_6.1.gemfile.lock b/gemfiles/rails_6.1.gemfile.lock new file mode 100644 index 00000000..7894bce2 --- /dev/null +++ b/gemfiles/rails_6.1.gemfile.lock @@ -0,0 +1,224 @@ +PATH + remote: .. + specs: + data_migrate (9.1.0) + activerecord (>= 6.0) + railties (>= 6.0) + +GEM + remote: http://rubygems.org/ + specs: + actioncable (6.1.7.3) + actionpack (= 6.1.7.3) + activesupport (= 6.1.7.3) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailbox (6.1.7.3) + actionpack (= 6.1.7.3) + activejob (= 6.1.7.3) + activerecord (= 6.1.7.3) + activestorage (= 6.1.7.3) + activesupport (= 6.1.7.3) + mail (>= 2.7.1) + actionmailer (6.1.7.3) + actionpack (= 6.1.7.3) + actionview (= 6.1.7.3) + activejob (= 6.1.7.3) + activesupport (= 6.1.7.3) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 2.0) + actionpack (6.1.7.3) + actionview (= 6.1.7.3) + activesupport (= 6.1.7.3) + rack (~> 2.0, >= 2.0.9) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.2.0) + actiontext (6.1.7.3) + actionpack (= 6.1.7.3) + activerecord (= 6.1.7.3) + activestorage (= 6.1.7.3) + activesupport (= 6.1.7.3) + nokogiri (>= 1.8.5) + actionview (6.1.7.3) + activesupport (= 6.1.7.3) + builder (~> 3.1) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.1, >= 1.2.0) + activejob (6.1.7.3) + activesupport (= 6.1.7.3) + globalid (>= 0.3.6) + activemodel (6.1.7.3) + activesupport (= 6.1.7.3) + activerecord (6.1.7.3) + activemodel (= 6.1.7.3) + activesupport (= 6.1.7.3) + activestorage (6.1.7.3) + actionpack (= 6.1.7.3) + activejob (= 6.1.7.3) + activerecord (= 6.1.7.3) + activesupport (= 6.1.7.3) + marcel (~> 1.0) + mini_mime (>= 1.1.0) + activesupport (6.1.7.3) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + zeitwerk (~> 2.3) + appraisal (2.4.1) + bundler + rake + thor (>= 0.14.0) + ast (2.4.2) + builder (3.2.4) + childprocess (4.1.0) + coderay (1.1.3) + concurrent-ruby (1.2.2) + crass (1.0.6) + date (3.3.3) + diff-lcs (1.5.0) + erubi (1.12.0) + globalid (1.1.0) + activesupport (>= 5.0) + i18n (1.14.1) + concurrent-ruby (~> 1.0) + iniparse (1.5.0) + json (2.6.3) + loofah (2.21.3) + crass (~> 1.0.2) + nokogiri (>= 1.12.0) + mail (2.8.1) + mini_mime (>= 0.1.1) + net-imap + net-pop + net-smtp + marcel (1.0.2) + method_source (1.0.0) + mini_mime (1.1.2) + minitest (5.18.1) + net-imap (0.3.4) + date + net-protocol + net-pop (0.1.2) + net-protocol + net-protocol (0.2.1) + timeout + net-smtp (0.3.3) + net-protocol + nio4r (2.5.9) + nokogiri (1.15.2-arm64-darwin) + racc (~> 1.4) + overcommit (0.60.0) + childprocess (>= 0.6.3, < 5) + iniparse (~> 1.4) + rexml (~> 3.2) + parallel (1.23.0) + parser (3.2.2.3) + ast (~> 2.4.1) + racc + pry (0.14.2) + coderay (~> 1.1) + method_source (~> 1.0) + racc (1.7.1) + rack (2.2.7) + rack-test (2.1.0) + rack (>= 1.3) + rails (6.1.7.3) + actioncable (= 6.1.7.3) + actionmailbox (= 6.1.7.3) + actionmailer (= 6.1.7.3) + actionpack (= 6.1.7.3) + actiontext (= 6.1.7.3) + actionview (= 6.1.7.3) + activejob (= 6.1.7.3) + activemodel (= 6.1.7.3) + activerecord (= 6.1.7.3) + activestorage (= 6.1.7.3) + activesupport (= 6.1.7.3) + bundler (>= 1.15.0) + railties (= 6.1.7.3) + sprockets-rails (>= 2.0.0) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) + rails-html-sanitizer (1.6.0) + loofah (~> 2.21) + nokogiri (~> 1.14) + railties (6.1.7.3) + actionpack (= 6.1.7.3) + activesupport (= 6.1.7.3) + method_source + rake (>= 12.2) + thor (~> 1.0) + rainbow (3.1.1) + rake (13.0.6) + rb-readline (0.5.5) + regexp_parser (2.8.1) + rexml (3.2.5) + rspec (3.12.0) + rspec-core (~> 3.12.0) + rspec-expectations (~> 3.12.0) + rspec-mocks (~> 3.12.0) + rspec-core (3.12.2) + rspec-support (~> 3.12.0) + rspec-expectations (3.12.3) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.12.0) + rspec-mocks (3.12.5) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.12.0) + rspec-support (3.12.0) + rubocop (1.52.1) + json (~> 2.3) + parallel (~> 1.10) + parser (>= 3.2.2.3) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.8, < 3.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.28.0, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.29.0) + parser (>= 3.2.1.0) + ruby-progressbar (1.13.0) + sprockets (4.2.0) + concurrent-ruby (~> 1.0) + rack (>= 2.2.4, < 4) + sprockets-rails (3.4.2) + actionpack (>= 5.2) + activesupport (>= 5.2) + sprockets (>= 3.0.0) + sqlite3 (1.6.3-arm64-darwin) + thor (1.2.2) + timecop (0.9.6) + timeout (0.3.2) + tzinfo (2.0.6) + concurrent-ruby (~> 1.0) + unicode-display_width (2.4.2) + websocket-driver (0.7.5) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + zeitwerk (2.6.8) + +PLATFORMS + arm64-darwin-22 + x86_64-linux + +DEPENDENCIES + appraisal + data_migrate! + overcommit + pry + rails (~> 6.1.0) + rake + rb-readline + rspec + rspec-core + rubocop + sqlite3 (~> 1.4) + timecop + +BUNDLED WITH + 2.4.14 diff --git a/gemfiles/rails_7.0.gemfile.lock b/gemfiles/rails_7.0.gemfile.lock new file mode 100644 index 00000000..a6e89a98 --- /dev/null +++ b/gemfiles/rails_7.0.gemfile.lock @@ -0,0 +1,226 @@ +PATH + remote: .. + specs: + data_migrate (9.1.0) + activerecord (>= 6.0) + railties (>= 6.0) + +GEM + remote: http://rubygems.org/ + specs: + actioncable (7.0.6) + actionpack (= 7.0.6) + activesupport (= 7.0.6) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailbox (7.0.6) + actionpack (= 7.0.6) + activejob (= 7.0.6) + activerecord (= 7.0.6) + activestorage (= 7.0.6) + activesupport (= 7.0.6) + mail (>= 2.7.1) + net-imap + net-pop + net-smtp + actionmailer (7.0.6) + actionpack (= 7.0.6) + actionview (= 7.0.6) + activejob (= 7.0.6) + activesupport (= 7.0.6) + mail (~> 2.5, >= 2.5.4) + net-imap + net-pop + net-smtp + rails-dom-testing (~> 2.0) + actionpack (7.0.6) + actionview (= 7.0.6) + activesupport (= 7.0.6) + rack (~> 2.0, >= 2.2.4) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.2.0) + actiontext (7.0.6) + actionpack (= 7.0.6) + activerecord (= 7.0.6) + activestorage (= 7.0.6) + activesupport (= 7.0.6) + globalid (>= 0.6.0) + nokogiri (>= 1.8.5) + actionview (7.0.6) + activesupport (= 7.0.6) + builder (~> 3.1) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.1, >= 1.2.0) + activejob (7.0.6) + activesupport (= 7.0.6) + globalid (>= 0.3.6) + activemodel (7.0.6) + activesupport (= 7.0.6) + activerecord (7.0.6) + activemodel (= 7.0.6) + activesupport (= 7.0.6) + activestorage (7.0.6) + actionpack (= 7.0.6) + activejob (= 7.0.6) + activerecord (= 7.0.6) + activesupport (= 7.0.6) + marcel (~> 1.0) + mini_mime (>= 1.1.0) + activesupport (7.0.6) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + appraisal (2.4.1) + bundler + rake + thor (>= 0.14.0) + ast (2.4.2) + builder (3.2.4) + childprocess (4.1.0) + coderay (1.1.3) + concurrent-ruby (1.2.2) + crass (1.0.6) + date (3.3.3) + diff-lcs (1.5.0) + erubi (1.12.0) + globalid (1.1.0) + activesupport (>= 5.0) + i18n (1.14.1) + concurrent-ruby (~> 1.0) + iniparse (1.5.0) + json (2.6.3) + language_server-protocol (3.17.0.3) + loofah (2.21.3) + crass (~> 1.0.2) + nokogiri (>= 1.12.0) + mail (2.8.1) + mini_mime (>= 0.1.1) + net-imap + net-pop + net-smtp + marcel (1.0.2) + method_source (1.0.0) + mini_mime (1.1.2) + minitest (5.18.1) + net-imap (0.3.6) + date + net-protocol + net-pop (0.1.2) + net-protocol + net-protocol (0.2.1) + timeout + net-smtp (0.3.3) + net-protocol + nio4r (2.5.9) + nokogiri (1.15.3-arm64-darwin) + racc (~> 1.4) + overcommit (0.60.0) + childprocess (>= 0.6.3, < 5) + iniparse (~> 1.4) + rexml (~> 3.2) + parallel (1.23.0) + parser (3.2.2.3) + ast (~> 2.4.1) + racc + pry (0.14.2) + coderay (~> 1.1) + method_source (~> 1.0) + racc (1.7.1) + rack (2.2.7) + rack-test (2.1.0) + rack (>= 1.3) + rails (7.0.6) + actioncable (= 7.0.6) + actionmailbox (= 7.0.6) + actionmailer (= 7.0.6) + actionpack (= 7.0.6) + actiontext (= 7.0.6) + actionview (= 7.0.6) + activejob (= 7.0.6) + activemodel (= 7.0.6) + activerecord (= 7.0.6) + activestorage (= 7.0.6) + activesupport (= 7.0.6) + bundler (>= 1.15.0) + railties (= 7.0.6) + rails-dom-testing (2.1.1) + activesupport (>= 5.0.0) + minitest + nokogiri (>= 1.6) + rails-html-sanitizer (1.6.0) + loofah (~> 2.21) + nokogiri (~> 1.14) + railties (7.0.6) + actionpack (= 7.0.6) + activesupport (= 7.0.6) + method_source + rake (>= 12.2) + thor (~> 1.0) + zeitwerk (~> 2.5) + rainbow (3.1.1) + rake (13.0.6) + rb-readline (0.5.5) + regexp_parser (2.8.1) + rexml (3.2.5) + rspec (3.12.0) + rspec-core (~> 3.12.0) + rspec-expectations (~> 3.12.0) + rspec-mocks (~> 3.12.0) + rspec-core (3.12.2) + rspec-support (~> 3.12.0) + rspec-expectations (3.12.3) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.12.0) + rspec-mocks (3.12.5) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.12.0) + rspec-support (3.12.1) + rubocop (1.54.1) + json (~> 2.3) + language_server-protocol (>= 3.17.0) + parallel (~> 1.10) + parser (>= 3.2.2.3) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.8, < 3.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.28.0, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.29.0) + parser (>= 3.2.1.0) + ruby-progressbar (1.13.0) + sqlite3 (1.6.3-arm64-darwin) + thor (1.2.2) + timecop (0.9.6) + timeout (0.4.0) + tzinfo (2.0.6) + concurrent-ruby (~> 1.0) + unicode-display_width (2.4.2) + websocket-driver (0.7.5) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + zeitwerk (2.6.8) + +PLATFORMS + arm64-darwin-22 + x86_64-linux + +DEPENDENCIES + appraisal + data_migrate! + overcommit + pry + rails (~> 7.0) + rake + rb-readline + rspec + rspec-core + rubocop + sqlite3 (~> 1.4) + timecop + +BUNDLED WITH + 2.4.14 From e5af2ca47320e81153d49b85bc0ee93a69b6f58e Mon Sep 17 00:00:00 2001 From: Maple Ong Date: Fri, 21 Jul 2023 14:49:54 -0400 Subject: [PATCH 38/98] Remove support for Rails 6.0 --- .github/workflows/build.yml | 1 - Appraisals | 4 - Changelog.md | 4 + Gemfile.lock | 4 +- README.md | 5 +- data_migrate.gemspec | 2 +- gemfiles/rails_6.0.gemfile | 8 - gemfiles/rails_6.0.gemfile.lock | 225 ------------------ gemfiles/rails_6.1.gemfile.lock | 4 +- gemfiles/rails_7.0.gemfile.lock | 4 +- lib/data_migrate/schema_migration.rb | 2 +- lib/data_migrate/status_service.rb | 2 +- lib/data_migrate/tasks/data_migrate_tasks.rb | 2 +- spec/data_migrate/schema_migration_spec.rb | 2 +- spec/db/data/20091231235959_some_name.rb | 2 +- spec/db/data/20171231235959_super_update.rb | 2 +- .../migrate/20131111111111_late_migration.rb | 2 +- .../db/migrate/20202020202011_db_migration.rb | 2 +- 18 files changed, 21 insertions(+), 256 deletions(-) delete mode 100644 gemfiles/rails_6.0.gemfile delete mode 100644 gemfiles/rails_6.0.gemfile.lock diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 18d5494b..404bd3ad 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,7 +15,6 @@ jobs: - '3.1' - '3.2' gemfile: - - gemfiles/rails_6.0.gemfile - gemfiles/rails_6.1.gemfile - gemfiles/rails_7.0.gemfile runs-on: ubuntu-latest diff --git a/Appraisals b/Appraisals index 12b662af..9bb5a4ba 100644 --- a/Appraisals +++ b/Appraisals @@ -1,7 +1,3 @@ -appraise 'rails-6.0' do - gem 'rails', '~> 6.0.0' -end - appraise 'rails-6.1' do gem 'rails', '~> 6.1.0' end diff --git a/Changelog.md b/Changelog.md index 2a0093ee..1cf5a438 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,9 @@ # Changelog +## 11.0.0 +- Commit *.lock files +- Remove support for Rails 6.0 + ## 9.1.0 - Fix a bug that caused `schema_sha1` in `ar_internal_metadata` to be reset to the `data_schema.rb` file. (#272) diff --git a/Gemfile.lock b/Gemfile.lock index a4583362..e2c16a5d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -2,8 +2,8 @@ PATH remote: . specs: data_migrate (9.1.0) - activerecord (>= 6.0) - railties (>= 6.0) + activerecord (>= 6.1) + railties (>= 6.1) GEM remote: http://rubygems.org/ diff --git a/README.md b/README.md index 48346a1f..45fe96e8 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ table to track all migrations. ## Rails Support -Support Rails 6.0 through 7.0 +Support Rails 6.1 through 7.0 #### v1 @@ -92,7 +92,7 @@ You can generate a data migration as you would a schema migration: rake db:version:with_data # Retrieves the current schema version numbers for data and schema migrations -Tasks work as they would with the 'vanilla' db version. The 'with_data' addition to the 'db' tasks will run the task in the context of both the data and schema migrations. That is, rake db:rollback:with_data will check to see if it was a schema or data migration invoked last, and do that. Tasks invoked in that space also have an additional line of output, indicating if the action is performed on data or schema. +Tasks work as they would with the 'vanilla' db version. The 'with_data' addition to the 'db' tasks will run the task in the context of both the data and schema migrations. That is, rake db:rollback:with_data will check to see if it was a schema or data migration invoked last, and do that. Tasks invoked in that space also have an additional line of output, indicating if the action is performed on data or schema. With 'up' and 'down', you can specify the option 'BOTH', which defaults to false. Using true, will migrate both the data and schema (in the desired direction) if they both match the version provided. Again, going up, schema is given precedence. Down its data. @@ -164,7 +164,6 @@ Run tests for a specific version of Rails ``` bundle exec appraisal install -bundle exec appraisal rails-6.0 rspec bundle exec appraisal rails-6.1 rspec bundle exec appraisal rails-7.0 rspec ``` diff --git a/data_migrate.gemspec b/data_migrate.gemspec index 5824e2db..5646c2b4 100644 --- a/data_migrate.gemspec +++ b/data_migrate.gemspec @@ -19,7 +19,7 @@ Gem::Specification.new do |s| activerecord railties ].each do |rails_gem| - s.add_dependency(rails_gem, '>= 6.0') + s.add_dependency(rails_gem, '>= 6.1') end s.add_development_dependency "appraisal" diff --git a/gemfiles/rails_6.0.gemfile b/gemfiles/rails_6.0.gemfile deleted file mode 100644 index fd25237e..00000000 --- a/gemfiles/rails_6.0.gemfile +++ /dev/null @@ -1,8 +0,0 @@ -# This file was generated by Appraisal - -source "http://rubygems.org" - -gem "sqlite3", "~> 1.4" -gem "rails", "~> 6.0.0" - -gemspec path: "../" diff --git a/gemfiles/rails_6.0.gemfile.lock b/gemfiles/rails_6.0.gemfile.lock deleted file mode 100644 index 5a94c489..00000000 --- a/gemfiles/rails_6.0.gemfile.lock +++ /dev/null @@ -1,225 +0,0 @@ -PATH - remote: .. - specs: - data_migrate (9.1.0) - activerecord (>= 6.0) - railties (>= 6.0) - -GEM - remote: http://rubygems.org/ - specs: - actioncable (6.0.0) - actionpack (= 6.0.0) - nio4r (~> 2.0) - websocket-driver (>= 0.6.1) - actionmailbox (6.0.0) - actionpack (= 6.0.0) - activejob (= 6.0.0) - activerecord (= 6.0.0) - activestorage (= 6.0.0) - activesupport (= 6.0.0) - mail (>= 2.7.1) - actionmailer (6.0.0) - actionpack (= 6.0.0) - actionview (= 6.0.0) - activejob (= 6.0.0) - mail (~> 2.5, >= 2.5.4) - rails-dom-testing (~> 2.0) - actionpack (6.0.0) - actionview (= 6.0.0) - activesupport (= 6.0.0) - rack (~> 2.0) - rack-test (>= 0.6.3) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (6.0.0) - actionpack (= 6.0.0) - activerecord (= 6.0.0) - activestorage (= 6.0.0) - activesupport (= 6.0.0) - nokogiri (>= 1.8.5) - actionview (6.0.0) - activesupport (= 6.0.0) - builder (~> 3.1) - erubi (~> 1.4) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (6.0.0) - activesupport (= 6.0.0) - globalid (>= 0.3.6) - activemodel (6.0.0) - activesupport (= 6.0.0) - activerecord (6.0.0) - activemodel (= 6.0.0) - activesupport (= 6.0.0) - activestorage (6.0.0) - actionpack (= 6.0.0) - activejob (= 6.0.0) - activerecord (= 6.0.0) - marcel (~> 0.3.1) - activesupport (6.0.0) - concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 0.7, < 2) - minitest (~> 5.1) - tzinfo (~> 1.1) - zeitwerk (~> 2.1, >= 2.1.8) - appraisal (2.4.1) - bundler - rake - thor (>= 0.14.0) - ast (2.4.2) - builder (3.2.4) - childprocess (4.1.0) - coderay (1.1.3) - concurrent-ruby (1.2.2) - crass (1.0.6) - date (3.3.3) - diff-lcs (1.5.0) - erubi (1.12.0) - globalid (1.1.0) - activesupport (>= 5.0) - i18n (1.14.1) - concurrent-ruby (~> 1.0) - iniparse (1.5.0) - json (2.6.3) - loofah (2.21.3) - crass (~> 1.0.2) - nokogiri (>= 1.12.0) - mail (2.8.1) - mini_mime (>= 0.1.1) - net-imap - net-pop - net-smtp - marcel (0.3.3) - mimemagic (~> 0.3.2) - method_source (1.0.0) - mimemagic (0.3.10) - nokogiri (~> 1) - rake - mini_mime (1.1.2) - minitest (5.18.1) - net-imap (0.3.4) - date - net-protocol - net-pop (0.1.2) - net-protocol - net-protocol (0.2.1) - timeout - net-smtp (0.3.3) - net-protocol - nio4r (2.5.9) - nokogiri (1.15.2-arm64-darwin) - racc (~> 1.4) - overcommit (0.60.0) - childprocess (>= 0.6.3, < 5) - iniparse (~> 1.4) - rexml (~> 3.2) - parallel (1.23.0) - parser (3.2.2.3) - ast (~> 2.4.1) - racc - pry (0.14.2) - coderay (~> 1.1) - method_source (~> 1.0) - racc (1.7.1) - rack (2.2.7) - rack-test (2.1.0) - rack (>= 1.3) - rails (6.0.0) - actioncable (= 6.0.0) - actionmailbox (= 6.0.0) - actionmailer (= 6.0.0) - actionpack (= 6.0.0) - actiontext (= 6.0.0) - actionview (= 6.0.0) - activejob (= 6.0.0) - activemodel (= 6.0.0) - activerecord (= 6.0.0) - activestorage (= 6.0.0) - activesupport (= 6.0.0) - bundler (>= 1.3.0) - railties (= 6.0.0) - sprockets-rails (>= 2.0.0) - rails-dom-testing (2.0.3) - activesupport (>= 4.2.0) - nokogiri (>= 1.6) - rails-html-sanitizer (1.6.0) - loofah (~> 2.21) - nokogiri (~> 1.14) - railties (6.0.0) - actionpack (= 6.0.0) - activesupport (= 6.0.0) - method_source - rake (>= 0.8.7) - thor (>= 0.20.3, < 2.0) - rainbow (3.1.1) - rake (13.0.6) - rb-readline (0.5.5) - regexp_parser (2.8.1) - rexml (3.2.5) - rspec (3.12.0) - rspec-core (~> 3.12.0) - rspec-expectations (~> 3.12.0) - rspec-mocks (~> 3.12.0) - rspec-core (3.12.2) - rspec-support (~> 3.12.0) - rspec-expectations (3.12.3) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.12.0) - rspec-mocks (3.12.5) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.12.0) - rspec-support (3.12.0) - rubocop (1.52.1) - json (~> 2.3) - parallel (~> 1.10) - parser (>= 3.2.2.3) - rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 1.8, < 3.0) - rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.28.0, < 2.0) - ruby-progressbar (~> 1.7) - unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.29.0) - parser (>= 3.2.1.0) - ruby-progressbar (1.13.0) - sprockets (4.2.0) - concurrent-ruby (~> 1.0) - rack (>= 2.2.4, < 4) - sprockets-rails (3.4.2) - actionpack (>= 5.2) - activesupport (>= 5.2) - sprockets (>= 3.0.0) - sqlite3 (1.6.3-arm64-darwin) - thor (1.2.2) - thread_safe (0.3.6) - timecop (0.9.6) - timeout (0.3.2) - tzinfo (1.2.11) - thread_safe (~> 0.1) - unicode-display_width (2.4.2) - websocket-driver (0.7.5) - websocket-extensions (>= 0.1.0) - websocket-extensions (0.1.5) - zeitwerk (2.6.8) - -PLATFORMS - arm64-darwin-22 - x86_64-linux - -DEPENDENCIES - appraisal - data_migrate! - overcommit - pry - rails (~> 6.0.0) - rake - rb-readline - rspec - rspec-core - rubocop - sqlite3 (~> 1.4) - timecop - -BUNDLED WITH - 2.4.14 diff --git a/gemfiles/rails_6.1.gemfile.lock b/gemfiles/rails_6.1.gemfile.lock index 7894bce2..c7a9bb2f 100644 --- a/gemfiles/rails_6.1.gemfile.lock +++ b/gemfiles/rails_6.1.gemfile.lock @@ -2,8 +2,8 @@ PATH remote: .. specs: data_migrate (9.1.0) - activerecord (>= 6.0) - railties (>= 6.0) + activerecord (>= 6.1) + railties (>= 6.1) GEM remote: http://rubygems.org/ diff --git a/gemfiles/rails_7.0.gemfile.lock b/gemfiles/rails_7.0.gemfile.lock index a6e89a98..8e03876d 100644 --- a/gemfiles/rails_7.0.gemfile.lock +++ b/gemfiles/rails_7.0.gemfile.lock @@ -2,8 +2,8 @@ PATH remote: .. specs: data_migrate (9.1.0) - activerecord (>= 6.0) - railties (>= 6.0) + activerecord (>= 6.1) + railties (>= 6.1) GEM remote: http://rubygems.org/ diff --git a/lib/data_migrate/schema_migration.rb b/lib/data_migrate/schema_migration.rb index aa7469f5..f93c0b16 100644 --- a/lib/data_migrate/schema_migration.rb +++ b/lib/data_migrate/schema_migration.rb @@ -26,7 +26,7 @@ def self.migrations_paths spec_name = DataMigrate.config.spec_name if spec_name && Gem::Dependency.new("railties", "~> 7.0").match?("railties", Gem.loaded_specs["railties"].version) ActiveRecord::Base.configurations.configs_for(env_name: Rails.env, name: spec_name).migrations_paths - elsif spec_name && Gem::Dependency.new("railties", "~> 6.0").match?("railties", Gem.loaded_specs["railties"].version) + elsif spec_name && Gem::Dependency.new("railties", "~> 6.1").match?("railties", Gem.loaded_specs["railties"].version) ActiveRecord::Base.configurations.configs_for(env_name: Rails.env, spec_name: spec_name).migrations_paths else Rails.application.config.paths["db/migrate"].to_a diff --git a/lib/data_migrate/status_service.rb b/lib/data_migrate/status_service.rb index e912faca..6ca148c8 100644 --- a/lib/data_migrate/status_service.rb +++ b/lib/data_migrate/status_service.rb @@ -46,7 +46,7 @@ def output(stream) def database_name if Gem::Dependency.new("railties", "~> 7.0").match?("railties", Gem.loaded_specs["railties"].version) ActiveRecord::Base.connection_db_config.configuration_hash[:database] - elsif Gem::Dependency.new("railties", "~> 6.0").match?("railties", Gem.loaded_specs["railties"].version) + elsif Gem::Dependency.new("railties", "~> 6.1").match?("railties", Gem.loaded_specs["railties"].version) ActiveRecord::Base.connection_config[:database] end end diff --git a/lib/data_migrate/tasks/data_migrate_tasks.rb b/lib/data_migrate/tasks/data_migrate_tasks.rb index 52f9b84c..1c97bdf8 100644 --- a/lib/data_migrate/tasks/data_migrate_tasks.rb +++ b/lib/data_migrate/tasks/data_migrate_tasks.rb @@ -96,7 +96,7 @@ def status_with_schema def database_name if Gem::Dependency.new("railties", "~> 7.0").match?("railties", Gem.loaded_specs["railties"].version) ActiveRecord::Base.connection_db_config.database - elsif Gem::Dependency.new("railties", "~> 6.0").match?("railties", Gem.loaded_specs["railties"].version) + elsif Gem::Dependency.new("railties", "~> 6.1").match?("railties", Gem.loaded_specs["railties"].version) ActiveRecord::Base.connection_config[:database] end end diff --git a/spec/data_migrate/schema_migration_spec.rb b/spec/data_migrate/schema_migration_spec.rb index 00f6ad26..6f73e221 100644 --- a/spec/data_migrate/schema_migration_spec.rb +++ b/spec/data_migrate/schema_migration_spec.rb @@ -61,7 +61,7 @@ let(:paths) { ['spec/db/migrate', 'spec/db/migrate/other'] } let(:specification_name) { "primary" } let(:config_options) do - if Gem::Dependency.new("railties", "~> 6.0").match?("railties", Gem.loaded_specs["railties"].version) + if Gem::Dependency.new("railties", "~> 6.1").match?("railties", Gem.loaded_specs["railties"].version) { env_name: Rails.env, spec_name: specification_name } elsif Gem::Dependency.new("railties", "~> 7.0").match?("railties", Gem.loaded_specs["railties"].version) { env_name: Rails.env, name: specification_name } diff --git a/spec/db/data/20091231235959_some_name.rb b/spec/db/data/20091231235959_some_name.rb index 145f291b..2b32fc49 100644 --- a/spec/db/data/20091231235959_some_name.rb +++ b/spec/db/data/20091231235959_some_name.rb @@ -1,4 +1,4 @@ -class SomeName < ActiveRecord::Migration[6.0] +class SomeName < ActiveRecord::Migration[6.1] def up puts "Doing data migration" end diff --git a/spec/db/data/20171231235959_super_update.rb b/spec/db/data/20171231235959_super_update.rb index 68edca36..85378ffb 100644 --- a/spec/db/data/20171231235959_super_update.rb +++ b/spec/db/data/20171231235959_super_update.rb @@ -1,4 +1,4 @@ -class SuperUpdate < ActiveRecord::Migration[6.0] +class SuperUpdate < ActiveRecord::Migration[6.1] def up puts "Doing SuperUpdate" end diff --git a/spec/db/migrate/20131111111111_late_migration.rb b/spec/db/migrate/20131111111111_late_migration.rb index cc5ef34c..8bafff3c 100644 --- a/spec/db/migrate/20131111111111_late_migration.rb +++ b/spec/db/migrate/20131111111111_late_migration.rb @@ -1,4 +1,4 @@ -class LateMigration < ActiveRecord::Migration[6.0] +class LateMigration < ActiveRecord::Migration[6.1] def up puts "Doing schema LateMigration" end diff --git a/spec/db/migrate/20202020202011_db_migration.rb b/spec/db/migrate/20202020202011_db_migration.rb index e254be44..3653cb2a 100644 --- a/spec/db/migrate/20202020202011_db_migration.rb +++ b/spec/db/migrate/20202020202011_db_migration.rb @@ -1,4 +1,4 @@ -class DbMigration < ActiveRecord::Migration[6.0] +class DbMigration < ActiveRecord::Migration[6.1] def up puts "Doing schema migration" end From 607d14ce6164d8eaf3cb8e4d5224a33153c19dbb Mon Sep 17 00:00:00 2001 From: Maple Ong Date: Thu, 27 Jul 2023 15:35:56 -0400 Subject: [PATCH 39/98] Appraise rails 7.1.0.alpha --- Appraisals | 4 + gemfiles/rails_7.1.0.alpha.gemfile | 8 + gemfiles/rails_7.1.0.alpha.gemfile.lock | 248 ++++++++++++++++++++++++ 3 files changed, 260 insertions(+) create mode 100644 gemfiles/rails_7.1.0.alpha.gemfile create mode 100644 gemfiles/rails_7.1.0.alpha.gemfile.lock diff --git a/Appraisals b/Appraisals index 9bb5a4ba..f8722491 100644 --- a/Appraisals +++ b/Appraisals @@ -5,3 +5,7 @@ end appraise 'rails-7.0' do gem 'rails', '~> 7.0' end + +appraise 'rails-7.1.0.alpha' do + gem 'rails', git: "https://github.com/rails/rails.git", branch: "main" +end diff --git a/gemfiles/rails_7.1.0.alpha.gemfile b/gemfiles/rails_7.1.0.alpha.gemfile new file mode 100644 index 00000000..bcccc8a3 --- /dev/null +++ b/gemfiles/rails_7.1.0.alpha.gemfile @@ -0,0 +1,8 @@ +# This file was generated by Appraisal + +source "http://rubygems.org" + +gem "sqlite3", "~> 1.4" +gem "rails", git: "https://github.com/rails/rails.git", branch: "main" + +gemspec path: "../" diff --git a/gemfiles/rails_7.1.0.alpha.gemfile.lock b/gemfiles/rails_7.1.0.alpha.gemfile.lock new file mode 100644 index 00000000..e3e26df4 --- /dev/null +++ b/gemfiles/rails_7.1.0.alpha.gemfile.lock @@ -0,0 +1,248 @@ +GIT + remote: https://github.com/rails/rails.git + revision: 5f3eb2195ba503919665028c01e4c76125e59fac + branch: main + specs: + actioncable (7.1.0.alpha) + actionpack (= 7.1.0.alpha) + activesupport (= 7.1.0.alpha) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + zeitwerk (~> 2.6) + actionmailbox (7.1.0.alpha) + actionpack (= 7.1.0.alpha) + activejob (= 7.1.0.alpha) + activerecord (= 7.1.0.alpha) + activestorage (= 7.1.0.alpha) + activesupport (= 7.1.0.alpha) + mail (>= 2.7.1) + net-imap + net-pop + net-smtp + actionmailer (7.1.0.alpha) + actionpack (= 7.1.0.alpha) + actionview (= 7.1.0.alpha) + activejob (= 7.1.0.alpha) + activesupport (= 7.1.0.alpha) + mail (~> 2.5, >= 2.5.4) + net-imap + net-pop + net-smtp + rails-dom-testing (~> 2.0) + actionpack (7.1.0.alpha) + actionview (= 7.1.0.alpha) + activesupport (= 7.1.0.alpha) + nokogiri (>= 1.8.5) + rack (>= 2.2.4) + rack-session (>= 1.0.1) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.6) + actiontext (7.1.0.alpha) + actionpack (= 7.1.0.alpha) + activerecord (= 7.1.0.alpha) + activestorage (= 7.1.0.alpha) + activesupport (= 7.1.0.alpha) + globalid (>= 0.6.0) + nokogiri (>= 1.8.5) + actionview (7.1.0.alpha) + activesupport (= 7.1.0.alpha) + builder (~> 3.1) + erubi (~> 1.11) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.6) + activejob (7.1.0.alpha) + activesupport (= 7.1.0.alpha) + globalid (>= 0.3.6) + activemodel (7.1.0.alpha) + activesupport (= 7.1.0.alpha) + activerecord (7.1.0.alpha) + activemodel (= 7.1.0.alpha) + activesupport (= 7.1.0.alpha) + timeout (>= 0.4.0) + activestorage (7.1.0.alpha) + actionpack (= 7.1.0.alpha) + activejob (= 7.1.0.alpha) + activerecord (= 7.1.0.alpha) + activesupport (= 7.1.0.alpha) + marcel (~> 1.0) + activesupport (7.1.0.alpha) + concurrent-ruby (~> 1.0, >= 1.0.2) + connection_pool (>= 2.2.5) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + rails (7.1.0.alpha) + actioncable (= 7.1.0.alpha) + actionmailbox (= 7.1.0.alpha) + actionmailer (= 7.1.0.alpha) + actionpack (= 7.1.0.alpha) + actiontext (= 7.1.0.alpha) + actionview (= 7.1.0.alpha) + activejob (= 7.1.0.alpha) + activemodel (= 7.1.0.alpha) + activerecord (= 7.1.0.alpha) + activestorage (= 7.1.0.alpha) + activesupport (= 7.1.0.alpha) + bundler (>= 1.15.0) + railties (= 7.1.0.alpha) + railties (7.1.0.alpha) + actionpack (= 7.1.0.alpha) + activesupport (= 7.1.0.alpha) + irb + rackup (>= 1.0.0) + rake (>= 12.2) + thor (~> 1.0, >= 1.2.2) + zeitwerk (~> 2.6) + +PATH + remote: .. + specs: + data_migrate (9.1.0) + activerecord (>= 6.1) + railties (>= 6.1) + +GEM + remote: http://rubygems.org/ + specs: + appraisal (2.5.0) + bundler + rake + thor (>= 0.14.0) + ast (2.4.2) + builder (3.2.4) + childprocess (4.1.0) + coderay (1.1.3) + concurrent-ruby (1.2.2) + connection_pool (2.4.1) + crass (1.0.6) + date (3.3.3) + diff-lcs (1.5.0) + erubi (1.12.0) + globalid (1.1.0) + activesupport (>= 5.0) + i18n (1.14.1) + concurrent-ruby (~> 1.0) + iniparse (1.5.0) + io-console (0.6.0) + irb (1.7.4) + reline (>= 0.3.6) + json (2.6.3) + language_server-protocol (3.17.0.3) + loofah (2.21.3) + crass (~> 1.0.2) + nokogiri (>= 1.12.0) + mail (2.8.1) + mini_mime (>= 0.1.1) + net-imap + net-pop + net-smtp + marcel (1.0.2) + method_source (1.0.0) + mini_mime (1.1.2) + minitest (5.18.1) + net-imap (0.3.6) + date + net-protocol + net-pop (0.1.2) + net-protocol + net-protocol (0.2.1) + timeout + net-smtp (0.3.3) + net-protocol + nio4r (2.5.9) + nokogiri (1.15.3-arm64-darwin) + racc (~> 1.4) + overcommit (0.60.0) + childprocess (>= 0.6.3, < 5) + iniparse (~> 1.4) + rexml (~> 3.2) + parallel (1.23.0) + parser (3.2.2.3) + ast (~> 2.4.1) + racc + pry (0.14.2) + coderay (~> 1.1) + method_source (~> 1.0) + racc (1.7.1) + rack (3.0.8) + rack-session (2.0.0) + rack (>= 3.0.0) + rack-test (2.1.0) + rack (>= 1.3) + rackup (2.1.0) + rack (>= 3) + webrick (~> 1.8) + rails-dom-testing (2.1.1) + activesupport (>= 5.0.0) + minitest + nokogiri (>= 1.6) + rails-html-sanitizer (1.6.0) + loofah (~> 2.21) + nokogiri (~> 1.14) + rainbow (3.1.1) + rake (13.0.6) + rb-readline (0.5.5) + regexp_parser (2.8.1) + reline (0.3.6) + io-console (~> 0.5) + rexml (3.2.5) + rspec (3.12.0) + rspec-core (~> 3.12.0) + rspec-expectations (~> 3.12.0) + rspec-mocks (~> 3.12.0) + rspec-core (3.12.2) + rspec-support (~> 3.12.0) + rspec-expectations (3.12.3) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.12.0) + rspec-mocks (3.12.6) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.12.0) + rspec-support (3.12.1) + rubocop (1.54.2) + json (~> 2.3) + language_server-protocol (>= 3.17.0) + parallel (~> 1.10) + parser (>= 3.2.2.3) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.8, < 3.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.28.0, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.29.0) + parser (>= 3.2.1.0) + ruby-progressbar (1.13.0) + sqlite3 (1.6.3-arm64-darwin) + thor (1.2.2) + timecop (0.9.6) + timeout (0.4.0) + tzinfo (2.0.6) + concurrent-ruby (~> 1.0) + unicode-display_width (2.4.2) + webrick (1.8.1) + websocket-driver (0.7.5) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + zeitwerk (2.6.8) + +PLATFORMS + arm64-darwin-22 + +DEPENDENCIES + appraisal + data_migrate! + overcommit + pry + rails! + rake + rb-readline + rspec + rspec-core + rubocop + sqlite3 (~> 1.4) + timecop + +BUNDLED WITH + 2.4.17 From f747d5067dc6a27b05a6ef5332ba7185bf14853e Mon Sep 17 00:00:00 2001 From: Maple Ong Date: Thu, 27 Jul 2023 15:36:25 -0400 Subject: [PATCH 40/98] Introduce rails helper for varying rails versions --- lib/data_migrate.rb | 1 + lib/data_migrate/rails_helper.rb | 71 ++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 lib/data_migrate/rails_helper.rb diff --git a/lib/data_migrate.rb b/lib/data_migrate.rb index d78eed37..a8368812 100644 --- a/lib/data_migrate.rb +++ b/lib/data_migrate.rb @@ -1,5 +1,6 @@ # frozen_string_literal: true +require File.join(File.dirname(__FILE__), "data_migrate", "rails_helper") require File.join(File.dirname(__FILE__), "data_migrate", "data_migrator") require File.join(File.dirname(__FILE__), "data_migrate", "data_schema_migration") require File.join(File.dirname(__FILE__), "data_migrate", "data_schema") diff --git a/lib/data_migrate/rails_helper.rb b/lib/data_migrate/rails_helper.rb new file mode 100644 index 00000000..470f308e --- /dev/null +++ b/lib/data_migrate/rails_helper.rb @@ -0,0 +1,71 @@ +module DataMigrate + class DataMigrate::RailsHelper + class << self + def rails_version_equal_to_or_higher_than_7_1 + @equal_to_or_higher_than_7_1 ||= Gem::Dependency.new("railties", ">= 7.1.0.alpha").match?("railties", Gem.loaded_specs["railties"].version) + end + + def internal_metadata + if rails_version_equal_to_or_higher_than_7_1 + ActiveRecord::Base.connection.internal_metadata + else + ActiveRecord::InternalMetadata + end + end + + def schema_migration + if rails_version_equal_to_or_higher_than_7_1 + ActiveRecord::Base.connection.schema_migration + else + ActiveRecord::SchemaMigration + end + end + + def schema_migration_versions + if rails_version_equal_to_or_higher_than_7_1 + schema_migration.versions + else + schema_migration.all.pluck(:version) + end + end + + def schema_create_version(version) + if rails_version_equal_to_or_higher_than_7_1 + schema_migration.create_version(version) + else + schema_migration.create(version: version) + end + end + + def data_schema_delete_version(version) + if rails_version_equal_to_or_higher_than_7_1 + data_schema_migration.delete_version(version) + else + data_schema_migration.where(version: version.to_s).delete_all + end + end + + def data_schema_migration + if rails_version_equal_to_or_higher_than_7_1 + DataMigrate::DataSchemaMigration.new(ActiveRecord::Tasks::DatabaseTasks.migration_connection) + else + DataMigrate::DataSchemaMigration + end + end + + def data_migrator( + direction, + migrations, + schema_migration = DataMigrate::RailsHelper.schema_migration, + internal_metadata = DataMigrate::RailsHelper.internal_metadata, + target_version = nil + ) + if rails_version_equal_to_or_higher_than_7_1 + DataMigrate::DataMigrator.new(direction, migrations, schema_migration, internal_metadata, target_version) + else + DataMigrate::DataMigrator.new(direction, migrations, schema_migration, target_version) + end + end + end + end +end From 04d7ed7b7c68a1847c22130591e27c8f46a5cb67 Mon Sep 17 00:00:00 2001 From: Maple Ong Date: Thu, 27 Jul 2023 15:37:01 -0400 Subject: [PATCH 41/98] Remove legacy migrator --- lib/data_migrate.rb | 1 - lib/data_migrate/legacy_migrator.rb | 22 ------------- spec/data_migrate/legacy_migrator_spec.rb | 38 ----------------------- 3 files changed, 61 deletions(-) delete mode 100644 lib/data_migrate/legacy_migrator.rb delete mode 100644 spec/data_migrate/legacy_migrator_spec.rb diff --git a/lib/data_migrate.rb b/lib/data_migrate.rb index a8368812..18705c2d 100644 --- a/lib/data_migrate.rb +++ b/lib/data_migrate.rb @@ -10,7 +10,6 @@ require File.join(File.dirname(__FILE__), "data_migrate", "migration_context") require File.join(File.dirname(__FILE__), "data_migrate", "railtie") require File.join(File.dirname(__FILE__), "data_migrate", "tasks/data_migrate_tasks") -require File.join(File.dirname(__FILE__), "data_migrate", "legacy_migrator") require File.join(File.dirname(__FILE__), "data_migrate", "config") require File.join(File.dirname(__FILE__), "data_migrate", "schema_migration") diff --git a/lib/data_migrate/legacy_migrator.rb b/lib/data_migrate/legacy_migrator.rb deleted file mode 100644 index b1f4ba56..00000000 --- a/lib/data_migrate/legacy_migrator.rb +++ /dev/null @@ -1,22 +0,0 @@ -module DataMigrate - class LegacyMigrator - def initialize(migrations_paths = "db/data") - @migrations_paths = migrations_paths || "db/data" - end - - def migrate - dates = - DataMigrate::DataMigrator.migrations(@migrations_paths).collect(&:version) - legacy = ActiveRecord::SchemaMigration.where(version: dates) - legacy.each do |v| - begin - version = v.version - puts "Creating #{version} in data schema" - DataMigrate::DataSchemaMigration.create(version: version) - rescue ActiveRecord::RecordNotUnique - nil - end - end - end - end -end diff --git a/spec/data_migrate/legacy_migrator_spec.rb b/spec/data_migrate/legacy_migrator_spec.rb deleted file mode 100644 index b9d4ee59..00000000 --- a/spec/data_migrate/legacy_migrator_spec.rb +++ /dev/null @@ -1,38 +0,0 @@ -# frozen_string_literal: true - -require "spec_helper" - -describe DataMigrate::LegacyMigrator do - let(:context) { - DataMigrate::MigrationContext.new("spec/db/data") - } - - before do - ActiveRecord::SchemaMigration.create_table - DataMigrate::DataSchemaMigration.create_table - end - - after do - ActiveRecord::Migration.drop_table("data_migrations") rescue nil - ActiveRecord::Migration.drop_table("schema_migrations") rescue nil - end - - it "migrate legacy migrations to be in correct table" do - # simulate creation of legacy data migration when - # it was recorded in schema table - ActiveRecord::SchemaMigration.create(version: "20091231235959") - - # create one migration in correct place - DataMigrate::DataSchemaMigration.create(version: "20171231235959") - - migrated = DataMigrate::DataMigrator.new(:up, []).load_migrated - expect(migrated.count).to eq 1 - - DataMigrate::LegacyMigrator.new("spec/db/data").migrate - - # after migacy migrator has been run, we should have records - # of both migrations - migrated = DataMigrate::DataMigrator .new(:up, []).load_migrated - expect(migrated.count).to eq 2 - end -end From de4d5dced0a87f4a8f65cfdc252b05235088a626 Mon Sep 17 00:00:00 2001 From: Maple Ong Date: Thu, 27 Jul 2023 15:37:21 -0400 Subject: [PATCH 42/98] Support rails 7.1 --- lib/data_migrate/data_migrator.rb | 34 ++++++------------- lib/data_migrate/data_schema.rb | 2 +- lib/data_migrate/data_schema_migration.rb | 20 ++++++++++- lib/data_migrate/database_tasks.rb | 10 +++--- lib/data_migrate/migration_context.rb | 19 ++++++----- lib/data_migrate/schema_dumper.rb | 2 +- lib/data_migrate/schema_migration.rb | 7 ++-- lib/data_migrate/status_service.rb | 4 +-- lib/data_migrate/tasks/data_migrate_tasks.rb | 4 +-- spec/data_migrate/data_migrator_spec.rb | 29 +++++++++------- .../data_schema_migration_spec.rb | 33 +++++++++++++----- spec/data_migrate/data_spec.rb | 2 +- spec/data_migrate/database_tasks_spec.rb | 27 +++++++++------ spec/data_migrate/migration_context_spec.rb | 23 ++++++++----- spec/data_migrate/schema_dumper_spec.rb | 9 +++-- spec/data_migrate/schema_migration_spec.rb | 17 +++++++--- spec/data_migrate/status_service_spec.rb | 9 +++-- .../tasks/data_migrate_tasks_spec.rb | 16 ++++----- 18 files changed, 163 insertions(+), 104 deletions(-) diff --git a/lib/data_migrate/data_migrator.rb b/lib/data_migrate/data_migrator.rb index 78cfe86e..300cde73 100644 --- a/lib/data_migrate/data_migrator.rb +++ b/lib/data_migrate/data_migrator.rb @@ -5,32 +5,20 @@ module DataMigrate class DataMigrator < ActiveRecord::Migrator - def self.migrations_paths - [DataMigrate.config.data_migrations_path] - end - - def self.create_data_schema_table - DataMigrate::DataSchemaMigration.create_table - end - - def initialize(direction, migrations, target_version = nil) - @direction = direction - @target_version = target_version - @migrated_versions = nil - @migrations = migrations - - validate(@migrations) - - DataMigrate::DataSchemaMigration.create_table - ActiveRecord::InternalMetadata.create_table - end - def load_migrated @migrated_versions = - DataMigrate::DataSchemaMigration.normalized_versions.map(&:to_i).sort + DataMigrate::RailsHelper.data_schema_migration.normalized_versions.map(&:to_i).sort end class << self + def migrations_paths + [DataMigrate.config.data_migrations_path] + end + + def create_data_schema_table + DataMigrate::RailsHelper.data_schema_migration.create_table + end + def current_version DataMigrate::MigrationContext.new(migrations_paths).current_version end @@ -79,10 +67,10 @@ def rollback(migrations_path, steps) def record_version_state_after_migrating(version) if down? migrated.delete(version) - DataMigrate::DataSchemaMigration.where(version: version.to_s).delete_all + DataMigrate::RailsHelper.data_schema_delete_version(version.to_s) else migrated << version - DataMigrate::DataSchemaMigration.create!(version: version.to_s) + DataMigrate::RailsHelper.data_schema_migration.create_version(version.to_s) end end end diff --git a/lib/data_migrate/data_schema.rb b/lib/data_migrate/data_schema.rb index 07e9fb78..a77bd56a 100644 --- a/lib/data_migrate/data_schema.rb +++ b/lib/data_migrate/data_schema.rb @@ -57,7 +57,7 @@ def sm_table end def table_name - DataMigrate::DataSchemaMigration.table_name + DataMigrate::RailsHelper.data_schema_migration.table_name end end end diff --git a/lib/data_migrate/data_schema_migration.rb b/lib/data_migrate/data_schema_migration.rb index c04c470e..0fb72ece 100644 --- a/lib/data_migrate/data_schema_migration.rb +++ b/lib/data_migrate/data_schema_migration.rb @@ -1,6 +1,8 @@ module DataMigrate class DataSchemaMigration < ActiveRecord::SchemaMigration - class << self + # In Rails 7.1+, ActiveRecord::SchemaMigration methods are instance methods + # So we only load the appropriate methods depending on Rails version. + if DataMigrate::RailsHelper.rails_version_equal_to_or_higher_than_7_1 def table_name ActiveRecord::Base.table_name_prefix + 'data_migrations' + ActiveRecord::Base.table_name_suffix end @@ -8,6 +10,22 @@ def table_name def primary_key "version" end + else + class << self + def table_name + ActiveRecord::Base.table_name_prefix + 'data_migrations' + ActiveRecord::Base.table_name_suffix + end + + def primary_key + "version" + end + + def create_version(version) + # Note that SchemaMigration.create_version in Rails 7.1 does not + # raise an error if validations fail but we retain this behaviour for now. + create!(version: version) + end + end end end end diff --git a/lib/data_migrate/database_tasks.rb b/lib/data_migrate/database_tasks.rb index ee96a7d6..9bf93071 100644 --- a/lib/data_migrate/database_tasks.rb +++ b/lib/data_migrate/database_tasks.rb @@ -100,8 +100,10 @@ def self.forward(step = 1) def self.pending_data_migrations data_migrations = DataMigrate::DataMigrator.migrations(data_migrations_path) - sort_migrations(DataMigrate::DataMigrator.new(:up, data_migrations ). - pending_migrations.map {|m| { version: m.version, name: m.name, kind: :data }}) + data_migrator = DataMigrate::RailsHelper.data_migrator(:up, data_migrations) + sort_migrations( + data_migrator.pending_migrations.map { |m| { version: m.version, name: m.name, kind: :data } } + ) end def self.pending_schema_migrations @@ -109,8 +111,8 @@ def self.pending_schema_migrations end def self.past_migrations(sort = nil) - data_versions = DataMigrate::DataSchemaMigration.table_exists? ? DataMigrate::DataSchemaMigration.normalized_versions : [] - schema_versions = ActiveRecord::SchemaMigration.normalized_versions + data_versions = DataMigrate::RailsHelper.data_schema_migration.table_exists? ? DataMigrate::RailsHelper.data_schema_migration.normalized_versions : [] + schema_versions = DataMigrate::RailsHelper.schema_migration.normalized_versions migrations = data_versions.map { |v| { version: v.to_i, kind: :data } } + schema_versions.map { |v| { version: v.to_i, kind: :schema } } sort&.downcase == "asc" ? sort_migrations(migrations) : sort_migrations(migrations).reverse diff --git a/lib/data_migrate/migration_context.rb b/lib/data_migrate/migration_context.rb index 48d2bbbb..cf6aeda8 100644 --- a/lib/data_migrate/migration_context.rb +++ b/lib/data_migrate/migration_context.rb @@ -11,7 +11,8 @@ def up(target_version = nil) migrations end - DataMigrator.new(:up, selected_migrations, target_version).migrate + data_migrator = DataMigrate::RailsHelper.data_migrator(:up, selected_migrations, DataMigrate::RailsHelper.schema_migration, DataMigrate::RailsHelper.internal_metadata, target_version) + data_migrator.migrate end def down(target_version = nil) @@ -22,11 +23,13 @@ def down(target_version = nil) migrations end - DataMigrator.new(:down, selected_migrations, target_version).migrate + data_migrator = DataMigrate::RailsHelper.data_migrator(:down, selected_migrations, DataMigrate::RailsHelper.schema_migration, DataMigrate::RailsHelper.internal_metadata, target_version) + data_migrator.migrate end def run(direction, target_version) - DataMigrator.new(direction, migrations, target_version).run + data_migrator = DataMigrate::RailsHelper.data_migrator(direction, migrations, DataMigrate::RailsHelper.schema_migration, DataMigrate::RailsHelper.internal_metadata, target_version) + data_migrator.run end def current_version @@ -40,12 +43,12 @@ def migration_files end def migrations_status - db_list = DataSchemaMigration.normalized_versions + db_list = DataMigrate::RailsHelper.data_schema_migration.normalized_versions file_list = migration_files.map do |file| version, name, scope = parse_migration_filename(file) raise ActiveRecord::IllegalMigrationNameError.new(file) unless version - version = ActiveRecord::SchemaMigration.normalize_migration_number(version) + version = DataMigrate::RailsHelper.schema_migration.normalize_migration_number(version) status = db_list.delete(version) ? "up" : "down" [status, version, (name + scope).humanize] end.compact @@ -60,15 +63,15 @@ def migrations_status private def get_all_versions - if DataMigrate::DataSchemaMigration.table_exists? - DataSchemaMigration.normalized_versions.map(&:to_i) + if DataMigrate::RailsHelper.data_schema_migration.table_exists? + DataMigrate::RailsHelper.data_schema_migration.normalized_versions.map(&:to_i) else [] end end def move(direction, steps) - migrator = DataMigrator.new(direction, migrations) + migrator = DataMigrate::RailsHelper.data_migrator(direction, migrations) if current_version != 0 && !migrator.current_migration raise ActiveRecord::UnknownMigrationVersionError.new(current_version) diff --git a/lib/data_migrate/schema_dumper.rb b/lib/data_migrate/schema_dumper.rb index 8692a301..cd56cce3 100644 --- a/lib/data_migrate/schema_dumper.rb +++ b/lib/data_migrate/schema_dumper.rb @@ -26,7 +26,7 @@ def dump(stream) def initialize(connection) @connection = connection - all_versions = DataSchemaMigration.normalized_versions + all_versions = DataMigrate::RailsHelper.data_schema_migration.normalized_versions @version = begin all_versions.max diff --git a/lib/data_migrate/schema_migration.rb b/lib/data_migrate/schema_migration.rb index f93c0b16..ed461324 100644 --- a/lib/data_migrate/schema_migration.rb +++ b/lib/data_migrate/schema_migration.rb @@ -7,14 +7,14 @@ class SchemaMigration def self.pending_schema_migrations all_migrations = DataMigrate::MigrationContext.new(migrations_paths).migrations sort_migrations( - ActiveRecord::Migrator.new(:up, all_migrations, ActiveRecord::Base.connection.schema_migration). + ActiveRecord::Migrator.new(:up, all_migrations, DataMigrate::RailsHelper.schema_migration, DataMigrate::RailsHelper.internal_metadata). pending_migrations. map {|m| { version: m.version, kind: :schema }} ) end def self.run(direction, migration_paths, version) - ActiveRecord::MigrationContext.new(migration_paths, ActiveRecord::Base.connection.schema_migration).run(direction, version) + ActiveRecord::MigrationContext.new(migration_paths, DataMigrate::RailsHelper.schema_migration).run(direction, version) end def self.sort_migrations(set1, set2 = nil) @@ -24,7 +24,8 @@ def self.sort_migrations(set1, set2 = nil) def self.migrations_paths spec_name = DataMigrate.config.spec_name - if spec_name && Gem::Dependency.new("railties", "~> 7.0").match?("railties", Gem.loaded_specs["railties"].version) + # The positional argument true is to include pre-release versions, such as 7.1.0.alpha + if spec_name && Gem::Dependency.new("railties", ">= 7.0").match?("railties", Gem.loaded_specs["railties"].version, true) ActiveRecord::Base.configurations.configs_for(env_name: Rails.env, name: spec_name).migrations_paths elsif spec_name && Gem::Dependency.new("railties", "~> 6.1").match?("railties", Gem.loaded_specs["railties"].version) ActiveRecord::Base.configurations.configs_for(env_name: Rails.env, spec_name: spec_name).migrations_paths diff --git a/lib/data_migrate/status_service.rb b/lib/data_migrate/status_service.rb index 6ca148c8..2703eabc 100644 --- a/lib/data_migrate/status_service.rb +++ b/lib/data_migrate/status_service.rb @@ -24,11 +24,11 @@ def dump(stream) private def table_name - DataMigrate::DataSchemaMigration.table_name + DataMigrate::RailsHelper.data_schema_migration.table_name end def output(stream) - unless DataMigrate::DataSchemaMigration.table_exists? + unless DataMigrate::RailsHelper.data_schema_migration.table_exists? stream.puts "Data migrations table does not exist yet." return end diff --git a/lib/data_migrate/tasks/data_migrate_tasks.rb b/lib/data_migrate/tasks/data_migrate_tasks.rb index 1c97bdf8..9143610e 100644 --- a/lib/data_migrate/tasks/data_migrate_tasks.rb +++ b/lib/data_migrate/tasks/data_migrate_tasks.rb @@ -50,9 +50,9 @@ def status def status_with_schema db_list_data = ActiveRecord::Base.connection.select_values( - "SELECT version FROM #{DataMigrate::DataSchemaMigration.table_name}" + "SELECT version FROM #{DataMigrate::RailsHelper.data_schema_migration.table_name}" ) - db_list_schema = ActiveRecord::SchemaMigration.all.pluck(:version) + db_list_schema = DataMigrate::RailsHelper.schema_migration_versions file_list = [] Dir.foreach(File.join(Rails.root, migrations_paths)) do |file| diff --git a/spec/data_migrate/data_migrator_spec.rb b/spec/data_migrate/data_migrator_spec.rb index 82d8a073..649e8d6f 100644 --- a/spec/data_migrate/data_migrator_spec.rb +++ b/spec/data_migrate/data_migrator_spec.rb @@ -3,7 +3,8 @@ require "spec_helper" describe DataMigrate::DataMigrator do - let(:subject) { DataMigrate::DataMigrator } + let(:described_class) { DataMigrate::DataMigrator } + let(:db_config) do { adapter: "sqlite3", @@ -13,8 +14,8 @@ before do ActiveRecord::Base.establish_connection(db_config) - ::ActiveRecord::SchemaMigration.create_table - DataMigrate::DataSchemaMigration.create_table + DataMigrate::RailsHelper.schema_migration.create_table + DataMigrate::RailsHelper.data_schema_migration.create_table end after do @@ -23,12 +24,14 @@ end describe ".load_migrated" do + let(:migrator) { DataMigrate::RailsHelper.data_migrator(:up, []) } + it "loads migrated versions" do - DataMigrate::DataSchemaMigration.create(version: 20090000000000) - ::ActiveRecord::SchemaMigration.create(version: 20100000000000) - DataMigrate::DataSchemaMigration.create(version: 20110000000000) - ::ActiveRecord::SchemaMigration.create(version: 20120000000000) - migrated = subject.new(:up, []).load_migrated + DataMigrate::RailsHelper.data_schema_migration.create_version(20090000000000) + DataMigrate::RailsHelper.schema_create_version(20100000000000) + DataMigrate::RailsHelper.data_schema_migration.create_version(20110000000000) + DataMigrate::RailsHelper.schema_create_version(20120000000000) + migrated = migrator.load_migrated expect(migrated.count).to eq 2 expect(migrated).to include 20090000000000 expect(migrated).to include 20110000000000 @@ -38,7 +41,7 @@ describe :create_data_schema_table do it "creates the data_migrations table" do ActiveRecord::Migration.drop_table("data_migrations") rescue nil - subject.create_data_schema_table + described_class.create_data_schema_table expect( ActiveRecord::Base.connection.table_exists?("data_migrations") ).to eq true @@ -47,7 +50,7 @@ describe "#migrations_status" do it "returns all migrations statuses" do - status = subject.migrations_status + status = described_class.migrations_status expect(status.length).to eq 2 expect(status.first).to eq ["down", "20091231235959", "Some name"] expect(status.second).to eq ["down", "20171231235959", "Super update"] @@ -57,19 +60,19 @@ describe :match do context "when the file does not match" do it "returns nil" do - expect(subject.match("not_a_data_migration_file")).to be_nil + expect(described_class.match("not_a_data_migration_file")).to be_nil end end context "when the file doesn't end in .rb" do it "returns nil" do - expect(subject.match("20091231235959_some_name.rb.un~")).to be_nil + expect(described_class.match("20091231235959_some_name.rb.un~")).to be_nil end end context "when the file matches" do it "returns a valid MatchData object" do - match_data = subject.match("20091231235959_some_name.rb") + match_data = described_class.match("20091231235959_some_name.rb") expect(match_data[0]).to eq "20091231235959_some_name.rb" expect(match_data[1]).to eq "20091231235959" diff --git a/spec/data_migrate/data_schema_migration_spec.rb b/spec/data_migrate/data_schema_migration_spec.rb index f7133b78..5a6cc362 100644 --- a/spec/data_migrate/data_schema_migration_spec.rb +++ b/spec/data_migrate/data_schema_migration_spec.rb @@ -1,16 +1,33 @@ require 'spec_helper' describe DataMigrate::DataSchemaMigration do - let(:subject) { DataMigrate::DataSchemaMigration } - describe :table_name do - it "returns correct table name" do - expect(subject.table_name).to eq("data_migrations") + if DataMigrate::RailsHelper.rails_version_equal_to_or_higher_than_7_1 + let(:connection) { double(:connection) } + let(:subject) { DataMigrate::DataSchemaMigration.new(connection) } + + describe :table_name do + it "returns correct table name" do + expect(subject.table_name).to eq("data_migrations") + end + end + + describe :index_name do + it "returns correct primary key name" do + expect(subject.primary_key).to eq("version") + end + end + else + let(:subject) { DataMigrate::DataSchemaMigration } + describe :table_name do + it "returns correct table name" do + expect(subject.table_name).to eq("data_migrations") + end end - end - describe :index_name do - it "returns correct primary key name" do - expect(subject.primary_key).to eq("version") + describe :index_name do + it "returns correct primary key name" do + expect(subject.primary_key).to eq("version") + end end end end diff --git a/spec/data_migrate/data_spec.rb b/spec/data_migrate/data_spec.rb index f1416f27..1763bc6e 100644 --- a/spec/data_migrate/data_spec.rb +++ b/spec/data_migrate/data_spec.rb @@ -55,7 +55,7 @@ sql_select = <<-SQL SELECT version - FROM #{DataMigrate::DataSchemaMigration.table_name} + FROM #{DataMigrate::RailsHelper.data_schema_migration.table_name} SQL db_list_data = ActiveRecord::Base.connection. diff --git a/spec/data_migrate/database_tasks_spec.rb b/spec/data_migrate/database_tasks_spec.rb index 77afc946..2c62d46d 100644 --- a/spec/data_migrate/database_tasks_spec.rb +++ b/spec/data_migrate/database_tasks_spec.rb @@ -28,13 +28,18 @@ data_migrations_path } ActiveRecord::Base.establish_connection(db_config) - if Gem::Dependency.new("railties", ">= 6.1").match?("railties", Gem.loaded_specs["railties"].version) - hash_config = ActiveRecord::DatabaseConfigurations::HashConfig.new('test', 'test', db_config) - config_obj = ActiveRecord::DatabaseConfigurations.new([hash_config]) - allow(ActiveRecord::Base).to receive(:configurations).and_return(config_obj) - else - ActiveRecord::Base.configurations[:test] = db_config - end + # if Gem::Dependency.new("railties", ">= 6.1").match?("railties", Gem.loaded_specs["railties"].version) + # hash_config = ActiveRecord::DatabaseConfigurations::HashConfig.new('test', 'test', db_config) + # config_obj = ActiveRecord::DatabaseConfigurations.new([hash_config]) + # allow(ActiveRecord::Base).to receive(:configurations).and_return(config_obj) + # else + # ActiveRecord::Base.configurations[:test] = db_config + # end + + hash_config = ActiveRecord::DatabaseConfigurations::HashConfig.new('test', 'test', db_config) + config_obj = ActiveRecord::DatabaseConfigurations.new([hash_config]) + allow(ActiveRecord::Base).to receive(:configurations).and_return(config_obj) + end context "migrations" do @@ -44,7 +49,7 @@ end before do - ActiveRecord::SchemaMigration.create_table + DataMigrate::RailsHelper.schema_migration.create_table allow(DataMigrate::SchemaMigration).to receive(:migrations_paths) { migration_path @@ -72,16 +77,16 @@ it "run forward default amount of times" do subject.forward - versions = DataMigrate::DataSchemaMigration.normalized_versions + versions = DataMigrate::RailsHelper.data_schema_migration.normalized_versions expect(versions.count).to eq(1) end it "run forward defined number of times" do subject.forward(2) - versions = DataMigrate::DataSchemaMigration.normalized_versions + versions = DataMigrate::RailsHelper.data_schema_migration.normalized_versions expect(versions.count).to eq(1) expect(versions.first).to eq "20091231235959" - versions = ActiveRecord::SchemaMigration.normalized_versions + versions = DataMigrate::RailsHelper.schema_migration.normalized_versions expect(versions.count).to eq(1) expect(versions.first).to eq "20131111111111" end diff --git a/spec/data_migrate/migration_context_spec.rb b/spec/data_migrate/migration_context_spec.rb index 182948fb..c80155d4 100644 --- a/spec/data_migrate/migration_context_spec.rb +++ b/spec/data_migrate/migration_context_spec.rb @@ -5,10 +5,17 @@ describe DataMigrate::DataMigrator do let(:context) { DataMigrate::MigrationContext.new("spec/db/data") } let(:schema_context) { ActiveRecord::MigrationContext.new("spec/db/migrate", ActiveRecord::Base.connection.schema_migration) } + let(:db_config) do + { + adapter: "sqlite3", + database: "spec/db/test.db" + } + end before do - ActiveRecord::SchemaMigration.create_table - DataMigrate::DataSchemaMigration.create_table + ActiveRecord::Base.establish_connection(db_config) + DataMigrate::RailsHelper.schema_migration.create_table + DataMigrate::RailsHelper.data_schema_migration.create_table end after do @@ -20,7 +27,7 @@ it "migrates existing file" do context.migrate(nil) context.migrations_status - versions = DataMigrate::DataSchemaMigration.normalized_versions + versions = DataMigrate::RailsHelper.data_schema_migration.normalized_versions expect(versions.count).to eq(2) expect(versions).to include("20091231235959") expect(versions).to include("20171231235959") @@ -29,7 +36,7 @@ it "undo migration" do context.migrate(nil) context.run(:down, 20171231235959) - versions = DataMigrate::DataSchemaMigration.normalized_versions + versions = DataMigrate::RailsHelper.data_schema_migration.normalized_versions expect(versions.count).to eq(1) expect(versions).to include("20091231235959") end @@ -46,7 +53,7 @@ it "runs a specific migration" do context.run(:up, 20171231235959) - versions = DataMigrate::DataSchemaMigration.normalized_versions + versions = DataMigrate::RailsHelper.data_schema_migration.normalized_versions expect(versions.count).to eq(1) expect(versions).to include("20171231235959") end @@ -74,7 +81,7 @@ expect { context.rollback }.to output(/Undoing SuperUpdate/).to_stdout - versions = DataMigrate::DataSchemaMigration.normalized_versions + versions = DataMigrate::RailsHelper.data_schema_migration.normalized_versions expect(versions.count).to eq(1) expect(versions).to include("20091231235959") end @@ -85,7 +92,7 @@ expect { context.rollback(2) }.to output(/Undoing SomeName/).to_stdout - versions = DataMigrate::DataSchemaMigration.normalized_versions + versions = DataMigrate::RailsHelper.data_schema_migration.normalized_versions expect(versions.count).to eq(0) end @@ -94,7 +101,7 @@ expect { context.rollback(2) }.to output(/Undoing SomeName/).to_stdout - versions = DataMigrate::DataSchemaMigration.normalized_versions + versions = DataMigrate::RailsHelper.data_schema_migration.normalized_versions expect(versions.count).to eq(0) end end diff --git a/spec/data_migrate/schema_dumper_spec.rb b/spec/data_migrate/schema_dumper_spec.rb index 1d57588c..c91a4524 100644 --- a/spec/data_migrate/schema_dumper_spec.rb +++ b/spec/data_migrate/schema_dumper_spec.rb @@ -9,9 +9,12 @@ end before do - ActiveRecord::SchemaMigration.create_table - DataMigrate::DataSchemaMigration.create_table - DataMigrate::DataSchemaMigration.create(fixture_file_timestamps.map { |t| { version: t } }) + DataMigrate::RailsHelper.schema_migration.create_table + DataMigrate::RailsHelper.data_schema_migration.create_table + + fixture_file_timestamps.map do |t| + DataMigrate::RailsHelper.data_schema_migration.create_version(t) + end end after do diff --git a/spec/data_migrate/schema_migration_spec.rb b/spec/data_migrate/schema_migration_spec.rb index 6f73e221..c6428890 100644 --- a/spec/data_migrate/schema_migration_spec.rb +++ b/spec/data_migrate/schema_migration_spec.rb @@ -8,10 +8,17 @@ let(:fixture_file_timestamps) do %w[20091231235959 20101231235959 20111231235959] end + let(:db_config) do + { + adapter: "sqlite3", + database: "spec/db/test.db" + } + end before do - ActiveRecord::SchemaMigration.create_table - DataMigrate::DataSchemaMigration.create_table + ActiveRecord::Base.establish_connection(db_config) + DataMigrate::RailsHelper.schema_migration.create_table + DataMigrate::RailsHelper.data_schema_migration.create_table end after do @@ -38,7 +45,7 @@ expect { subject.run(:up, migration_path, 20202020202011) }.to output(/20202020202011 DbMigration: migrating/).to_stdout - versions = ActiveRecord::SchemaMigration.normalized_versions + versions = DataMigrate::RailsHelper.schema_migration.normalized_versions expect(versions.first).to eq("20202020202011") end @@ -49,7 +56,7 @@ subject.run(:down, migration_path, 20202020202011) }.to output(/Undoing DbMigration/).to_stdout - versions = ActiveRecord::SchemaMigration.normalized_versions + versions = DataMigrate::RailsHelper.schema_migration.normalized_versions expect(versions.count).to eq(0) end @@ -65,6 +72,8 @@ { env_name: Rails.env, spec_name: specification_name } elsif Gem::Dependency.new("railties", "~> 7.0").match?("railties", Gem.loaded_specs["railties"].version) { env_name: Rails.env, name: specification_name } + else + { env_name: Rails.env, name: specification_name } end end diff --git a/spec/data_migrate/status_service_spec.rb b/spec/data_migrate/status_service_spec.rb index ad610a89..18339680 100644 --- a/spec/data_migrate/status_service_spec.rb +++ b/spec/data_migrate/status_service_spec.rb @@ -33,9 +33,12 @@ end before do - ActiveRecord::SchemaMigration.create_table - DataMigrate::DataSchemaMigration.create_table - DataMigrate::DataSchemaMigration.create(fixture_file_timestamps.map { |t| { version: t } }) + DataMigrate::RailsHelper.schema_migration.create_table + DataMigrate::RailsHelper.data_schema_migration.create_table + + fixture_file_timestamps.map do |t| + DataMigrate::RailsHelper.data_schema_migration.create_version(t) + end subject.dump(connection_db_config, stream) stream.rewind diff --git a/spec/data_migrate/tasks/data_migrate_tasks_spec.rb b/spec/data_migrate/tasks/data_migrate_tasks_spec.rb index 50792d95..0323df05 100644 --- a/spec/data_migrate/tasks/data_migrate_tasks_spec.rb +++ b/spec/data_migrate/tasks/data_migrate_tasks_spec.rb @@ -3,17 +3,17 @@ require "spec_helper" describe DataMigrate::Tasks::DataMigrateTasks do - let(:connection_db_config) do - if Gem::Dependency.new("railties", ">= 6.1").match?("railties", Gem.loaded_specs["railties"].version) - ActiveRecord::Base.connection_db_config - else - ActiveRecord::Base.configurations.configs_for.first - end + let(:db_config) do + { + adapter: "sqlite3", + database: "spec/db/test.db" + } end before do - ActiveRecord::SchemaMigration.create_table - DataMigrate::DataSchemaMigration.create_table + ActiveRecord::Base.establish_connection(db_config) + DataMigrate::RailsHelper.schema_migration.create_table + DataMigrate::RailsHelper.data_schema_migration.create_table end after do From 8bd66ae03840c0dcfc053b0830c63784ce40f8e1 Mon Sep 17 00:00:00 2001 From: Maple Ong Date: Thu, 27 Jul 2023 15:50:40 -0400 Subject: [PATCH 43/98] Add to changelog --- Changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/Changelog.md b/Changelog.md index 1cf5a438..704dd79f 100644 --- a/Changelog.md +++ b/Changelog.md @@ -3,6 +3,7 @@ ## 11.0.0 - Commit *.lock files - Remove support for Rails 6.0 +- Support Rails 7.1 ## 9.1.0 From 803aecef3af7e96ef04c96958f3e472928c7d72b Mon Sep 17 00:00:00 2001 From: Maple Ong Date: Thu, 27 Jul 2023 15:51:00 -0400 Subject: [PATCH 44/98] Test rails-7.1.0.alpha on CI --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 404bd3ad..40b232ad 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,6 +17,7 @@ jobs: gemfile: - gemfiles/rails_6.1.gemfile - gemfiles/rails_7.0.gemfile + - gemfiles/rails_7.1.0.alpha.gemfile runs-on: ubuntu-latest env: BUNDLE_GEMFILE: ${{ matrix.gemfile }} From 4fd00c067d88554fa157354e5fa9bd1ed9187bfe Mon Sep 17 00:00:00 2001 From: Maple Ong Date: Thu, 27 Jul 2023 15:57:10 -0400 Subject: [PATCH 45/98] Add ci's platform to lockfile --- gemfiles/rails_7.1.0.alpha.gemfile.lock | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gemfiles/rails_7.1.0.alpha.gemfile.lock b/gemfiles/rails_7.1.0.alpha.gemfile.lock index e3e26df4..9b78be9c 100644 --- a/gemfiles/rails_7.1.0.alpha.gemfile.lock +++ b/gemfiles/rails_7.1.0.alpha.gemfile.lock @@ -153,6 +153,8 @@ GEM nio4r (2.5.9) nokogiri (1.15.3-arm64-darwin) racc (~> 1.4) + nokogiri (1.15.3-x86_64-linux) + racc (~> 1.4) overcommit (0.60.0) childprocess (>= 0.6.3, < 5) iniparse (~> 1.4) @@ -215,6 +217,7 @@ GEM parser (>= 3.2.1.0) ruby-progressbar (1.13.0) sqlite3 (1.6.3-arm64-darwin) + sqlite3 (1.6.3-x86_64-linux) thor (1.2.2) timecop (0.9.6) timeout (0.4.0) @@ -229,6 +232,7 @@ GEM PLATFORMS arm64-darwin-22 + x86_64-linux DEPENDENCIES appraisal From 7e698d21004ede01d9835cf1eb6017c0b0362d05 Mon Sep 17 00:00:00 2001 From: Maple Ong Date: Fri, 28 Jul 2023 11:37:39 -0400 Subject: [PATCH 46/98] Remove commented out code --- spec/data_migrate/database_tasks_spec.rb | 9 --------- 1 file changed, 9 deletions(-) diff --git a/spec/data_migrate/database_tasks_spec.rb b/spec/data_migrate/database_tasks_spec.rb index 2c62d46d..1e0406f1 100644 --- a/spec/data_migrate/database_tasks_spec.rb +++ b/spec/data_migrate/database_tasks_spec.rb @@ -28,18 +28,9 @@ data_migrations_path } ActiveRecord::Base.establish_connection(db_config) - # if Gem::Dependency.new("railties", ">= 6.1").match?("railties", Gem.loaded_specs["railties"].version) - # hash_config = ActiveRecord::DatabaseConfigurations::HashConfig.new('test', 'test', db_config) - # config_obj = ActiveRecord::DatabaseConfigurations.new([hash_config]) - # allow(ActiveRecord::Base).to receive(:configurations).and_return(config_obj) - # else - # ActiveRecord::Base.configurations[:test] = db_config - # end - hash_config = ActiveRecord::DatabaseConfigurations::HashConfig.new('test', 'test', db_config) config_obj = ActiveRecord::DatabaseConfigurations.new([hash_config]) allow(ActiveRecord::Base).to receive(:configurations).and_return(config_obj) - end context "migrations" do From 06a9605e17230df092215a00157f661b9e08db47 Mon Sep 17 00:00:00 2001 From: Maple Ong Date: Fri, 28 Jul 2023 11:39:03 -0400 Subject: [PATCH 47/98] Improve if condition --- spec/data_migrate/schema_migration_spec.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/spec/data_migrate/schema_migration_spec.rb b/spec/data_migrate/schema_migration_spec.rb index c6428890..989bd82e 100644 --- a/spec/data_migrate/schema_migration_spec.rb +++ b/spec/data_migrate/schema_migration_spec.rb @@ -70,8 +70,6 @@ let(:config_options) do if Gem::Dependency.new("railties", "~> 6.1").match?("railties", Gem.loaded_specs["railties"].version) { env_name: Rails.env, spec_name: specification_name } - elsif Gem::Dependency.new("railties", "~> 7.0").match?("railties", Gem.loaded_specs["railties"].version) - { env_name: Rails.env, name: specification_name } else { env_name: Rails.env, name: specification_name } end From 0209917a1385214e02665bd4e7d4205104a9799c Mon Sep 17 00:00:00 2001 From: Ngan Pham Date: Tue, 1 Aug 2023 11:59:34 -0700 Subject: [PATCH 48/98] Fix data:schema:load for structure.sql --- lib/data_migrate/database_tasks.rb | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/data_migrate/database_tasks.rb b/lib/data_migrate/database_tasks.rb index 9bf93071..07204e74 100644 --- a/lib/data_migrate/database_tasks.rb +++ b/lib/data_migrate/database_tasks.rb @@ -67,20 +67,35 @@ def run_migration(migration, direction) end end + alias_method :original_schema_dump_path, :schema_dump_path def schema_dump_path(db_config, format = ActiveRecord.schema_format) return ENV["DATA_SCHEMA"] if ENV["DATA_SCHEMA"] # We only require a schema.rb file for the primary database return unless db_config.primary? - super.gsub(/(_)?schema\.rb\z/, '\1data_schema.rb') + schema_to_data_schema_dump_paths.fetch(super) end # Override this method from `ActiveRecord::Tasks::DatabaseTasks` # to ensure that the sha saved in ar_internal_metadata table # is from the original schema.rb file def schema_sha1(file) - super(file.gsub(/data_schema.rb\z/, 'schema.rb')) + super(schema_to_data_schema_dump_paths.key(file)) + end + + private + + def schema_to_data_schema_dump_paths + @schema_to_data_schema_dump_paths ||= begin + ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env).each_with_object({}) do |config, mapping| + dump_path = original_schema_dump_path(config) + data_schema_dump_path = dump_path.gsub(/(_)?(schema\.rb|structure\.sql)\z/, '\1data_schema.rb') + mapping[dump_path] = data_schema_dump_path + end + end + puts @schema_to_data_schema_dump_paths.inspect + @schema_to_data_schema_dump_paths end end From fe600ddf38141f5bd4614bf501932daa2788975e Mon Sep 17 00:00:00 2001 From: Ngan Pham Date: Tue, 1 Aug 2023 12:38:44 -0700 Subject: [PATCH 49/98] Fix for Rails 6.1 --- lib/data_migrate/database_tasks.rb | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/data_migrate/database_tasks.rb b/lib/data_migrate/database_tasks.rb index 07204e74..fbd3c1f9 100644 --- a/lib/data_migrate/database_tasks.rb +++ b/lib/data_migrate/database_tasks.rb @@ -67,7 +67,6 @@ def run_migration(migration, direction) end end - alias_method :original_schema_dump_path, :schema_dump_path def schema_dump_path(db_config, format = ActiveRecord.schema_format) return ENV["DATA_SCHEMA"] if ENV["DATA_SCHEMA"] @@ -89,12 +88,17 @@ def schema_sha1(file) def schema_to_data_schema_dump_paths @schema_to_data_schema_dump_paths ||= begin ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env).each_with_object({}) do |config, mapping| - dump_path = original_schema_dump_path(config) - data_schema_dump_path = dump_path.gsub(/(_)?(schema\.rb|structure\.sql)\z/, '\1data_schema.rb') - mapping[dump_path] = data_schema_dump_path + dump_path = config.respond_to?(:schema_dump) ? config.schema_dump : ActiveRecord::Tasks::DatabaseTasks.dump_filename(db_config.name) + data_dump_name = File.basename(dump_path, File.extname(dump_path)) + + unless data_dump_name.gsub!(/(_)?(schema|structure)\z/, '\1data_schema') + data_dump_name.concat('_data_schema') + end + data_dump_name.concat('.rb') + + mapping[dump_path] = File.join(File.dirname(dump_path), data_dump_name) end end - puts @schema_to_data_schema_dump_paths.inspect @schema_to_data_schema_dump_paths end end From 41559a7af30c5dc323da4081d871dedd7a7e2cc4 Mon Sep 17 00:00:00 2001 From: Ngan Pham Date: Tue, 1 Aug 2023 12:58:22 -0700 Subject: [PATCH 50/98] More fixes --- lib/data_migrate/database_tasks.rb | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/data_migrate/database_tasks.rb b/lib/data_migrate/database_tasks.rb index fbd3c1f9..e4ac8be8 100644 --- a/lib/data_migrate/database_tasks.rb +++ b/lib/data_migrate/database_tasks.rb @@ -67,6 +67,11 @@ def run_migration(migration, direction) end end + # This method only exists in Rails 7.0+. + if method_defined?(:schema_dump_path) + alias_method :original_schema_dump_path, :schema_dump_path + end + def schema_dump_path(db_config, format = ActiveRecord.schema_format) return ENV["DATA_SCHEMA"] if ENV["DATA_SCHEMA"] @@ -87,18 +92,21 @@ def schema_sha1(file) def schema_to_data_schema_dump_paths @schema_to_data_schema_dump_paths ||= begin - ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env).each_with_object({}) do |config, mapping| - dump_path = config.respond_to?(:schema_dump) ? config.schema_dump : ActiveRecord::Tasks::DatabaseTasks.dump_filename(db_config.name) + ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env).each_with_object({}) do |db_config, mapping| + dump_path = respond_to?(:original_schema_dump_path) ? original_schema_dump_path(db_config) : ActiveRecord::Tasks::DatabaseTasks.dump_filename(db_config.name) + # As of Rails 7.0, `schema_dump` could return false for when schema dumping is not supported. + next unless dump_path + data_dump_name = File.basename(dump_path, File.extname(dump_path)) - unless data_dump_name.gsub!(/(_)?(schema|structure)\z/, '\1data_schema') - data_dump_name.concat('_data_schema') + unless data_dump_name.gsub!(/(_)?(schema|structure)\z/, "\\1#{schema_file_type}") + data_dump_name.concat("_#{schema_file_type}") end - data_dump_name.concat('.rb') mapping[dump_path] = File.join(File.dirname(dump_path), data_dump_name) end end + puts @schema_to_data_schema_dump_paths.inspect @schema_to_data_schema_dump_paths end end From d1eb1f0717bbebbc400e03a196a9af4d7fbdc053 Mon Sep 17 00:00:00 2001 From: Ngan Pham Date: Tue, 1 Aug 2023 12:58:42 -0700 Subject: [PATCH 51/98] Remove puts --- lib/data_migrate/database_tasks.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/data_migrate/database_tasks.rb b/lib/data_migrate/database_tasks.rb index e4ac8be8..4f5be47a 100644 --- a/lib/data_migrate/database_tasks.rb +++ b/lib/data_migrate/database_tasks.rb @@ -106,8 +106,6 @@ def schema_to_data_schema_dump_paths mapping[dump_path] = File.join(File.dirname(dump_path), data_dump_name) end end - puts @schema_to_data_schema_dump_paths.inspect - @schema_to_data_schema_dump_paths end end From b3f0ae823d91d1589bd88c04780e08373b7ecdc2 Mon Sep 17 00:00:00 2001 From: Maple Ong Date: Tue, 1 Aug 2023 19:08:18 -0400 Subject: [PATCH 52/98] Add tests for database tasks --- lib/data_migrate/database_tasks.rb | 1 + lib/data_migrate/rails_helper.rb | 6 ++- spec/data_migrate/database_tasks_spec.rb | 58 ++++++++++++++++++++---- 3 files changed, 55 insertions(+), 10 deletions(-) diff --git a/lib/data_migrate/database_tasks.rb b/lib/data_migrate/database_tasks.rb index 4f5be47a..2a67688c 100644 --- a/lib/data_migrate/database_tasks.rb +++ b/lib/data_migrate/database_tasks.rb @@ -17,6 +17,7 @@ def schema_file_type(_format = nil) "data_schema.rb" end + # This method is removed in Rails 7.0 def dump_filename(spec_name, format = ActiveRecord::Base.schema_format) filename = if spec_name == "primary" schema_file_type(format) diff --git a/lib/data_migrate/rails_helper.rb b/lib/data_migrate/rails_helper.rb index 470f308e..9ae9b409 100644 --- a/lib/data_migrate/rails_helper.rb +++ b/lib/data_migrate/rails_helper.rb @@ -1,10 +1,14 @@ module DataMigrate - class DataMigrate::RailsHelper + class RailsHelper class << self def rails_version_equal_to_or_higher_than_7_1 @equal_to_or_higher_than_7_1 ||= Gem::Dependency.new("railties", ">= 7.1.0.alpha").match?("railties", Gem.loaded_specs["railties"].version) end + def rails_version_equal_to_or_higher_than_7_0 + @rails_version_equal_to_or_higher_than_7_0 ||= Gem::Dependency.new("railties", ">= 7.0").match?("railties", Gem.loaded_specs["railties"].version) + end + def internal_metadata if rails_version_equal_to_or_higher_than_7_1 ActiveRecord::Base.connection.internal_metadata diff --git a/spec/data_migrate/database_tasks_spec.rb b/spec/data_migrate/database_tasks_spec.rb index 1e0406f1..9af7d242 100644 --- a/spec/data_migrate/database_tasks_spec.rb +++ b/spec/data_migrate/database_tasks_spec.rb @@ -8,12 +8,6 @@ let(:data_migrations_path) { DataMigrate.config.data_migrations_path } - let(:db_config) do - { - adapter: "sqlite3", - database: "spec/db/test.db" - } - end before do # In a normal Rails installation, db_dir would defer to @@ -27,8 +21,8 @@ allow(DataMigrate::Tasks::DataMigrateTasks).to receive(:migrations_paths) { data_migrations_path } - ActiveRecord::Base.establish_connection(db_config) - hash_config = ActiveRecord::DatabaseConfigurations::HashConfig.new('test', 'test', db_config) + ActiveRecord::Base.establish_connection({ adapter: "sqlite3", database: "spec/db/test.db" }) + hash_config = ActiveRecord::DatabaseConfigurations::HashConfig.new('test', 'test', { adapter: "sqlite3", database: "spec/db/test.db" }) config_obj = ActiveRecord::DatabaseConfigurations.new([hash_config]) allow(ActiveRecord::Base).to receive(:configurations).and_return(config_obj) end @@ -65,7 +59,6 @@ end describe :forward do - it "run forward default amount of times" do subject.forward versions = DataMigrate::RailsHelper.data_schema_migration.normalized_versions @@ -82,5 +75,52 @@ expect(versions.first).to eq "20131111111111" end end + + if DataMigrate::RailsHelper.rails_version_equal_to_or_higher_than_7_0 + describe :schema_dump_path do + before do + allow(ActiveRecord::Base).to receive(:configurations).and_return(ActiveRecord::DatabaseConfigurations.new([db_config])) + DataMigrate::DatabaseTasks.instance_variable_set(:@schema_to_data_schema_dump_paths, nil) + end + + context "with no custom schema dump path" do + let(:db_config) { ActiveRecord::DatabaseConfigurations::HashConfig.new("development", nil, {} ) } + + context "for :ruby db format" do + it 'returns the default data schema path' do + allow(ActiveRecord).to receive(:schema_format).and_return(:ruby) + expect(subject.schema_dump_path(db_config)).to eq "db/data_schema.rb" + end + end + + context "for :sql db format" do + it 'returns the default data schema path' do + allow(ActiveRecord).to receive(:schema_format).and_return(:sql) + expect(subject.schema_dump_path(db_config, :sql)).to eq "db/data_schema.rb" + end + end + end + + context "with custom schema dump path" do + context "for :ruby db format" do + let(:db_config) { ActiveRecord::DatabaseConfigurations::HashConfig.new("development", nil, { schema_dump: "payments_schema.rb" }) } + + it 'returns the default data schema path' do + allow(ActiveRecord).to receive(:schema_format).and_return(:ruby) + expect(subject.schema_dump_path(db_config)).to eq "db/payments_data_schema.rb" + end + end + + context "for :sql db format" do + let(:db_config) { ActiveRecord::DatabaseConfigurations::HashConfig.new("development", nil, { schema_dump: "payments_structure.sql" }) } + + it 'returns the default data schema path' do + allow(ActiveRecord).to receive(:schema_format).and_return(:sql) + expect(subject.schema_dump_path(db_config, :sql)).to eq "db/payments_data_schema.rb" + end + end + end + end + end end end From 884c5e1b7451f80571b9535ae16c835d5ef30c07 Mon Sep 17 00:00:00 2001 From: Ngan Pham Date: Wed, 2 Aug 2023 09:35:19 -0700 Subject: [PATCH 53/98] Simplify --- lib/data_migrate/database_tasks.rb | 29 ++---------------------- spec/data_migrate/database_tasks_spec.rb | 20 ---------------- 2 files changed, 2 insertions(+), 47 deletions(-) diff --git a/lib/data_migrate/database_tasks.rb b/lib/data_migrate/database_tasks.rb index 2a67688c..333f9e9f 100644 --- a/lib/data_migrate/database_tasks.rb +++ b/lib/data_migrate/database_tasks.rb @@ -68,45 +68,20 @@ def run_migration(migration, direction) end end - # This method only exists in Rails 7.0+. - if method_defined?(:schema_dump_path) - alias_method :original_schema_dump_path, :schema_dump_path - end - def schema_dump_path(db_config, format = ActiveRecord.schema_format) return ENV["DATA_SCHEMA"] if ENV["DATA_SCHEMA"] # We only require a schema.rb file for the primary database return unless db_config.primary? - schema_to_data_schema_dump_paths.fetch(super) + File.join(File.dirname(ActiveRecord::Tasks::DatabaseTasks.schema_dump_path(db_config, format)), schema_file_type) end # Override this method from `ActiveRecord::Tasks::DatabaseTasks` # to ensure that the sha saved in ar_internal_metadata table # is from the original schema.rb file def schema_sha1(file) - super(schema_to_data_schema_dump_paths.key(file)) - end - - private - - def schema_to_data_schema_dump_paths - @schema_to_data_schema_dump_paths ||= begin - ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env).each_with_object({}) do |db_config, mapping| - dump_path = respond_to?(:original_schema_dump_path) ? original_schema_dump_path(db_config) : ActiveRecord::Tasks::DatabaseTasks.dump_filename(db_config.name) - # As of Rails 7.0, `schema_dump` could return false for when schema dumping is not supported. - next unless dump_path - - data_dump_name = File.basename(dump_path, File.extname(dump_path)) - - unless data_dump_name.gsub!(/(_)?(schema|structure)\z/, "\\1#{schema_file_type}") - data_dump_name.concat("_#{schema_file_type}") - end - - mapping[dump_path] = File.join(File.dirname(dump_path), data_dump_name) - end - end + ActiveRecord::Tasks::DatabaseTasks.schema_dump_path(ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env, name: "primary")) end end diff --git a/spec/data_migrate/database_tasks_spec.rb b/spec/data_migrate/database_tasks_spec.rb index 9af7d242..9307e43b 100644 --- a/spec/data_migrate/database_tasks_spec.rb +++ b/spec/data_migrate/database_tasks_spec.rb @@ -100,26 +100,6 @@ end end end - - context "with custom schema dump path" do - context "for :ruby db format" do - let(:db_config) { ActiveRecord::DatabaseConfigurations::HashConfig.new("development", nil, { schema_dump: "payments_schema.rb" }) } - - it 'returns the default data schema path' do - allow(ActiveRecord).to receive(:schema_format).and_return(:ruby) - expect(subject.schema_dump_path(db_config)).to eq "db/payments_data_schema.rb" - end - end - - context "for :sql db format" do - let(:db_config) { ActiveRecord::DatabaseConfigurations::HashConfig.new("development", nil, { schema_dump: "payments_structure.sql" }) } - - it 'returns the default data schema path' do - allow(ActiveRecord).to receive(:schema_format).and_return(:sql) - expect(subject.schema_dump_path(db_config, :sql)).to eq "db/payments_data_schema.rb" - end - end - end end end end From dd850b5fa6b5234e5c45770d2305c1c580a46f78 Mon Sep 17 00:00:00 2001 From: Ngan Pham Date: Wed, 2 Aug 2023 09:42:37 -0700 Subject: [PATCH 54/98] Fix tests --- spec/data_migrate/database_tasks_spec.rb | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/spec/data_migrate/database_tasks_spec.rb b/spec/data_migrate/database_tasks_spec.rb index 9307e43b..32d955a1 100644 --- a/spec/data_migrate/database_tasks_spec.rb +++ b/spec/data_migrate/database_tasks_spec.rb @@ -80,23 +80,22 @@ describe :schema_dump_path do before do allow(ActiveRecord::Base).to receive(:configurations).and_return(ActiveRecord::DatabaseConfigurations.new([db_config])) - DataMigrate::DatabaseTasks.instance_variable_set(:@schema_to_data_schema_dump_paths, nil) end - context "with no custom schema dump path" do - let(:db_config) { ActiveRecord::DatabaseConfigurations::HashConfig.new("development", nil, {} ) } + context "for primary database" do + let(:db_config) { ActiveRecord::DatabaseConfigurations::HashConfig.new("development", "primary", {} ) } context "for :ruby db format" do - it 'returns the default data schema path' do + it 'returns the data schema path' do allow(ActiveRecord).to receive(:schema_format).and_return(:ruby) - expect(subject.schema_dump_path(db_config)).to eq "db/data_schema.rb" + expect(subject.schema_dump_path(db_config)).to eq("db/data_schema.rb") end end context "for :sql db format" do - it 'returns the default data schema path' do + it 'returns the data schema path' do allow(ActiveRecord).to receive(:schema_format).and_return(:sql) - expect(subject.schema_dump_path(db_config, :sql)).to eq "db/data_schema.rb" + expect(subject.schema_dump_path(db_config, :sql)).to eq("db/data_schema.rb") end end end From 6fd7216ba8cd1d0c2ada74d2db25c1eaf61cb0cb Mon Sep 17 00:00:00 2001 From: Ngan Pham Date: Wed, 2 Aug 2023 09:46:52 -0700 Subject: [PATCH 55/98] Fix version check --- lib/data_migrate/rails_helper.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/data_migrate/rails_helper.rb b/lib/data_migrate/rails_helper.rb index 9ae9b409..9f94e73a 100644 --- a/lib/data_migrate/rails_helper.rb +++ b/lib/data_migrate/rails_helper.rb @@ -2,11 +2,15 @@ module DataMigrate class RailsHelper class << self def rails_version_equal_to_or_higher_than_7_1 - @equal_to_or_higher_than_7_1 ||= Gem::Dependency.new("railties", ">= 7.1.0.alpha").match?("railties", Gem.loaded_specs["railties"].version) + return @equal_to_or_higher_than_7_1 if defined?(@equal_to_or_higher_than_7_1) + + @equal_to_or_higher_than_7_1 = Gem::Dependency.new("railties", ">= 7.1.0.alpha").match?("railties", Gem.loaded_specs["railties"].version, true) end def rails_version_equal_to_or_higher_than_7_0 - @rails_version_equal_to_or_higher_than_7_0 ||= Gem::Dependency.new("railties", ">= 7.0").match?("railties", Gem.loaded_specs["railties"].version) + return @rails_version_equal_to_or_higher_than_7_0 if defined?(@rails_version_equal_to_or_higher_than_7_0) + + @rails_version_equal_to_or_higher_than_7_0 = Gem::Dependency.new("railties", ">= 7.0").match?("railties", Gem.loaded_specs["railties"].version, true) end def internal_metadata From 090353d3d69a4bf667d61c41d554f626a853b472 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 23 Aug 2023 21:48:49 +0000 Subject: [PATCH 56/98] Bump activesupport from 7.0.6 to 7.0.7.2 Bumps [activesupport](https://github.com/rails/rails) from 7.0.6 to 7.0.7.2. - [Release notes](https://github.com/rails/rails/releases) - [Changelog](https://github.com/rails/rails/blob/v7.0.7.2/activesupport/CHANGELOG.md) - [Commits](https://github.com/rails/rails/compare/v7.0.6...v7.0.7.2) --- updated-dependencies: - dependency-name: activesupport dependency-type: indirect ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index e2c16a5d..b309b9e7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -8,25 +8,25 @@ PATH GEM remote: http://rubygems.org/ specs: - actionpack (7.0.6) - actionview (= 7.0.6) - activesupport (= 7.0.6) + actionpack (7.0.7.2) + actionview (= 7.0.7.2) + activesupport (= 7.0.7.2) rack (~> 2.0, >= 2.2.4) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actionview (7.0.6) - activesupport (= 7.0.6) + actionview (7.0.7.2) + activesupport (= 7.0.7.2) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - activemodel (7.0.6) - activesupport (= 7.0.6) - activerecord (7.0.6) - activemodel (= 7.0.6) - activesupport (= 7.0.6) - activesupport (7.0.6) + activemodel (7.0.7.2) + activesupport (= 7.0.7.2) + activerecord (7.0.7.2) + activemodel (= 7.0.7.2) + activesupport (= 7.0.7.2) + activesupport (7.0.7.2) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) @@ -52,7 +52,7 @@ GEM crass (~> 1.0.2) nokogiri (>= 1.12.0) method_source (1.0.0) - minitest (5.18.1) + minitest (5.19.0) nokogiri (1.15.3-arm64-darwin) racc (~> 1.4) nokogiri (1.15.3-x86_64-linux) @@ -79,9 +79,9 @@ GEM rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) - railties (7.0.6) - actionpack (= 7.0.6) - activesupport (= 7.0.6) + railties (7.0.7.2) + actionpack (= 7.0.7.2) + activesupport (= 7.0.7.2) method_source rake (>= 12.2) thor (~> 1.0) From e2154ec18df3e017110c6a81df8194de2e8a55e0 Mon Sep 17 00:00:00 2001 From: Josh Nichols Date: Tue, 19 Sep 2023 10:50:43 -0400 Subject: [PATCH 57/98] Update rails-7.1 to 7.1.0.beta1 Also, rename it to 7.1 in prep for it being released at some point --- .github/workflows/build.yml | 2 +- Appraisals | 4 +- ..._7.1.0.alpha.gemfile => rails_7.1.gemfile} | 2 +- ...ha.gemfile.lock => rails_7.1.gemfile.lock} | 172 +++++++++--------- 4 files changed, 92 insertions(+), 88 deletions(-) rename gemfiles/{rails_7.1.0.alpha.gemfile => rails_7.1.gemfile} (61%) rename gemfiles/{rails_7.1.0.alpha.gemfile.lock => rails_7.1.gemfile.lock} (64%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 40b232ad..a8d44d0a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,7 +17,7 @@ jobs: gemfile: - gemfiles/rails_6.1.gemfile - gemfiles/rails_7.0.gemfile - - gemfiles/rails_7.1.0.alpha.gemfile + - gemfiles/rails_7.1.gemfile runs-on: ubuntu-latest env: BUNDLE_GEMFILE: ${{ matrix.gemfile }} diff --git a/Appraisals b/Appraisals index f8722491..f048cc78 100644 --- a/Appraisals +++ b/Appraisals @@ -6,6 +6,6 @@ appraise 'rails-7.0' do gem 'rails', '~> 7.0' end -appraise 'rails-7.1.0.alpha' do - gem 'rails', git: "https://github.com/rails/rails.git", branch: "main" +appraise 'rails-7.1' do + gem 'rails', '7.1.0.beta1' end diff --git a/gemfiles/rails_7.1.0.alpha.gemfile b/gemfiles/rails_7.1.gemfile similarity index 61% rename from gemfiles/rails_7.1.0.alpha.gemfile rename to gemfiles/rails_7.1.gemfile index bcccc8a3..57716709 100644 --- a/gemfiles/rails_7.1.0.alpha.gemfile +++ b/gemfiles/rails_7.1.gemfile @@ -3,6 +3,6 @@ source "http://rubygems.org" gem "sqlite3", "~> 1.4" -gem "rails", git: "https://github.com/rails/rails.git", branch: "main" +gem "rails", "7.1.0.beta1" gemspec path: "../" diff --git a/gemfiles/rails_7.1.0.alpha.gemfile.lock b/gemfiles/rails_7.1.gemfile.lock similarity index 64% rename from gemfiles/rails_7.1.0.alpha.gemfile.lock rename to gemfiles/rails_7.1.gemfile.lock index 9b78be9c..d77b384e 100644 --- a/gemfiles/rails_7.1.0.alpha.gemfile.lock +++ b/gemfiles/rails_7.1.gemfile.lock @@ -1,115 +1,93 @@ -GIT - remote: https://github.com/rails/rails.git - revision: 5f3eb2195ba503919665028c01e4c76125e59fac - branch: main +PATH + remote: .. + specs: + data_migrate (9.1.0) + activerecord (>= 6.1) + railties (>= 6.1) + +GEM + remote: http://rubygems.org/ specs: - actioncable (7.1.0.alpha) - actionpack (= 7.1.0.alpha) - activesupport (= 7.1.0.alpha) + actioncable (7.1.0.beta1) + actionpack (= 7.1.0.beta1) + activesupport (= 7.1.0.beta1) nio4r (~> 2.0) websocket-driver (>= 0.6.1) zeitwerk (~> 2.6) - actionmailbox (7.1.0.alpha) - actionpack (= 7.1.0.alpha) - activejob (= 7.1.0.alpha) - activerecord (= 7.1.0.alpha) - activestorage (= 7.1.0.alpha) - activesupport (= 7.1.0.alpha) + actionmailbox (7.1.0.beta1) + actionpack (= 7.1.0.beta1) + activejob (= 7.1.0.beta1) + activerecord (= 7.1.0.beta1) + activestorage (= 7.1.0.beta1) + activesupport (= 7.1.0.beta1) mail (>= 2.7.1) net-imap net-pop net-smtp - actionmailer (7.1.0.alpha) - actionpack (= 7.1.0.alpha) - actionview (= 7.1.0.alpha) - activejob (= 7.1.0.alpha) - activesupport (= 7.1.0.alpha) + actionmailer (7.1.0.beta1) + actionpack (= 7.1.0.beta1) + actionview (= 7.1.0.beta1) + activejob (= 7.1.0.beta1) + activesupport (= 7.1.0.beta1) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp - rails-dom-testing (~> 2.0) - actionpack (7.1.0.alpha) - actionview (= 7.1.0.alpha) - activesupport (= 7.1.0.alpha) + rails-dom-testing (~> 2.2) + actionpack (7.1.0.beta1) + actionview (= 7.1.0.beta1) + activesupport (= 7.1.0.beta1) nokogiri (>= 1.8.5) rack (>= 2.2.4) rack-session (>= 1.0.1) rack-test (>= 0.6.3) - rails-dom-testing (~> 2.0) + rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - actiontext (7.1.0.alpha) - actionpack (= 7.1.0.alpha) - activerecord (= 7.1.0.alpha) - activestorage (= 7.1.0.alpha) - activesupport (= 7.1.0.alpha) + actiontext (7.1.0.beta1) + actionpack (= 7.1.0.beta1) + activerecord (= 7.1.0.beta1) + activestorage (= 7.1.0.beta1) + activesupport (= 7.1.0.beta1) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.1.0.alpha) - activesupport (= 7.1.0.alpha) + actionview (7.1.0.beta1) + activesupport (= 7.1.0.beta1) builder (~> 3.1) erubi (~> 1.11) - rails-dom-testing (~> 2.0) + rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - activejob (7.1.0.alpha) - activesupport (= 7.1.0.alpha) + activejob (7.1.0.beta1) + activesupport (= 7.1.0.beta1) globalid (>= 0.3.6) - activemodel (7.1.0.alpha) - activesupport (= 7.1.0.alpha) - activerecord (7.1.0.alpha) - activemodel (= 7.1.0.alpha) - activesupport (= 7.1.0.alpha) + activemodel (7.1.0.beta1) + activesupport (= 7.1.0.beta1) + activerecord (7.1.0.beta1) + activemodel (= 7.1.0.beta1) + activesupport (= 7.1.0.beta1) timeout (>= 0.4.0) - activestorage (7.1.0.alpha) - actionpack (= 7.1.0.alpha) - activejob (= 7.1.0.alpha) - activerecord (= 7.1.0.alpha) - activesupport (= 7.1.0.alpha) + activestorage (7.1.0.beta1) + actionpack (= 7.1.0.beta1) + activejob (= 7.1.0.beta1) + activerecord (= 7.1.0.beta1) + activesupport (= 7.1.0.beta1) marcel (~> 1.0) - activesupport (7.1.0.alpha) + activesupport (7.1.0.beta1) + base64 + bigdecimal concurrent-ruby (~> 1.0, >= 1.0.2) connection_pool (>= 2.2.5) + drb i18n (>= 1.6, < 2) minitest (>= 5.1) + mutex_m tzinfo (~> 2.0) - rails (7.1.0.alpha) - actioncable (= 7.1.0.alpha) - actionmailbox (= 7.1.0.alpha) - actionmailer (= 7.1.0.alpha) - actionpack (= 7.1.0.alpha) - actiontext (= 7.1.0.alpha) - actionview (= 7.1.0.alpha) - activejob (= 7.1.0.alpha) - activemodel (= 7.1.0.alpha) - activerecord (= 7.1.0.alpha) - activestorage (= 7.1.0.alpha) - activesupport (= 7.1.0.alpha) - bundler (>= 1.15.0) - railties (= 7.1.0.alpha) - railties (7.1.0.alpha) - actionpack (= 7.1.0.alpha) - activesupport (= 7.1.0.alpha) - irb - rackup (>= 1.0.0) - rake (>= 12.2) - thor (~> 1.0, >= 1.2.2) - zeitwerk (~> 2.6) - -PATH - remote: .. - specs: - data_migrate (9.1.0) - activerecord (>= 6.1) - railties (>= 6.1) - -GEM - remote: http://rubygems.org/ - specs: appraisal (2.5.0) bundler rake thor (>= 0.14.0) ast (2.4.2) + base64 (0.1.1) + bigdecimal (3.1.4) builder (3.2.4) childprocess (4.1.0) coderay (1.1.3) @@ -118,9 +96,11 @@ GEM crass (1.0.6) date (3.3.3) diff-lcs (1.5.0) + drb (2.1.1) + ruby2_keywords erubi (1.12.0) - globalid (1.1.0) - activesupport (>= 5.0) + globalid (1.2.1) + activesupport (>= 6.1) i18n (1.14.1) concurrent-ruby (~> 1.0) iniparse (1.5.0) @@ -139,9 +119,10 @@ GEM net-smtp marcel (1.0.2) method_source (1.0.0) - mini_mime (1.1.2) + mini_mime (1.1.5) minitest (5.18.1) - net-imap (0.3.6) + mutex_m (0.1.2) + net-imap (0.3.7) date net-protocol net-pop (0.1.2) @@ -175,13 +156,35 @@ GEM rackup (2.1.0) rack (>= 3) webrick (~> 1.8) - rails-dom-testing (2.1.1) + rails (7.1.0.beta1) + actioncable (= 7.1.0.beta1) + actionmailbox (= 7.1.0.beta1) + actionmailer (= 7.1.0.beta1) + actionpack (= 7.1.0.beta1) + actiontext (= 7.1.0.beta1) + actionview (= 7.1.0.beta1) + activejob (= 7.1.0.beta1) + activemodel (= 7.1.0.beta1) + activerecord (= 7.1.0.beta1) + activestorage (= 7.1.0.beta1) + activesupport (= 7.1.0.beta1) + bundler (>= 1.15.0) + railties (= 7.1.0.beta1) + rails-dom-testing (2.2.0) activesupport (>= 5.0.0) minitest nokogiri (>= 1.6) rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) + railties (7.1.0.beta1) + actionpack (= 7.1.0.beta1) + activesupport (= 7.1.0.beta1) + irb + rackup (>= 1.0.0) + rake (>= 12.2) + thor (~> 1.0, >= 1.2.2) + zeitwerk (~> 2.6) rainbow (3.1.1) rake (13.0.6) rb-readline (0.5.5) @@ -216,6 +219,7 @@ GEM rubocop-ast (1.29.0) parser (>= 3.2.1.0) ruby-progressbar (1.13.0) + ruby2_keywords (0.0.5) sqlite3 (1.6.3-arm64-darwin) sqlite3 (1.6.3-x86_64-linux) thor (1.2.2) @@ -225,7 +229,7 @@ GEM concurrent-ruby (~> 1.0) unicode-display_width (2.4.2) webrick (1.8.1) - websocket-driver (0.7.5) + websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) zeitwerk (2.6.8) @@ -239,7 +243,7 @@ DEPENDENCIES data_migrate! overcommit pry - rails! + rails (= 7.1.0.beta1) rake rb-readline rspec From 714086a0b8cbd814a5a0f219cb3ae72dedc6ae9a Mon Sep 17 00:00:00 2001 From: Ngan Pham Date: Sat, 30 Sep 2023 08:22:03 -0700 Subject: [PATCH 58/98] Build agianst rails 7.1.0.rc1 --- Appraisals | 2 +- gemfiles/rails_7.1.gemfile | 2 +- gemfiles/rails_7.1.gemfile.lock | 110 ++++++++++++++++---------------- 3 files changed, 57 insertions(+), 57 deletions(-) diff --git a/Appraisals b/Appraisals index f048cc78..286e16b1 100644 --- a/Appraisals +++ b/Appraisals @@ -7,5 +7,5 @@ appraise 'rails-7.0' do end appraise 'rails-7.1' do - gem 'rails', '7.1.0.beta1' + gem 'rails', '7.1.0.rc1' end diff --git a/gemfiles/rails_7.1.gemfile b/gemfiles/rails_7.1.gemfile index 57716709..16542f5c 100644 --- a/gemfiles/rails_7.1.gemfile +++ b/gemfiles/rails_7.1.gemfile @@ -3,6 +3,6 @@ source "http://rubygems.org" gem "sqlite3", "~> 1.4" -gem "rails", "7.1.0.beta1" +gem "rails", "7.1.0.rc1" gemspec path: "../" diff --git a/gemfiles/rails_7.1.gemfile.lock b/gemfiles/rails_7.1.gemfile.lock index d77b384e..2ef2da6f 100644 --- a/gemfiles/rails_7.1.gemfile.lock +++ b/gemfiles/rails_7.1.gemfile.lock @@ -8,70 +8,70 @@ PATH GEM remote: http://rubygems.org/ specs: - actioncable (7.1.0.beta1) - actionpack (= 7.1.0.beta1) - activesupport (= 7.1.0.beta1) + actioncable (7.1.0.rc1) + actionpack (= 7.1.0.rc1) + activesupport (= 7.1.0.rc1) nio4r (~> 2.0) websocket-driver (>= 0.6.1) zeitwerk (~> 2.6) - actionmailbox (7.1.0.beta1) - actionpack (= 7.1.0.beta1) - activejob (= 7.1.0.beta1) - activerecord (= 7.1.0.beta1) - activestorage (= 7.1.0.beta1) - activesupport (= 7.1.0.beta1) + actionmailbox (7.1.0.rc1) + actionpack (= 7.1.0.rc1) + activejob (= 7.1.0.rc1) + activerecord (= 7.1.0.rc1) + activestorage (= 7.1.0.rc1) + activesupport (= 7.1.0.rc1) mail (>= 2.7.1) net-imap net-pop net-smtp - actionmailer (7.1.0.beta1) - actionpack (= 7.1.0.beta1) - actionview (= 7.1.0.beta1) - activejob (= 7.1.0.beta1) - activesupport (= 7.1.0.beta1) + actionmailer (7.1.0.rc1) + actionpack (= 7.1.0.rc1) + actionview (= 7.1.0.rc1) + activejob (= 7.1.0.rc1) + activesupport (= 7.1.0.rc1) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp rails-dom-testing (~> 2.2) - actionpack (7.1.0.beta1) - actionview (= 7.1.0.beta1) - activesupport (= 7.1.0.beta1) + actionpack (7.1.0.rc1) + actionview (= 7.1.0.rc1) + activesupport (= 7.1.0.rc1) nokogiri (>= 1.8.5) rack (>= 2.2.4) rack-session (>= 1.0.1) rack-test (>= 0.6.3) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - actiontext (7.1.0.beta1) - actionpack (= 7.1.0.beta1) - activerecord (= 7.1.0.beta1) - activestorage (= 7.1.0.beta1) - activesupport (= 7.1.0.beta1) + actiontext (7.1.0.rc1) + actionpack (= 7.1.0.rc1) + activerecord (= 7.1.0.rc1) + activestorage (= 7.1.0.rc1) + activesupport (= 7.1.0.rc1) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.1.0.beta1) - activesupport (= 7.1.0.beta1) + actionview (7.1.0.rc1) + activesupport (= 7.1.0.rc1) builder (~> 3.1) erubi (~> 1.11) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - activejob (7.1.0.beta1) - activesupport (= 7.1.0.beta1) + activejob (7.1.0.rc1) + activesupport (= 7.1.0.rc1) globalid (>= 0.3.6) - activemodel (7.1.0.beta1) - activesupport (= 7.1.0.beta1) - activerecord (7.1.0.beta1) - activemodel (= 7.1.0.beta1) - activesupport (= 7.1.0.beta1) + activemodel (7.1.0.rc1) + activesupport (= 7.1.0.rc1) + activerecord (7.1.0.rc1) + activemodel (= 7.1.0.rc1) + activesupport (= 7.1.0.rc1) timeout (>= 0.4.0) - activestorage (7.1.0.beta1) - actionpack (= 7.1.0.beta1) - activejob (= 7.1.0.beta1) - activerecord (= 7.1.0.beta1) - activesupport (= 7.1.0.beta1) + activestorage (7.1.0.rc1) + actionpack (= 7.1.0.rc1) + activejob (= 7.1.0.rc1) + activerecord (= 7.1.0.rc1) + activesupport (= 7.1.0.rc1) marcel (~> 1.0) - activesupport (7.1.0.beta1) + activesupport (7.1.0.rc1) base64 bigdecimal concurrent-ruby (~> 1.0, >= 1.0.2) @@ -129,7 +129,7 @@ GEM net-protocol net-protocol (0.2.1) timeout - net-smtp (0.3.3) + net-smtp (0.4.0) net-protocol nio4r (2.5.9) nokogiri (1.15.3-arm64-darwin) @@ -156,20 +156,20 @@ GEM rackup (2.1.0) rack (>= 3) webrick (~> 1.8) - rails (7.1.0.beta1) - actioncable (= 7.1.0.beta1) - actionmailbox (= 7.1.0.beta1) - actionmailer (= 7.1.0.beta1) - actionpack (= 7.1.0.beta1) - actiontext (= 7.1.0.beta1) - actionview (= 7.1.0.beta1) - activejob (= 7.1.0.beta1) - activemodel (= 7.1.0.beta1) - activerecord (= 7.1.0.beta1) - activestorage (= 7.1.0.beta1) - activesupport (= 7.1.0.beta1) + rails (7.1.0.rc1) + actioncable (= 7.1.0.rc1) + actionmailbox (= 7.1.0.rc1) + actionmailer (= 7.1.0.rc1) + actionpack (= 7.1.0.rc1) + actiontext (= 7.1.0.rc1) + actionview (= 7.1.0.rc1) + activejob (= 7.1.0.rc1) + activemodel (= 7.1.0.rc1) + activerecord (= 7.1.0.rc1) + activestorage (= 7.1.0.rc1) + activesupport (= 7.1.0.rc1) bundler (>= 1.15.0) - railties (= 7.1.0.beta1) + railties (= 7.1.0.rc1) rails-dom-testing (2.2.0) activesupport (>= 5.0.0) minitest @@ -177,9 +177,9 @@ GEM rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) - railties (7.1.0.beta1) - actionpack (= 7.1.0.beta1) - activesupport (= 7.1.0.beta1) + railties (7.1.0.rc1) + actionpack (= 7.1.0.rc1) + activesupport (= 7.1.0.rc1) irb rackup (>= 1.0.0) rake (>= 12.2) @@ -243,7 +243,7 @@ DEPENDENCIES data_migrate! overcommit pry - rails (= 7.1.0.beta1) + rails (= 7.1.0.rc1) rake rb-readline rspec From 64ffeb79c214e3459bc4d1179d0d04cbd92c6d6d Mon Sep 17 00:00:00 2001 From: Ngan Pham Date: Sun, 1 Oct 2023 17:28:27 -0700 Subject: [PATCH 59/98] Support rails 7.1.0.rc2 --- Appraisals | 2 +- gemfiles/rails_7.1.gemfile | 2 +- gemfiles/rails_7.1.gemfile.lock | 108 ++++++++++++++++---------------- 3 files changed, 56 insertions(+), 56 deletions(-) diff --git a/Appraisals b/Appraisals index 286e16b1..766bb80a 100644 --- a/Appraisals +++ b/Appraisals @@ -7,5 +7,5 @@ appraise 'rails-7.0' do end appraise 'rails-7.1' do - gem 'rails', '7.1.0.rc1' + gem 'rails', '7.1.0.rc2' end diff --git a/gemfiles/rails_7.1.gemfile b/gemfiles/rails_7.1.gemfile index 16542f5c..0e336803 100644 --- a/gemfiles/rails_7.1.gemfile +++ b/gemfiles/rails_7.1.gemfile @@ -3,6 +3,6 @@ source "http://rubygems.org" gem "sqlite3", "~> 1.4" -gem "rails", "7.1.0.rc1" +gem "rails", "7.1.0.rc2" gemspec path: "../" diff --git a/gemfiles/rails_7.1.gemfile.lock b/gemfiles/rails_7.1.gemfile.lock index 2ef2da6f..51a3d9a1 100644 --- a/gemfiles/rails_7.1.gemfile.lock +++ b/gemfiles/rails_7.1.gemfile.lock @@ -8,70 +8,70 @@ PATH GEM remote: http://rubygems.org/ specs: - actioncable (7.1.0.rc1) - actionpack (= 7.1.0.rc1) - activesupport (= 7.1.0.rc1) + actioncable (7.1.0.rc2) + actionpack (= 7.1.0.rc2) + activesupport (= 7.1.0.rc2) nio4r (~> 2.0) websocket-driver (>= 0.6.1) zeitwerk (~> 2.6) - actionmailbox (7.1.0.rc1) - actionpack (= 7.1.0.rc1) - activejob (= 7.1.0.rc1) - activerecord (= 7.1.0.rc1) - activestorage (= 7.1.0.rc1) - activesupport (= 7.1.0.rc1) + actionmailbox (7.1.0.rc2) + actionpack (= 7.1.0.rc2) + activejob (= 7.1.0.rc2) + activerecord (= 7.1.0.rc2) + activestorage (= 7.1.0.rc2) + activesupport (= 7.1.0.rc2) mail (>= 2.7.1) net-imap net-pop net-smtp - actionmailer (7.1.0.rc1) - actionpack (= 7.1.0.rc1) - actionview (= 7.1.0.rc1) - activejob (= 7.1.0.rc1) - activesupport (= 7.1.0.rc1) + actionmailer (7.1.0.rc2) + actionpack (= 7.1.0.rc2) + actionview (= 7.1.0.rc2) + activejob (= 7.1.0.rc2) + activesupport (= 7.1.0.rc2) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp rails-dom-testing (~> 2.2) - actionpack (7.1.0.rc1) - actionview (= 7.1.0.rc1) - activesupport (= 7.1.0.rc1) + actionpack (7.1.0.rc2) + actionview (= 7.1.0.rc2) + activesupport (= 7.1.0.rc2) nokogiri (>= 1.8.5) rack (>= 2.2.4) rack-session (>= 1.0.1) rack-test (>= 0.6.3) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - actiontext (7.1.0.rc1) - actionpack (= 7.1.0.rc1) - activerecord (= 7.1.0.rc1) - activestorage (= 7.1.0.rc1) - activesupport (= 7.1.0.rc1) + actiontext (7.1.0.rc2) + actionpack (= 7.1.0.rc2) + activerecord (= 7.1.0.rc2) + activestorage (= 7.1.0.rc2) + activesupport (= 7.1.0.rc2) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.1.0.rc1) - activesupport (= 7.1.0.rc1) + actionview (7.1.0.rc2) + activesupport (= 7.1.0.rc2) builder (~> 3.1) erubi (~> 1.11) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - activejob (7.1.0.rc1) - activesupport (= 7.1.0.rc1) + activejob (7.1.0.rc2) + activesupport (= 7.1.0.rc2) globalid (>= 0.3.6) - activemodel (7.1.0.rc1) - activesupport (= 7.1.0.rc1) - activerecord (7.1.0.rc1) - activemodel (= 7.1.0.rc1) - activesupport (= 7.1.0.rc1) + activemodel (7.1.0.rc2) + activesupport (= 7.1.0.rc2) + activerecord (7.1.0.rc2) + activemodel (= 7.1.0.rc2) + activesupport (= 7.1.0.rc2) timeout (>= 0.4.0) - activestorage (7.1.0.rc1) - actionpack (= 7.1.0.rc1) - activejob (= 7.1.0.rc1) - activerecord (= 7.1.0.rc1) - activesupport (= 7.1.0.rc1) + activestorage (7.1.0.rc2) + actionpack (= 7.1.0.rc2) + activejob (= 7.1.0.rc2) + activerecord (= 7.1.0.rc2) + activesupport (= 7.1.0.rc2) marcel (~> 1.0) - activesupport (7.1.0.rc1) + activesupport (7.1.0.rc2) base64 bigdecimal concurrent-ruby (~> 1.0, >= 1.0.2) @@ -156,20 +156,20 @@ GEM rackup (2.1.0) rack (>= 3) webrick (~> 1.8) - rails (7.1.0.rc1) - actioncable (= 7.1.0.rc1) - actionmailbox (= 7.1.0.rc1) - actionmailer (= 7.1.0.rc1) - actionpack (= 7.1.0.rc1) - actiontext (= 7.1.0.rc1) - actionview (= 7.1.0.rc1) - activejob (= 7.1.0.rc1) - activemodel (= 7.1.0.rc1) - activerecord (= 7.1.0.rc1) - activestorage (= 7.1.0.rc1) - activesupport (= 7.1.0.rc1) + rails (7.1.0.rc2) + actioncable (= 7.1.0.rc2) + actionmailbox (= 7.1.0.rc2) + actionmailer (= 7.1.0.rc2) + actionpack (= 7.1.0.rc2) + actiontext (= 7.1.0.rc2) + actionview (= 7.1.0.rc2) + activejob (= 7.1.0.rc2) + activemodel (= 7.1.0.rc2) + activerecord (= 7.1.0.rc2) + activestorage (= 7.1.0.rc2) + activesupport (= 7.1.0.rc2) bundler (>= 1.15.0) - railties (= 7.1.0.rc1) + railties (= 7.1.0.rc2) rails-dom-testing (2.2.0) activesupport (>= 5.0.0) minitest @@ -177,9 +177,9 @@ GEM rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) - railties (7.1.0.rc1) - actionpack (= 7.1.0.rc1) - activesupport (= 7.1.0.rc1) + railties (7.1.0.rc2) + actionpack (= 7.1.0.rc2) + activesupport (= 7.1.0.rc2) irb rackup (>= 1.0.0) rake (>= 12.2) @@ -243,7 +243,7 @@ DEPENDENCIES data_migrate! overcommit pry - rails (= 7.1.0.rc1) + rails (= 7.1.0.rc2) rake rb-readline rspec From 6ff71684283da7584f4f6e48d408b1169ec80132 Mon Sep 17 00:00:00 2001 From: Josh Nichols Date: Thu, 5 Oct 2023 15:16:39 -0600 Subject: [PATCH 60/98] update to 7.1.0 official release --- Appraisals | 4 +- gemfiles/rails_7.1.gemfile | 2 +- gemfiles/rails_7.1.gemfile.lock | 130 +++++++++++++++++--------------- 3 files changed, 71 insertions(+), 65 deletions(-) diff --git a/Appraisals b/Appraisals index 766bb80a..7eec0afd 100644 --- a/Appraisals +++ b/Appraisals @@ -3,9 +3,9 @@ appraise 'rails-6.1' do end appraise 'rails-7.0' do - gem 'rails', '~> 7.0' + gem 'rails', '~> 7.0.0' end appraise 'rails-7.1' do - gem 'rails', '7.1.0.rc2' + gem 'rails', '7.1.0' end diff --git a/gemfiles/rails_7.1.gemfile b/gemfiles/rails_7.1.gemfile index 0e336803..ce298207 100644 --- a/gemfiles/rails_7.1.gemfile +++ b/gemfiles/rails_7.1.gemfile @@ -3,6 +3,6 @@ source "http://rubygems.org" gem "sqlite3", "~> 1.4" -gem "rails", "7.1.0.rc2" +gem "rails", "7.1.0" gemspec path: "../" diff --git a/gemfiles/rails_7.1.gemfile.lock b/gemfiles/rails_7.1.gemfile.lock index 51a3d9a1..e63627d9 100644 --- a/gemfiles/rails_7.1.gemfile.lock +++ b/gemfiles/rails_7.1.gemfile.lock @@ -8,70 +8,70 @@ PATH GEM remote: http://rubygems.org/ specs: - actioncable (7.1.0.rc2) - actionpack (= 7.1.0.rc2) - activesupport (= 7.1.0.rc2) + actioncable (7.1.0) + actionpack (= 7.1.0) + activesupport (= 7.1.0) nio4r (~> 2.0) websocket-driver (>= 0.6.1) zeitwerk (~> 2.6) - actionmailbox (7.1.0.rc2) - actionpack (= 7.1.0.rc2) - activejob (= 7.1.0.rc2) - activerecord (= 7.1.0.rc2) - activestorage (= 7.1.0.rc2) - activesupport (= 7.1.0.rc2) + actionmailbox (7.1.0) + actionpack (= 7.1.0) + activejob (= 7.1.0) + activerecord (= 7.1.0) + activestorage (= 7.1.0) + activesupport (= 7.1.0) mail (>= 2.7.1) net-imap net-pop net-smtp - actionmailer (7.1.0.rc2) - actionpack (= 7.1.0.rc2) - actionview (= 7.1.0.rc2) - activejob (= 7.1.0.rc2) - activesupport (= 7.1.0.rc2) + actionmailer (7.1.0) + actionpack (= 7.1.0) + actionview (= 7.1.0) + activejob (= 7.1.0) + activesupport (= 7.1.0) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp rails-dom-testing (~> 2.2) - actionpack (7.1.0.rc2) - actionview (= 7.1.0.rc2) - activesupport (= 7.1.0.rc2) + actionpack (7.1.0) + actionview (= 7.1.0) + activesupport (= 7.1.0) nokogiri (>= 1.8.5) rack (>= 2.2.4) rack-session (>= 1.0.1) rack-test (>= 0.6.3) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - actiontext (7.1.0.rc2) - actionpack (= 7.1.0.rc2) - activerecord (= 7.1.0.rc2) - activestorage (= 7.1.0.rc2) - activesupport (= 7.1.0.rc2) + actiontext (7.1.0) + actionpack (= 7.1.0) + activerecord (= 7.1.0) + activestorage (= 7.1.0) + activesupport (= 7.1.0) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.1.0.rc2) - activesupport (= 7.1.0.rc2) + actionview (7.1.0) + activesupport (= 7.1.0) builder (~> 3.1) erubi (~> 1.11) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - activejob (7.1.0.rc2) - activesupport (= 7.1.0.rc2) + activejob (7.1.0) + activesupport (= 7.1.0) globalid (>= 0.3.6) - activemodel (7.1.0.rc2) - activesupport (= 7.1.0.rc2) - activerecord (7.1.0.rc2) - activemodel (= 7.1.0.rc2) - activesupport (= 7.1.0.rc2) + activemodel (7.1.0) + activesupport (= 7.1.0) + activerecord (7.1.0) + activemodel (= 7.1.0) + activesupport (= 7.1.0) timeout (>= 0.4.0) - activestorage (7.1.0.rc2) - actionpack (= 7.1.0.rc2) - activejob (= 7.1.0.rc2) - activerecord (= 7.1.0.rc2) - activesupport (= 7.1.0.rc2) + activestorage (7.1.0) + actionpack (= 7.1.0) + activejob (= 7.1.0) + activerecord (= 7.1.0) + activesupport (= 7.1.0) marcel (~> 1.0) - activesupport (7.1.0.rc2) + activesupport (7.1.0) base64 bigdecimal concurrent-ruby (~> 1.0, >= 1.0.2) @@ -105,8 +105,9 @@ GEM concurrent-ruby (~> 1.0) iniparse (1.5.0) io-console (0.6.0) - irb (1.7.4) - reline (>= 0.3.6) + irb (1.8.1) + rdoc + reline (>= 0.3.8) json (2.6.3) language_server-protocol (3.17.0.3) loofah (2.21.3) @@ -120,9 +121,9 @@ GEM marcel (1.0.2) method_source (1.0.0) mini_mime (1.1.5) - minitest (5.18.1) + minitest (5.20.0) mutex_m (0.1.2) - net-imap (0.3.7) + net-imap (0.4.0) date net-protocol net-pop (0.1.2) @@ -132,9 +133,9 @@ GEM net-smtp (0.4.0) net-protocol nio4r (2.5.9) - nokogiri (1.15.3-arm64-darwin) + nokogiri (1.15.4-arm64-darwin) racc (~> 1.4) - nokogiri (1.15.3-x86_64-linux) + nokogiri (1.15.4-x86_64-linux) racc (~> 1.4) overcommit (0.60.0) childprocess (>= 0.6.3, < 5) @@ -147,6 +148,8 @@ GEM pry (0.14.2) coderay (~> 1.1) method_source (~> 1.0) + psych (5.1.0) + stringio racc (1.7.1) rack (3.0.8) rack-session (2.0.0) @@ -156,20 +159,20 @@ GEM rackup (2.1.0) rack (>= 3) webrick (~> 1.8) - rails (7.1.0.rc2) - actioncable (= 7.1.0.rc2) - actionmailbox (= 7.1.0.rc2) - actionmailer (= 7.1.0.rc2) - actionpack (= 7.1.0.rc2) - actiontext (= 7.1.0.rc2) - actionview (= 7.1.0.rc2) - activejob (= 7.1.0.rc2) - activemodel (= 7.1.0.rc2) - activerecord (= 7.1.0.rc2) - activestorage (= 7.1.0.rc2) - activesupport (= 7.1.0.rc2) + rails (7.1.0) + actioncable (= 7.1.0) + actionmailbox (= 7.1.0) + actionmailer (= 7.1.0) + actionpack (= 7.1.0) + actiontext (= 7.1.0) + actionview (= 7.1.0) + activejob (= 7.1.0) + activemodel (= 7.1.0) + activerecord (= 7.1.0) + activestorage (= 7.1.0) + activesupport (= 7.1.0) bundler (>= 1.15.0) - railties (= 7.1.0.rc2) + railties (= 7.1.0) rails-dom-testing (2.2.0) activesupport (>= 5.0.0) minitest @@ -177,9 +180,9 @@ GEM rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) - railties (7.1.0.rc2) - actionpack (= 7.1.0.rc2) - activesupport (= 7.1.0.rc2) + railties (7.1.0) + actionpack (= 7.1.0) + activesupport (= 7.1.0) irb rackup (>= 1.0.0) rake (>= 12.2) @@ -188,8 +191,10 @@ GEM rainbow (3.1.1) rake (13.0.6) rb-readline (0.5.5) + rdoc (6.5.0) + psych (>= 4.0.0) regexp_parser (2.8.1) - reline (0.3.6) + reline (0.3.9) io-console (~> 0.5) rexml (3.2.5) rspec (3.12.0) @@ -222,6 +227,7 @@ GEM ruby2_keywords (0.0.5) sqlite3 (1.6.3-arm64-darwin) sqlite3 (1.6.3-x86_64-linux) + stringio (3.0.8) thor (1.2.2) timecop (0.9.6) timeout (0.4.0) @@ -232,7 +238,7 @@ GEM websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) - zeitwerk (2.6.8) + zeitwerk (2.6.12) PLATFORMS arm64-darwin-22 @@ -243,7 +249,7 @@ DEPENDENCIES data_migrate! overcommit pry - rails (= 7.1.0.rc2) + rails (= 7.1.0) rake rb-readline rspec From aafb8565ebee05295ca6034174781c4c1465a3bc Mon Sep 17 00:00:00 2001 From: Josh Nichols Date: Thu, 5 Oct 2023 15:17:57 -0600 Subject: [PATCH 61/98] update readme to mention 7.1 --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 45fe96e8..e6aca129 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ table to track all migrations. ## Rails Support -Support Rails 6.1 through 7.0 +Support Rails 6.1 through 7.1 #### v1 @@ -166,6 +166,7 @@ Run tests for a specific version of Rails bundle exec appraisal install bundle exec appraisal rails-6.1 rspec bundle exec appraisal rails-7.0 rspec +bundle exec appraisal rails-7.1 rspec ``` ## Thanks From 428b1e11ae889d8db2db1854660f289aa9f8dd11 Mon Sep 17 00:00:00 2001 From: Maple Ong Date: Thu, 5 Oct 2023 14:41:58 -0600 Subject: [PATCH 62/98] Release v9.2.0 --- Changelog.md | 7 +++---- Gemfile.lock | 2 +- gemfiles/rails_6.1.gemfile.lock | 5 ++++- gemfiles/rails_7.0.gemfile.lock | 5 ++++- gemfiles/rails_7.1.gemfile.lock | 2 +- lib/data_migrate/version.rb | 2 +- 6 files changed, 14 insertions(+), 9 deletions(-) diff --git a/Changelog.md b/Changelog.md index 704dd79f..bb41f64c 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,9 +1,8 @@ # Changelog -## 11.0.0 -- Commit *.lock files -- Remove support for Rails 6.0 -- Support Rails 7.1 +## 9.2.0 +- Support Rails 7.1 https://github.com/ilyakatz/data-migrate/pull/278 +- Build and test against 7.1.0.rc1 https://github.com/ilyakatz/data-migrate/pull/286 ## 9.1.0 diff --git a/Gemfile.lock b/Gemfile.lock index b309b9e7..235df4ba 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - data_migrate (9.1.0) + data_migrate (9.2.0) activerecord (>= 6.1) railties (>= 6.1) diff --git a/gemfiles/rails_6.1.gemfile.lock b/gemfiles/rails_6.1.gemfile.lock index c7a9bb2f..fd049e8b 100644 --- a/gemfiles/rails_6.1.gemfile.lock +++ b/gemfiles/rails_6.1.gemfile.lock @@ -1,7 +1,7 @@ PATH remote: .. specs: - data_migrate (9.1.0) + data_migrate (9.2.0) activerecord (>= 6.1) railties (>= 6.1) @@ -110,6 +110,8 @@ GEM nio4r (2.5.9) nokogiri (1.15.2-arm64-darwin) racc (~> 1.4) + nokogiri (1.15.2-x86_64-linux) + racc (~> 1.4) overcommit (0.60.0) childprocess (>= 0.6.3, < 5) iniparse (~> 1.4) @@ -191,6 +193,7 @@ GEM activesupport (>= 5.2) sprockets (>= 3.0.0) sqlite3 (1.6.3-arm64-darwin) + sqlite3 (1.6.3-x86_64-linux) thor (1.2.2) timecop (0.9.6) timeout (0.3.2) diff --git a/gemfiles/rails_7.0.gemfile.lock b/gemfiles/rails_7.0.gemfile.lock index 8e03876d..56147e89 100644 --- a/gemfiles/rails_7.0.gemfile.lock +++ b/gemfiles/rails_7.0.gemfile.lock @@ -1,7 +1,7 @@ PATH remote: .. specs: - data_migrate (9.1.0) + data_migrate (9.2.0) activerecord (>= 6.1) railties (>= 6.1) @@ -117,6 +117,8 @@ GEM nio4r (2.5.9) nokogiri (1.15.3-arm64-darwin) racc (~> 1.4) + nokogiri (1.15.3-x86_64-linux) + racc (~> 1.4) overcommit (0.60.0) childprocess (>= 0.6.3, < 5) iniparse (~> 1.4) @@ -193,6 +195,7 @@ GEM parser (>= 3.2.1.0) ruby-progressbar (1.13.0) sqlite3 (1.6.3-arm64-darwin) + sqlite3 (1.6.3-x86_64-linux) thor (1.2.2) timecop (0.9.6) timeout (0.4.0) diff --git a/gemfiles/rails_7.1.gemfile.lock b/gemfiles/rails_7.1.gemfile.lock index e63627d9..9ab273eb 100644 --- a/gemfiles/rails_7.1.gemfile.lock +++ b/gemfiles/rails_7.1.gemfile.lock @@ -1,7 +1,7 @@ PATH remote: .. specs: - data_migrate (9.1.0) + data_migrate (9.2.0) activerecord (>= 6.1) railties (>= 6.1) diff --git a/lib/data_migrate/version.rb b/lib/data_migrate/version.rb index 3533a8cd..4c584041 100644 --- a/lib/data_migrate/version.rb +++ b/lib/data_migrate/version.rb @@ -1,3 +1,3 @@ module DataMigrate - VERSION = "9.1.0".freeze + VERSION = "9.2.0".freeze end From 0321038d40651a5df2bac813a622fe6b768696d4 Mon Sep 17 00:00:00 2001 From: Josh Nichols Date: Wed, 27 Sep 2023 12:08:50 -0400 Subject: [PATCH 63/98] Update rails appraisals --- gemfiles/rails_6.1.gemfile.lock | 141 ++++++++++++++++---------------- gemfiles/rails_7.0.gemfile | 2 +- gemfiles/rails_7.0.gemfile.lock | 136 +++++++++++++++--------------- gemfiles/rails_7.1.gemfile.lock | 10 +-- 4 files changed, 145 insertions(+), 144 deletions(-) diff --git a/gemfiles/rails_6.1.gemfile.lock b/gemfiles/rails_6.1.gemfile.lock index fd049e8b..d715b44c 100644 --- a/gemfiles/rails_6.1.gemfile.lock +++ b/gemfiles/rails_6.1.gemfile.lock @@ -8,60 +8,60 @@ PATH GEM remote: http://rubygems.org/ specs: - actioncable (6.1.7.3) - actionpack (= 6.1.7.3) - activesupport (= 6.1.7.3) + actioncable (6.1.7.6) + actionpack (= 6.1.7.6) + activesupport (= 6.1.7.6) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (6.1.7.3) - actionpack (= 6.1.7.3) - activejob (= 6.1.7.3) - activerecord (= 6.1.7.3) - activestorage (= 6.1.7.3) - activesupport (= 6.1.7.3) + actionmailbox (6.1.7.6) + actionpack (= 6.1.7.6) + activejob (= 6.1.7.6) + activerecord (= 6.1.7.6) + activestorage (= 6.1.7.6) + activesupport (= 6.1.7.6) mail (>= 2.7.1) - actionmailer (6.1.7.3) - actionpack (= 6.1.7.3) - actionview (= 6.1.7.3) - activejob (= 6.1.7.3) - activesupport (= 6.1.7.3) + actionmailer (6.1.7.6) + actionpack (= 6.1.7.6) + actionview (= 6.1.7.6) + activejob (= 6.1.7.6) + activesupport (= 6.1.7.6) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (6.1.7.3) - actionview (= 6.1.7.3) - activesupport (= 6.1.7.3) + actionpack (6.1.7.6) + actionview (= 6.1.7.6) + activesupport (= 6.1.7.6) rack (~> 2.0, >= 2.0.9) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (6.1.7.3) - actionpack (= 6.1.7.3) - activerecord (= 6.1.7.3) - activestorage (= 6.1.7.3) - activesupport (= 6.1.7.3) + actiontext (6.1.7.6) + actionpack (= 6.1.7.6) + activerecord (= 6.1.7.6) + activestorage (= 6.1.7.6) + activesupport (= 6.1.7.6) nokogiri (>= 1.8.5) - actionview (6.1.7.3) - activesupport (= 6.1.7.3) + actionview (6.1.7.6) + activesupport (= 6.1.7.6) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (6.1.7.3) - activesupport (= 6.1.7.3) + activejob (6.1.7.6) + activesupport (= 6.1.7.6) globalid (>= 0.3.6) - activemodel (6.1.7.3) - activesupport (= 6.1.7.3) - activerecord (6.1.7.3) - activemodel (= 6.1.7.3) - activesupport (= 6.1.7.3) - activestorage (6.1.7.3) - actionpack (= 6.1.7.3) - activejob (= 6.1.7.3) - activerecord (= 6.1.7.3) - activesupport (= 6.1.7.3) + activemodel (6.1.7.6) + activesupport (= 6.1.7.6) + activerecord (6.1.7.6) + activemodel (= 6.1.7.6) + activesupport (= 6.1.7.6) + activestorage (6.1.7.6) + actionpack (= 6.1.7.6) + activejob (= 6.1.7.6) + activerecord (= 6.1.7.6) + activesupport (= 6.1.7.6) marcel (~> 1.0) mini_mime (>= 1.1.0) - activesupport (6.1.7.3) + activesupport (6.1.7.6) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) @@ -80,13 +80,13 @@ GEM date (3.3.3) diff-lcs (1.5.0) erubi (1.12.0) - globalid (1.1.0) - activesupport (>= 5.0) + globalid (1.2.1) + activesupport (>= 6.1) i18n (1.14.1) concurrent-ruby (~> 1.0) iniparse (1.5.0) json (2.6.3) - loofah (2.21.3) + loofah (2.21.4) crass (~> 1.0.2) nokogiri (>= 1.12.0) mail (2.8.1) @@ -96,21 +96,21 @@ GEM net-smtp marcel (1.0.2) method_source (1.0.0) - mini_mime (1.1.2) - minitest (5.18.1) - net-imap (0.3.4) + mini_mime (1.1.5) + minitest (5.20.0) + net-imap (0.4.2) date net-protocol net-pop (0.1.2) net-protocol net-protocol (0.2.1) timeout - net-smtp (0.3.3) + net-smtp (0.4.0) net-protocol nio4r (2.5.9) - nokogiri (1.15.2-arm64-darwin) + nokogiri (1.15.4-arm64-darwin) racc (~> 1.4) - nokogiri (1.15.2-x86_64-linux) + nokogiri (1.15.4-x86_64-linux) racc (~> 1.4) overcommit (0.60.0) childprocess (>= 0.6.3, < 5) @@ -124,33 +124,34 @@ GEM coderay (~> 1.1) method_source (~> 1.0) racc (1.7.1) - rack (2.2.7) + rack (2.2.8) rack-test (2.1.0) rack (>= 1.3) - rails (6.1.7.3) - actioncable (= 6.1.7.3) - actionmailbox (= 6.1.7.3) - actionmailer (= 6.1.7.3) - actionpack (= 6.1.7.3) - actiontext (= 6.1.7.3) - actionview (= 6.1.7.3) - activejob (= 6.1.7.3) - activemodel (= 6.1.7.3) - activerecord (= 6.1.7.3) - activestorage (= 6.1.7.3) - activesupport (= 6.1.7.3) + rails (6.1.7.6) + actioncable (= 6.1.7.6) + actionmailbox (= 6.1.7.6) + actionmailer (= 6.1.7.6) + actionpack (= 6.1.7.6) + actiontext (= 6.1.7.6) + actionview (= 6.1.7.6) + activejob (= 6.1.7.6) + activemodel (= 6.1.7.6) + activerecord (= 6.1.7.6) + activestorage (= 6.1.7.6) + activesupport (= 6.1.7.6) bundler (>= 1.15.0) - railties (= 6.1.7.3) + railties (= 6.1.7.6) sprockets-rails (>= 2.0.0) - rails-dom-testing (2.0.3) - activesupport (>= 4.2.0) + rails-dom-testing (2.2.0) + activesupport (>= 5.0.0) + minitest nokogiri (>= 1.6) rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) - railties (6.1.7.3) - actionpack (= 6.1.7.3) - activesupport (= 6.1.7.3) + railties (6.1.7.6) + actionpack (= 6.1.7.6) + activesupport (= 6.1.7.6) method_source rake (>= 12.2) thor (~> 1.0) @@ -185,7 +186,7 @@ GEM rubocop-ast (1.29.0) parser (>= 3.2.1.0) ruby-progressbar (1.13.0) - sprockets (4.2.0) + sprockets (4.2.1) concurrent-ruby (~> 1.0) rack (>= 2.2.4, < 4) sprockets-rails (3.4.2) @@ -194,16 +195,16 @@ GEM sprockets (>= 3.0.0) sqlite3 (1.6.3-arm64-darwin) sqlite3 (1.6.3-x86_64-linux) - thor (1.2.2) + thor (1.3.0) timecop (0.9.6) - timeout (0.3.2) + timeout (0.4.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) unicode-display_width (2.4.2) - websocket-driver (0.7.5) + websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) - zeitwerk (2.6.8) + zeitwerk (2.6.12) PLATFORMS arm64-darwin-22 diff --git a/gemfiles/rails_7.0.gemfile b/gemfiles/rails_7.0.gemfile index 88cdc430..3f5a75ba 100644 --- a/gemfiles/rails_7.0.gemfile +++ b/gemfiles/rails_7.0.gemfile @@ -3,6 +3,6 @@ source "http://rubygems.org" gem "sqlite3", "~> 1.4" -gem "rails", "~> 7.0" +gem "rails", "~> 7.0.0" gemspec path: "../" diff --git a/gemfiles/rails_7.0.gemfile.lock b/gemfiles/rails_7.0.gemfile.lock index 56147e89..78ff6bba 100644 --- a/gemfiles/rails_7.0.gemfile.lock +++ b/gemfiles/rails_7.0.gemfile.lock @@ -8,67 +8,67 @@ PATH GEM remote: http://rubygems.org/ specs: - actioncable (7.0.6) - actionpack (= 7.0.6) - activesupport (= 7.0.6) + actioncable (7.0.8) + actionpack (= 7.0.8) + activesupport (= 7.0.8) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (7.0.6) - actionpack (= 7.0.6) - activejob (= 7.0.6) - activerecord (= 7.0.6) - activestorage (= 7.0.6) - activesupport (= 7.0.6) + actionmailbox (7.0.8) + actionpack (= 7.0.8) + activejob (= 7.0.8) + activerecord (= 7.0.8) + activestorage (= 7.0.8) + activesupport (= 7.0.8) mail (>= 2.7.1) net-imap net-pop net-smtp - actionmailer (7.0.6) - actionpack (= 7.0.6) - actionview (= 7.0.6) - activejob (= 7.0.6) - activesupport (= 7.0.6) + actionmailer (7.0.8) + actionpack (= 7.0.8) + actionview (= 7.0.8) + activejob (= 7.0.8) + activesupport (= 7.0.8) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp rails-dom-testing (~> 2.0) - actionpack (7.0.6) - actionview (= 7.0.6) - activesupport (= 7.0.6) + actionpack (7.0.8) + actionview (= 7.0.8) + activesupport (= 7.0.8) rack (~> 2.0, >= 2.2.4) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (7.0.6) - actionpack (= 7.0.6) - activerecord (= 7.0.6) - activestorage (= 7.0.6) - activesupport (= 7.0.6) + actiontext (7.0.8) + actionpack (= 7.0.8) + activerecord (= 7.0.8) + activestorage (= 7.0.8) + activesupport (= 7.0.8) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.0.6) - activesupport (= 7.0.6) + actionview (7.0.8) + activesupport (= 7.0.8) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (7.0.6) - activesupport (= 7.0.6) + activejob (7.0.8) + activesupport (= 7.0.8) globalid (>= 0.3.6) - activemodel (7.0.6) - activesupport (= 7.0.6) - activerecord (7.0.6) - activemodel (= 7.0.6) - activesupport (= 7.0.6) - activestorage (7.0.6) - actionpack (= 7.0.6) - activejob (= 7.0.6) - activerecord (= 7.0.6) - activesupport (= 7.0.6) + activemodel (7.0.8) + activesupport (= 7.0.8) + activerecord (7.0.8) + activemodel (= 7.0.8) + activesupport (= 7.0.8) + activestorage (7.0.8) + actionpack (= 7.0.8) + activejob (= 7.0.8) + activerecord (= 7.0.8) + activesupport (= 7.0.8) marcel (~> 1.0) mini_mime (>= 1.1.0) - activesupport (7.0.6) + activesupport (7.0.8) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) @@ -86,14 +86,14 @@ GEM date (3.3.3) diff-lcs (1.5.0) erubi (1.12.0) - globalid (1.1.0) - activesupport (>= 5.0) + globalid (1.2.1) + activesupport (>= 6.1) i18n (1.14.1) concurrent-ruby (~> 1.0) iniparse (1.5.0) json (2.6.3) language_server-protocol (3.17.0.3) - loofah (2.21.3) + loofah (2.21.4) crass (~> 1.0.2) nokogiri (>= 1.12.0) mail (2.8.1) @@ -103,21 +103,21 @@ GEM net-smtp marcel (1.0.2) method_source (1.0.0) - mini_mime (1.1.2) - minitest (5.18.1) - net-imap (0.3.6) + mini_mime (1.1.5) + minitest (5.20.0) + net-imap (0.4.2) date net-protocol net-pop (0.1.2) net-protocol net-protocol (0.2.1) timeout - net-smtp (0.3.3) + net-smtp (0.4.0) net-protocol nio4r (2.5.9) - nokogiri (1.15.3-arm64-darwin) + nokogiri (1.15.4-arm64-darwin) racc (~> 1.4) - nokogiri (1.15.3-x86_64-linux) + nokogiri (1.15.4-x86_64-linux) racc (~> 1.4) overcommit (0.60.0) childprocess (>= 0.6.3, < 5) @@ -131,33 +131,33 @@ GEM coderay (~> 1.1) method_source (~> 1.0) racc (1.7.1) - rack (2.2.7) + rack (2.2.8) rack-test (2.1.0) rack (>= 1.3) - rails (7.0.6) - actioncable (= 7.0.6) - actionmailbox (= 7.0.6) - actionmailer (= 7.0.6) - actionpack (= 7.0.6) - actiontext (= 7.0.6) - actionview (= 7.0.6) - activejob (= 7.0.6) - activemodel (= 7.0.6) - activerecord (= 7.0.6) - activestorage (= 7.0.6) - activesupport (= 7.0.6) + rails (7.0.8) + actioncable (= 7.0.8) + actionmailbox (= 7.0.8) + actionmailer (= 7.0.8) + actionpack (= 7.0.8) + actiontext (= 7.0.8) + actionview (= 7.0.8) + activejob (= 7.0.8) + activemodel (= 7.0.8) + activerecord (= 7.0.8) + activestorage (= 7.0.8) + activesupport (= 7.0.8) bundler (>= 1.15.0) - railties (= 7.0.6) - rails-dom-testing (2.1.1) + railties (= 7.0.8) + rails-dom-testing (2.2.0) activesupport (>= 5.0.0) minitest nokogiri (>= 1.6) rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) - railties (7.0.6) - actionpack (= 7.0.6) - activesupport (= 7.0.6) + railties (7.0.8) + actionpack (= 7.0.8) + activesupport (= 7.0.8) method_source rake (>= 12.2) thor (~> 1.0) @@ -196,16 +196,16 @@ GEM ruby-progressbar (1.13.0) sqlite3 (1.6.3-arm64-darwin) sqlite3 (1.6.3-x86_64-linux) - thor (1.2.2) + thor (1.3.0) timecop (0.9.6) timeout (0.4.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) unicode-display_width (2.4.2) - websocket-driver (0.7.5) + websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) - zeitwerk (2.6.8) + zeitwerk (2.6.12) PLATFORMS arm64-darwin-22 @@ -216,7 +216,7 @@ DEPENDENCIES data_migrate! overcommit pry - rails (~> 7.0) + rails (~> 7.0.0) rake rb-readline rspec diff --git a/gemfiles/rails_7.1.gemfile.lock b/gemfiles/rails_7.1.gemfile.lock index 9ab273eb..3e7d23c3 100644 --- a/gemfiles/rails_7.1.gemfile.lock +++ b/gemfiles/rails_7.1.gemfile.lock @@ -105,12 +105,12 @@ GEM concurrent-ruby (~> 1.0) iniparse (1.5.0) io-console (0.6.0) - irb (1.8.1) + irb (1.8.3) rdoc reline (>= 0.3.8) json (2.6.3) language_server-protocol (3.17.0.3) - loofah (2.21.3) + loofah (2.21.4) crass (~> 1.0.2) nokogiri (>= 1.12.0) mail (2.8.1) @@ -123,7 +123,7 @@ GEM mini_mime (1.1.5) minitest (5.20.0) mutex_m (0.1.2) - net-imap (0.4.0) + net-imap (0.4.2) date net-protocol net-pop (0.1.2) @@ -148,7 +148,7 @@ GEM pry (0.14.2) coderay (~> 1.1) method_source (~> 1.0) - psych (5.1.0) + psych (5.1.1.1) stringio racc (1.7.1) rack (3.0.8) @@ -228,7 +228,7 @@ GEM sqlite3 (1.6.3-arm64-darwin) sqlite3 (1.6.3-x86_64-linux) stringio (3.0.8) - thor (1.2.2) + thor (1.3.0) timecop (0.9.6) timeout (0.4.0) tzinfo (2.0.6) From 8ef20e149374f4dab7e790daa56522d24126786d Mon Sep 17 00:00:00 2001 From: Maple Ong Date: Fri, 22 Dec 2023 13:30:41 -0500 Subject: [PATCH 64/98] Use extend self --- lib/data_migrate/database_tasks.rb | 127 ++++++++++++++--------------- 1 file changed, 63 insertions(+), 64 deletions(-) diff --git a/lib/data_migrate/database_tasks.rb b/lib/data_migrate/database_tasks.rb index 333f9e9f..3c8535ba 100644 --- a/lib/data_migrate/database_tasks.rb +++ b/lib/data_migrate/database_tasks.rb @@ -7,85 +7,84 @@ module DataMigrate # This class extends DatabaseTasks to add a schema_file method. class DatabaseTasks extend ActiveRecord::Tasks::DatabaseTasks + extend self - class << self - def schema_file(_format = nil) - File.join(db_dir, "data_schema.rb") - end - - def schema_file_type(_format = nil) - "data_schema.rb" - end + def schema_file(_format = nil) + File.join(db_dir, "data_schema.rb") + end - # This method is removed in Rails 7.0 - def dump_filename(spec_name, format = ActiveRecord::Base.schema_format) - filename = if spec_name == "primary" - schema_file_type(format) - else - "#{spec_name}_#{schema_file_type(format)}" - end + def schema_file_type(_format = nil) + "data_schema.rb" + end - ENV["DATA_SCHEMA"] || File.join(db_dir, filename) + # This method is removed in Rails 7.0 + def dump_filename(spec_name, format = ActiveRecord::Base.schema_format) + filename = if spec_name == "primary" + schema_file_type(format) + else + "#{spec_name}_#{schema_file_type(format)}" end - def check_schema_file(filename) - unless File.exist?(filename) - message = +%{#{filename} doesn't exist yet. Run `rake data:migrate` to create it, then try again.} - Kernel.abort message - end - end + ENV["DATA_SCHEMA"] || File.join(db_dir, filename) + end - def pending_migrations - sort_migrations( - pending_schema_migrations, - pending_data_migrations - ) + def check_schema_file(filename) + unless File.exist?(filename) + message = +%{#{filename} doesn't exist yet. Run `rake data:migrate` to create it, then try again.} + Kernel.abort message end + end - def sort_migrations(*migrations) - migrations.flatten.sort { |a, b| sort_string(a) <=> sort_string(b) } - end + def pending_migrations + sort_migrations( + pending_schema_migrations, + pending_data_migrations + ) + end - def sort_string migration - "#{migration[:version]}_#{migration[:kind] == :data ? 1 : 0}" - end + def sort_migrations(*migrations) + migrations.flatten.sort { |a, b| sort_string(a) <=> sort_string(b) } + end - def data_migrations_path - ::DataMigrate.config.data_migrations_path - end + def sort_string migration + "#{migration[:version]}_#{migration[:kind] == :data ? 1 : 0}" + end - def run_migration(migration, direction) - if migration[:kind] == :data - ::ActiveRecord::Migration.write("== %s %s" % ['Data', "=" * 71]) - ::DataMigrate::DataMigrator.run(direction, data_migrations_path, migration[:version]) - else - ::ActiveRecord::Migration.write("== %s %s" % ['Schema', "=" * 69]) - ::DataMigrate::SchemaMigration.run( - direction, - ::DataMigrate::SchemaMigration.migrations_paths, - migration[:version] - ) - end + def data_migrations_path + ::DataMigrate.config.data_migrations_path + end + + def run_migration(migration, direction) + if migration[:kind] == :data + ::ActiveRecord::Migration.write("== %s %s" % ['Data', "=" * 71]) + ::DataMigrate::DataMigrator.run(direction, data_migrations_path, migration[:version]) + else + ::ActiveRecord::Migration.write("== %s %s" % ['Schema', "=" * 69]) + ::DataMigrate::SchemaMigration.run( + direction, + ::DataMigrate::SchemaMigration.migrations_paths, + migration[:version] + ) end + end - def schema_dump_path(db_config, format = ActiveRecord.schema_format) - return ENV["DATA_SCHEMA"] if ENV["DATA_SCHEMA"] + def schema_dump_path(db_config, format = ActiveRecord.schema_format) + return ENV["DATA_SCHEMA"] if ENV["DATA_SCHEMA"] - # We only require a schema.rb file for the primary database - return unless db_config.primary? + # We only require a schema.rb file for the primary database + return unless db_config.primary? - File.join(File.dirname(ActiveRecord::Tasks::DatabaseTasks.schema_dump_path(db_config, format)), schema_file_type) - end + File.join(File.dirname(ActiveRecord::Tasks::DatabaseTasks.schema_dump_path(db_config, format)), schema_file_type) + end - # Override this method from `ActiveRecord::Tasks::DatabaseTasks` - # to ensure that the sha saved in ar_internal_metadata table - # is from the original schema.rb file - def schema_sha1(file) - ActiveRecord::Tasks::DatabaseTasks.schema_dump_path(ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env, name: "primary")) - end + # Override this method from `ActiveRecord::Tasks::DatabaseTasks` + # to ensure that the sha saved in ar_internal_metadata table + # is from the original schema.rb file + def schema_sha1(file) + ActiveRecord::Tasks::DatabaseTasks.schema_dump_path(ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env, name: "primary")) end - def self.forward(step = 1) + def forward(step = 1) DataMigrate::DataMigrator.create_data_schema_table migrations = pending_migrations.reverse.pop(step).reverse migrations.each do | pending_migration | @@ -99,7 +98,7 @@ def self.forward(step = 1) end end - def self.pending_data_migrations + def pending_data_migrations data_migrations = DataMigrate::DataMigrator.migrations(data_migrations_path) data_migrator = DataMigrate::RailsHelper.data_migrator(:up, data_migrations) sort_migrations( @@ -107,11 +106,11 @@ def self.pending_data_migrations ) end - def self.pending_schema_migrations + def pending_schema_migrations ::DataMigrate::SchemaMigration.pending_schema_migrations end - def self.past_migrations(sort = nil) + def past_migrations(sort = nil) data_versions = DataMigrate::RailsHelper.data_schema_migration.table_exists? ? DataMigrate::RailsHelper.data_schema_migration.normalized_versions : [] schema_versions = DataMigrate::RailsHelper.schema_migration.normalized_versions migrations = data_versions.map { |v| { version: v.to_i, kind: :data } } + schema_versions.map { |v| { version: v.to_i, kind: :schema } } From 740ed4969c0863648036634f92e922bdda3a5018 Mon Sep 17 00:00:00 2001 From: Maple Ong Date: Fri, 22 Dec 2023 13:56:19 -0500 Subject: [PATCH 65/98] Add required methods from rails --- lib/data_migrate/database_tasks.rb | 56 +++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/lib/data_migrate/database_tasks.rb b/lib/data_migrate/database_tasks.rb index 3c8535ba..f1301f66 100644 --- a/lib/data_migrate/database_tasks.rb +++ b/lib/data_migrate/database_tasks.rb @@ -5,10 +5,64 @@ module DataMigrate ## # This class extends DatabaseTasks to add a schema_file method. - class DatabaseTasks + module DatabaseTasks extend ActiveRecord::Tasks::DatabaseTasks extend self + # These method are only introduced in Rails 7.1 + unless respond_to?(:with_temporary_connection_for_each) + def with_temporary_connection_for_each(env: ActiveRecord::Tasks::DatabaseTasks.env, name: nil, &block) # :nodoc: + if name + db_config = ActiveRecord::Base.configurations.configs_for(env_name: env, name: name) + with_temporary_connection(db_config, &block) + else + ActiveRecord::Base.configurations.configs_for(env_name: env, name: name).each do |db_config| + with_temporary_connection(db_config, &block) + end + end + end + + def with_temporary_connection(db_config) # :nodoc: + with_temporary_pool(db_config) do |pool| + yield pool.connection + end + end + + def migration_class # :nodoc: + ActiveRecord::Base + end + + def migration_connection # :nodoc: + migration_class.connection + end + + private def with_temporary_pool(db_config) + original_db_config = migration_class.connection_db_config + pool = migration_class.connection_handler.establish_connection(db_config) + + yield pool + ensure + migration_class.connection_handler.establish_connection(original_db_config) + end + end + + def db_configs_with_versions + db_configs_with_versions = Hash.new { |h, k| h[k] = [] } + + with_temporary_connection_for_each do |conn| + db_config = conn.pool.db_config + versions_to_run = conn.migration_context.pending_migration_versions + target_version = ActiveRecord::Tasks::DatabaseTasks.target_version + + versions_to_run.each do |version| + next if target_version && target_version != version + db_configs_with_versions[version] << db_config + end + end + + db_configs_with_versions + end + def schema_file(_format = nil) File.join(db_dir, "data_schema.rb") end From c8588dd4b76015ca0fa5869b21eee48bf6bb6033 Mon Sep 17 00:00:00 2001 From: Maple Ong Date: Wed, 10 Jan 2024 15:05:41 -0500 Subject: [PATCH 66/98] Refactor db:migrate:with_data --- lib/data_migrate.rb | 1 + .../database_configurations_wrapper.rb | 11 ++++ lib/data_migrate/database_tasks.rb | 17 +++--- lib/data_migrate/test.rb | 14 +++++ tasks/databases.rake | 59 +++++++------------ 5 files changed, 56 insertions(+), 46 deletions(-) create mode 100644 lib/data_migrate/database_configurations_wrapper.rb create mode 100644 lib/data_migrate/test.rb diff --git a/lib/data_migrate.rb b/lib/data_migrate.rb index 18705c2d..d85d1639 100644 --- a/lib/data_migrate.rb +++ b/lib/data_migrate.rb @@ -12,6 +12,7 @@ require File.join(File.dirname(__FILE__), "data_migrate", "tasks/data_migrate_tasks") require File.join(File.dirname(__FILE__), "data_migrate", "config") require File.join(File.dirname(__FILE__), "data_migrate", "schema_migration") +require File.join(File.dirname(__FILE__), "data_migrate", "database_configurations_wrapper") module DataMigrate def self.root diff --git a/lib/data_migrate/database_configurations_wrapper.rb b/lib/data_migrate/database_configurations_wrapper.rb new file mode 100644 index 00000000..b343fcd3 --- /dev/null +++ b/lib/data_migrate/database_configurations_wrapper.rb @@ -0,0 +1,11 @@ +module DataMigrate + # This wrapper is used to differentiate between + # a data and schema db config when running migrations + class DatabaseConfigurationWrapper + attr_reader :db_config + + def initialize(db_config) + @db_config = db_config + end + end +end diff --git a/lib/data_migrate/database_tasks.rb b/lib/data_migrate/database_tasks.rb index f1301f66..d6d7af06 100644 --- a/lib/data_migrate/database_tasks.rb +++ b/lib/data_migrate/database_tasks.rb @@ -24,7 +24,7 @@ def with_temporary_connection_for_each(env: ActiveRecord::Tasks::DatabaseTasks.e def with_temporary_connection(db_config) # :nodoc: with_temporary_pool(db_config) do |pool| - yield pool.connection + yield pool.connection, db_config end end @@ -49,14 +49,15 @@ def migration_connection # :nodoc: def db_configs_with_versions db_configs_with_versions = Hash.new { |h, k| h[k] = [] } - with_temporary_connection_for_each do |conn| - db_config = conn.pool.db_config - versions_to_run = conn.migration_context.pending_migration_versions - target_version = ActiveRecord::Tasks::DatabaseTasks.target_version + with_temporary_connection_for_each do |conn, db_config| + if db_config.primary? + versions_to_run = DataMigrate::DatabaseTasks.pending_data_migrations.map { |m| m[:version] } + target_version = ActiveRecord::Tasks::DatabaseTasks.target_version - versions_to_run.each do |version| - next if target_version && target_version != version - db_configs_with_versions[version] << db_config + versions_to_run.each do |version| + next if target_version && target_version != version + db_configs_with_versions[version] << DatabaseConfigurationWrapper.new(db_config) + end end end diff --git a/lib/data_migrate/test.rb b/lib/data_migrate/test.rb new file mode 100644 index 00000000..e0e8010a --- /dev/null +++ b/lib/data_migrate/test.rb @@ -0,0 +1,14 @@ +module Base + extend self + + def foo + puts "Base#foo called" + end +end + +module Child + extend Base + extend self + + puts "foo: #{respond_to?(:foo)}" +end diff --git a/tasks/databases.rake b/tasks/databases.rake index e02e7f7b..4ca696cd 100644 --- a/tasks/databases.rake +++ b/tasks/databases.rake @@ -7,48 +7,31 @@ namespace :db do desc "Migrate the database data and schema (options: VERSION=x, VERBOSE=false)." task :with_data => :environment do DataMigrate::DataMigrator.create_data_schema_table - ActiveRecord::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true - target_version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil - migrations = [] - if target_version.nil? - migrations = DataMigrate::DatabaseTasks.pending_migrations.map{ |m| m.merge(:direction =>:up) } - else - current_schema_version = ActiveRecord::Migrator.current_version - schema_migrations = if target_version > current_schema_version - DataMigrate::DatabaseTasks.pending_schema_migrations.keep_if{ |m| m[:version] <= target_version }.map{ |m| m.merge(:direction =>:up) } - elsif target_version < current_schema_version - DataMigrate::DatabaseTasks.past_migrations.keep_if{ |m| m[:version] > target_version }.map{ |m| m.merge(:direction =>:down) } - else # == - [] - end - - current_data_version = DataMigrate::DataMigrator.current_version - data_migrations = if target_version > current_data_version - DataMigrate::DatabaseTasks.pending_data_migrations.keep_if{ |m| m[:version] <= target_version }.map{ |m| m.merge(:direction =>:up) } - elsif target_version < current_data_version - DataMigrate::DatabaseTasks.past_migrations.keep_if{ |m| m[:version] > target_version }.map{ |m| m.merge(:direction =>:down) } - else # == - [] - end - migrations = if schema_migrations.empty? - data_migrations - elsif data_migrations.empty? - schema_migrations - elsif target_version > current_data_version && target_version > current_schema_version - DataMigrate::DatabaseTasks.sort_migrations data_migrations, schema_migrations - elsif target_version < current_data_version && target_version < current_schema_version - DataMigrate::DatabaseTasks.sort_migrations(data_migrations, schema_migrations).reverse - elsif target_version > current_data_version && target_version < current_schema_version - schema_migrations + data_migrations - elsif target_version < current_data_version && target_version > current_schema_version - schema_migrations + data_migrations - end + db_configs = ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env) + + schema_mapped_versions = ActiveRecord::Tasks::DatabaseTasks.db_configs_with_versions(db_configs) + data_mapped_versions = DataMigrate::DatabaseTasks.db_configs_with_versions + + mapped_versions = schema_mapped_versions.merge(data_mapped_versions) do |_key, schema_db_configs, data_db_configs| + schema_db_configs + data_db_configs end - migrations.each do |migration| - DataMigrate::DatabaseTasks.run_migration(migration, migration[:direction]) + mapped_versions.sort.each do |version, db_configs| + db_configs.each do |db_config| + if is_data_migration = db_config.is_a?(DataMigrate::DatabaseConfigurationWrapper) + db_config = db_config.db_config + end + + DataMigrate::DatabaseTasks.with_temporary_connection(db_config) do + if is_data_migration + DataMigrate::DataMigrator.run(:up, DataMigrate::DatabaseTasks.data_migrations_path, version) + else + ActiveRecord::Tasks::DatabaseTasks.migrate(version) + end + end + end end Rake::Task["db:_dump"].invoke From f76727e4b3ea2ba53431d9efa12ababddbd40b35 Mon Sep 17 00:00:00 2001 From: m-nakamura145 Date: Fri, 12 Jan 2024 00:33:07 +0900 Subject: [PATCH 67/98] Add Ruby 3.3 to CI matrix --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a8d44d0a..de73c902 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,6 +14,7 @@ jobs: - '3.0' - '3.1' - '3.2' + - '3.3' gemfile: - gemfiles/rails_6.1.gemfile - gemfiles/rails_7.0.gemfile From c5a86b4c4c16d4b1005d2ac6a81e1a0b15e29040 Mon Sep 17 00:00:00 2001 From: Maple Ong Date: Wed, 17 Jan 2024 10:03:31 -0500 Subject: [PATCH 68/98] Remove db_config from yield arguments --- lib/data_migrate/database_tasks.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/data_migrate/database_tasks.rb b/lib/data_migrate/database_tasks.rb index d6d7af06..38a2a2fa 100644 --- a/lib/data_migrate/database_tasks.rb +++ b/lib/data_migrate/database_tasks.rb @@ -24,7 +24,7 @@ def with_temporary_connection_for_each(env: ActiveRecord::Tasks::DatabaseTasks.e def with_temporary_connection(db_config) # :nodoc: with_temporary_pool(db_config) do |pool| - yield pool.connection, db_config + yield pool.connection end end @@ -49,7 +49,8 @@ def migration_connection # :nodoc: def db_configs_with_versions db_configs_with_versions = Hash.new { |h, k| h[k] = [] } - with_temporary_connection_for_each do |conn, db_config| + with_temporary_connection_for_each do |conn| + db_config = conn.pool.db_config if db_config.primary? versions_to_run = DataMigrate::DatabaseTasks.pending_data_migrations.map { |m| m[:version] } target_version = ActiveRecord::Tasks::DatabaseTasks.target_version From 1c7b0436c0b1240cf136512c459c489b3d76f36a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 6 Feb 2024 03:36:36 +0000 Subject: [PATCH 69/98] Bump nokogiri from 1.15.3 to 1.16.2 Bumps [nokogiri](https://github.com/sparklemotion/nokogiri) from 1.15.3 to 1.16.2. - [Release notes](https://github.com/sparklemotion/nokogiri/releases) - [Changelog](https://github.com/sparklemotion/nokogiri/blob/main/CHANGELOG.md) - [Commits](https://github.com/sparklemotion/nokogiri/compare/v1.15.3...v1.16.2) --- updated-dependencies: - dependency-name: nokogiri dependency-type: indirect ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 235df4ba..ec5fc13c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -53,9 +53,9 @@ GEM nokogiri (>= 1.12.0) method_source (1.0.0) minitest (5.19.0) - nokogiri (1.15.3-arm64-darwin) + nokogiri (1.16.2-arm64-darwin) racc (~> 1.4) - nokogiri (1.15.3-x86_64-linux) + nokogiri (1.16.2-x86_64-linux) racc (~> 1.4) overcommit (0.60.0) childprocess (>= 0.6.3, < 5) @@ -68,7 +68,7 @@ GEM pry (0.14.2) coderay (~> 1.1) method_source (~> 1.0) - racc (1.7.1) + racc (1.7.3) rack (2.2.7) rack-test (2.1.0) rack (>= 1.3) From 9a68a960b49994a33e147d84f5c6d9138bb8a91d Mon Sep 17 00:00:00 2001 From: Ngan Pham Date: Tue, 27 Feb 2024 11:17:47 -0800 Subject: [PATCH 70/98] Bump gems --- gemfiles/rails_6.1.gemfile.lock | 140 ++++++++++++++++---------------- gemfiles/rails_7.0.gemfile.lock | 140 ++++++++++++++++---------------- gemfiles/rails_7.1.gemfile.lock | 54 ++++++------ 3 files changed, 167 insertions(+), 167 deletions(-) diff --git a/gemfiles/rails_6.1.gemfile.lock b/gemfiles/rails_6.1.gemfile.lock index d715b44c..42bbde69 100644 --- a/gemfiles/rails_6.1.gemfile.lock +++ b/gemfiles/rails_6.1.gemfile.lock @@ -8,60 +8,60 @@ PATH GEM remote: http://rubygems.org/ specs: - actioncable (6.1.7.6) - actionpack (= 6.1.7.6) - activesupport (= 6.1.7.6) + actioncable (6.1.7.7) + actionpack (= 6.1.7.7) + activesupport (= 6.1.7.7) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (6.1.7.6) - actionpack (= 6.1.7.6) - activejob (= 6.1.7.6) - activerecord (= 6.1.7.6) - activestorage (= 6.1.7.6) - activesupport (= 6.1.7.6) + actionmailbox (6.1.7.7) + actionpack (= 6.1.7.7) + activejob (= 6.1.7.7) + activerecord (= 6.1.7.7) + activestorage (= 6.1.7.7) + activesupport (= 6.1.7.7) mail (>= 2.7.1) - actionmailer (6.1.7.6) - actionpack (= 6.1.7.6) - actionview (= 6.1.7.6) - activejob (= 6.1.7.6) - activesupport (= 6.1.7.6) + actionmailer (6.1.7.7) + actionpack (= 6.1.7.7) + actionview (= 6.1.7.7) + activejob (= 6.1.7.7) + activesupport (= 6.1.7.7) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (6.1.7.6) - actionview (= 6.1.7.6) - activesupport (= 6.1.7.6) + actionpack (6.1.7.7) + actionview (= 6.1.7.7) + activesupport (= 6.1.7.7) rack (~> 2.0, >= 2.0.9) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (6.1.7.6) - actionpack (= 6.1.7.6) - activerecord (= 6.1.7.6) - activestorage (= 6.1.7.6) - activesupport (= 6.1.7.6) + actiontext (6.1.7.7) + actionpack (= 6.1.7.7) + activerecord (= 6.1.7.7) + activestorage (= 6.1.7.7) + activesupport (= 6.1.7.7) nokogiri (>= 1.8.5) - actionview (6.1.7.6) - activesupport (= 6.1.7.6) + actionview (6.1.7.7) + activesupport (= 6.1.7.7) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (6.1.7.6) - activesupport (= 6.1.7.6) + activejob (6.1.7.7) + activesupport (= 6.1.7.7) globalid (>= 0.3.6) - activemodel (6.1.7.6) - activesupport (= 6.1.7.6) - activerecord (6.1.7.6) - activemodel (= 6.1.7.6) - activesupport (= 6.1.7.6) - activestorage (6.1.7.6) - actionpack (= 6.1.7.6) - activejob (= 6.1.7.6) - activerecord (= 6.1.7.6) - activesupport (= 6.1.7.6) + activemodel (6.1.7.7) + activesupport (= 6.1.7.7) + activerecord (6.1.7.7) + activemodel (= 6.1.7.7) + activesupport (= 6.1.7.7) + activestorage (6.1.7.7) + actionpack (= 6.1.7.7) + activejob (= 6.1.7.7) + activerecord (= 6.1.7.7) + activesupport (= 6.1.7.7) marcel (~> 1.0) mini_mime (>= 1.1.0) - activesupport (6.1.7.6) + activesupport (6.1.7.7) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) @@ -75,9 +75,9 @@ GEM builder (3.2.4) childprocess (4.1.0) coderay (1.1.3) - concurrent-ruby (1.2.2) + concurrent-ruby (1.2.3) crass (1.0.6) - date (3.3.3) + date (3.3.4) diff-lcs (1.5.0) erubi (1.12.0) globalid (1.2.1) @@ -86,7 +86,7 @@ GEM concurrent-ruby (~> 1.0) iniparse (1.5.0) json (2.6.3) - loofah (2.21.4) + loofah (2.22.0) crass (~> 1.0.2) nokogiri (>= 1.12.0) mail (2.8.1) @@ -97,20 +97,20 @@ GEM marcel (1.0.2) method_source (1.0.0) mini_mime (1.1.5) - minitest (5.20.0) - net-imap (0.4.2) + minitest (5.22.2) + net-imap (0.4.10) date net-protocol net-pop (0.1.2) net-protocol - net-protocol (0.2.1) + net-protocol (0.2.2) timeout - net-smtp (0.4.0) + net-smtp (0.4.0.1) net-protocol - nio4r (2.5.9) - nokogiri (1.15.4-arm64-darwin) + nio4r (2.7.0) + nokogiri (1.16.2-arm64-darwin) racc (~> 1.4) - nokogiri (1.15.4-x86_64-linux) + nokogiri (1.16.2-x86_64-linux) racc (~> 1.4) overcommit (0.60.0) childprocess (>= 0.6.3, < 5) @@ -123,24 +123,24 @@ GEM pry (0.14.2) coderay (~> 1.1) method_source (~> 1.0) - racc (1.7.1) - rack (2.2.8) + racc (1.7.3) + rack (2.2.8.1) rack-test (2.1.0) rack (>= 1.3) - rails (6.1.7.6) - actioncable (= 6.1.7.6) - actionmailbox (= 6.1.7.6) - actionmailer (= 6.1.7.6) - actionpack (= 6.1.7.6) - actiontext (= 6.1.7.6) - actionview (= 6.1.7.6) - activejob (= 6.1.7.6) - activemodel (= 6.1.7.6) - activerecord (= 6.1.7.6) - activestorage (= 6.1.7.6) - activesupport (= 6.1.7.6) + rails (6.1.7.7) + actioncable (= 6.1.7.7) + actionmailbox (= 6.1.7.7) + actionmailer (= 6.1.7.7) + actionpack (= 6.1.7.7) + actiontext (= 6.1.7.7) + actionview (= 6.1.7.7) + activejob (= 6.1.7.7) + activemodel (= 6.1.7.7) + activerecord (= 6.1.7.7) + activestorage (= 6.1.7.7) + activesupport (= 6.1.7.7) bundler (>= 1.15.0) - railties (= 6.1.7.6) + railties (= 6.1.7.7) sprockets-rails (>= 2.0.0) rails-dom-testing (2.2.0) activesupport (>= 5.0.0) @@ -149,14 +149,14 @@ GEM rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) - railties (6.1.7.6) - actionpack (= 6.1.7.6) - activesupport (= 6.1.7.6) + railties (6.1.7.7) + actionpack (= 6.1.7.7) + activesupport (= 6.1.7.7) method_source rake (>= 12.2) thor (~> 1.0) rainbow (3.1.1) - rake (13.0.6) + rake (13.1.0) rb-readline (0.5.5) regexp_parser (2.8.1) rexml (3.2.5) @@ -195,16 +195,16 @@ GEM sprockets (>= 3.0.0) sqlite3 (1.6.3-arm64-darwin) sqlite3 (1.6.3-x86_64-linux) - thor (1.3.0) + thor (1.3.1) timecop (0.9.6) - timeout (0.4.0) + timeout (0.4.1) tzinfo (2.0.6) concurrent-ruby (~> 1.0) unicode-display_width (2.4.2) websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) - zeitwerk (2.6.12) + zeitwerk (2.6.13) PLATFORMS arm64-darwin-22 @@ -225,4 +225,4 @@ DEPENDENCIES timecop BUNDLED WITH - 2.4.14 + 2.5.6 diff --git a/gemfiles/rails_7.0.gemfile.lock b/gemfiles/rails_7.0.gemfile.lock index 78ff6bba..ab0e766d 100644 --- a/gemfiles/rails_7.0.gemfile.lock +++ b/gemfiles/rails_7.0.gemfile.lock @@ -8,67 +8,67 @@ PATH GEM remote: http://rubygems.org/ specs: - actioncable (7.0.8) - actionpack (= 7.0.8) - activesupport (= 7.0.8) + actioncable (7.0.8.1) + actionpack (= 7.0.8.1) + activesupport (= 7.0.8.1) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (7.0.8) - actionpack (= 7.0.8) - activejob (= 7.0.8) - activerecord (= 7.0.8) - activestorage (= 7.0.8) - activesupport (= 7.0.8) + actionmailbox (7.0.8.1) + actionpack (= 7.0.8.1) + activejob (= 7.0.8.1) + activerecord (= 7.0.8.1) + activestorage (= 7.0.8.1) + activesupport (= 7.0.8.1) mail (>= 2.7.1) net-imap net-pop net-smtp - actionmailer (7.0.8) - actionpack (= 7.0.8) - actionview (= 7.0.8) - activejob (= 7.0.8) - activesupport (= 7.0.8) + actionmailer (7.0.8.1) + actionpack (= 7.0.8.1) + actionview (= 7.0.8.1) + activejob (= 7.0.8.1) + activesupport (= 7.0.8.1) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp rails-dom-testing (~> 2.0) - actionpack (7.0.8) - actionview (= 7.0.8) - activesupport (= 7.0.8) + actionpack (7.0.8.1) + actionview (= 7.0.8.1) + activesupport (= 7.0.8.1) rack (~> 2.0, >= 2.2.4) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (7.0.8) - actionpack (= 7.0.8) - activerecord (= 7.0.8) - activestorage (= 7.0.8) - activesupport (= 7.0.8) + actiontext (7.0.8.1) + actionpack (= 7.0.8.1) + activerecord (= 7.0.8.1) + activestorage (= 7.0.8.1) + activesupport (= 7.0.8.1) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.0.8) - activesupport (= 7.0.8) + actionview (7.0.8.1) + activesupport (= 7.0.8.1) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (7.0.8) - activesupport (= 7.0.8) + activejob (7.0.8.1) + activesupport (= 7.0.8.1) globalid (>= 0.3.6) - activemodel (7.0.8) - activesupport (= 7.0.8) - activerecord (7.0.8) - activemodel (= 7.0.8) - activesupport (= 7.0.8) - activestorage (7.0.8) - actionpack (= 7.0.8) - activejob (= 7.0.8) - activerecord (= 7.0.8) - activesupport (= 7.0.8) + activemodel (7.0.8.1) + activesupport (= 7.0.8.1) + activerecord (7.0.8.1) + activemodel (= 7.0.8.1) + activesupport (= 7.0.8.1) + activestorage (7.0.8.1) + actionpack (= 7.0.8.1) + activejob (= 7.0.8.1) + activerecord (= 7.0.8.1) + activesupport (= 7.0.8.1) marcel (~> 1.0) mini_mime (>= 1.1.0) - activesupport (7.0.8) + activesupport (7.0.8.1) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) @@ -81,9 +81,9 @@ GEM builder (3.2.4) childprocess (4.1.0) coderay (1.1.3) - concurrent-ruby (1.2.2) + concurrent-ruby (1.2.3) crass (1.0.6) - date (3.3.3) + date (3.3.4) diff-lcs (1.5.0) erubi (1.12.0) globalid (1.2.1) @@ -93,7 +93,7 @@ GEM iniparse (1.5.0) json (2.6.3) language_server-protocol (3.17.0.3) - loofah (2.21.4) + loofah (2.22.0) crass (~> 1.0.2) nokogiri (>= 1.12.0) mail (2.8.1) @@ -104,20 +104,20 @@ GEM marcel (1.0.2) method_source (1.0.0) mini_mime (1.1.5) - minitest (5.20.0) - net-imap (0.4.2) + minitest (5.22.2) + net-imap (0.4.10) date net-protocol net-pop (0.1.2) net-protocol - net-protocol (0.2.1) + net-protocol (0.2.2) timeout - net-smtp (0.4.0) + net-smtp (0.4.0.1) net-protocol - nio4r (2.5.9) - nokogiri (1.15.4-arm64-darwin) + nio4r (2.7.0) + nokogiri (1.16.2-arm64-darwin) racc (~> 1.4) - nokogiri (1.15.4-x86_64-linux) + nokogiri (1.16.2-x86_64-linux) racc (~> 1.4) overcommit (0.60.0) childprocess (>= 0.6.3, < 5) @@ -130,24 +130,24 @@ GEM pry (0.14.2) coderay (~> 1.1) method_source (~> 1.0) - racc (1.7.1) - rack (2.2.8) + racc (1.7.3) + rack (2.2.8.1) rack-test (2.1.0) rack (>= 1.3) - rails (7.0.8) - actioncable (= 7.0.8) - actionmailbox (= 7.0.8) - actionmailer (= 7.0.8) - actionpack (= 7.0.8) - actiontext (= 7.0.8) - actionview (= 7.0.8) - activejob (= 7.0.8) - activemodel (= 7.0.8) - activerecord (= 7.0.8) - activestorage (= 7.0.8) - activesupport (= 7.0.8) + rails (7.0.8.1) + actioncable (= 7.0.8.1) + actionmailbox (= 7.0.8.1) + actionmailer (= 7.0.8.1) + actionpack (= 7.0.8.1) + actiontext (= 7.0.8.1) + actionview (= 7.0.8.1) + activejob (= 7.0.8.1) + activemodel (= 7.0.8.1) + activerecord (= 7.0.8.1) + activestorage (= 7.0.8.1) + activesupport (= 7.0.8.1) bundler (>= 1.15.0) - railties (= 7.0.8) + railties (= 7.0.8.1) rails-dom-testing (2.2.0) activesupport (>= 5.0.0) minitest @@ -155,15 +155,15 @@ GEM rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) - railties (7.0.8) - actionpack (= 7.0.8) - activesupport (= 7.0.8) + railties (7.0.8.1) + actionpack (= 7.0.8.1) + activesupport (= 7.0.8.1) method_source rake (>= 12.2) thor (~> 1.0) zeitwerk (~> 2.5) rainbow (3.1.1) - rake (13.0.6) + rake (13.1.0) rb-readline (0.5.5) regexp_parser (2.8.1) rexml (3.2.5) @@ -196,16 +196,16 @@ GEM ruby-progressbar (1.13.0) sqlite3 (1.6.3-arm64-darwin) sqlite3 (1.6.3-x86_64-linux) - thor (1.3.0) + thor (1.3.1) timecop (0.9.6) - timeout (0.4.0) + timeout (0.4.1) tzinfo (2.0.6) concurrent-ruby (~> 1.0) unicode-display_width (2.4.2) websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) - zeitwerk (2.6.12) + zeitwerk (2.6.13) PLATFORMS arm64-darwin-22 @@ -226,4 +226,4 @@ DEPENDENCIES timecop BUNDLED WITH - 2.4.14 + 2.5.6 diff --git a/gemfiles/rails_7.1.gemfile.lock b/gemfiles/rails_7.1.gemfile.lock index 3e7d23c3..247f5e16 100644 --- a/gemfiles/rails_7.1.gemfile.lock +++ b/gemfiles/rails_7.1.gemfile.lock @@ -86,17 +86,17 @@ GEM rake thor (>= 0.14.0) ast (2.4.2) - base64 (0.1.1) - bigdecimal (3.1.4) + base64 (0.2.0) + bigdecimal (3.1.6) builder (3.2.4) childprocess (4.1.0) coderay (1.1.3) - concurrent-ruby (1.2.2) + concurrent-ruby (1.2.3) connection_pool (2.4.1) crass (1.0.6) - date (3.3.3) + date (3.3.4) diff-lcs (1.5.0) - drb (2.1.1) + drb (2.2.0) ruby2_keywords erubi (1.12.0) globalid (1.2.1) @@ -104,13 +104,13 @@ GEM i18n (1.14.1) concurrent-ruby (~> 1.0) iniparse (1.5.0) - io-console (0.6.0) - irb (1.8.3) + io-console (0.7.2) + irb (1.11.2) rdoc - reline (>= 0.3.8) + reline (>= 0.4.2) json (2.6.3) language_server-protocol (3.17.0.3) - loofah (2.21.4) + loofah (2.22.0) crass (~> 1.0.2) nokogiri (>= 1.12.0) mail (2.8.1) @@ -121,21 +121,21 @@ GEM marcel (1.0.2) method_source (1.0.0) mini_mime (1.1.5) - minitest (5.20.0) - mutex_m (0.1.2) - net-imap (0.4.2) + minitest (5.22.2) + mutex_m (0.2.0) + net-imap (0.4.10) date net-protocol net-pop (0.1.2) net-protocol - net-protocol (0.2.1) + net-protocol (0.2.2) timeout - net-smtp (0.4.0) + net-smtp (0.4.0.1) net-protocol - nio4r (2.5.9) - nokogiri (1.15.4-arm64-darwin) + nio4r (2.7.0) + nokogiri (1.16.2-arm64-darwin) racc (~> 1.4) - nokogiri (1.15.4-x86_64-linux) + nokogiri (1.16.2-x86_64-linux) racc (~> 1.4) overcommit (0.60.0) childprocess (>= 0.6.3, < 5) @@ -148,10 +148,10 @@ GEM pry (0.14.2) coderay (~> 1.1) method_source (~> 1.0) - psych (5.1.1.1) + psych (5.1.2) stringio - racc (1.7.1) - rack (3.0.8) + racc (1.7.3) + rack (3.0.9.1) rack-session (2.0.0) rack (>= 3.0.0) rack-test (2.1.0) @@ -189,12 +189,12 @@ GEM thor (~> 1.0, >= 1.2.2) zeitwerk (~> 2.6) rainbow (3.1.1) - rake (13.0.6) + rake (13.1.0) rb-readline (0.5.5) - rdoc (6.5.0) + rdoc (6.6.2) psych (>= 4.0.0) regexp_parser (2.8.1) - reline (0.3.9) + reline (0.4.3) io-console (~> 0.5) rexml (3.2.5) rspec (3.12.0) @@ -227,10 +227,10 @@ GEM ruby2_keywords (0.0.5) sqlite3 (1.6.3-arm64-darwin) sqlite3 (1.6.3-x86_64-linux) - stringio (3.0.8) - thor (1.3.0) + stringio (3.1.0) + thor (1.3.1) timecop (0.9.6) - timeout (0.4.0) + timeout (0.4.1) tzinfo (2.0.6) concurrent-ruby (~> 1.0) unicode-display_width (2.4.2) @@ -238,7 +238,7 @@ GEM websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) - zeitwerk (2.6.12) + zeitwerk (2.6.13) PLATFORMS arm64-darwin-22 From 8c74be55b8562f60a1349e5b9e690ff3eb5f5110 Mon Sep 17 00:00:00 2001 From: Ngan Pham Date: Tue, 27 Feb 2024 11:19:22 -0800 Subject: [PATCH 71/98] bump rails 7.1 --- gemfiles/rails_7.1.gemfile | 2 +- gemfiles/rails_7.1.gemfile.lock | 109 ++++++++++++++++---------------- 2 files changed, 56 insertions(+), 55 deletions(-) diff --git a/gemfiles/rails_7.1.gemfile b/gemfiles/rails_7.1.gemfile index ce298207..41dca2d4 100644 --- a/gemfiles/rails_7.1.gemfile +++ b/gemfiles/rails_7.1.gemfile @@ -3,6 +3,6 @@ source "http://rubygems.org" gem "sqlite3", "~> 1.4" -gem "rails", "7.1.0" +gem "rails", "~> 7.1.0" gemspec path: "../" diff --git a/gemfiles/rails_7.1.gemfile.lock b/gemfiles/rails_7.1.gemfile.lock index 247f5e16..ffe356e1 100644 --- a/gemfiles/rails_7.1.gemfile.lock +++ b/gemfiles/rails_7.1.gemfile.lock @@ -8,70 +8,71 @@ PATH GEM remote: http://rubygems.org/ specs: - actioncable (7.1.0) - actionpack (= 7.1.0) - activesupport (= 7.1.0) + actioncable (7.1.3.2) + actionpack (= 7.1.3.2) + activesupport (= 7.1.3.2) nio4r (~> 2.0) websocket-driver (>= 0.6.1) zeitwerk (~> 2.6) - actionmailbox (7.1.0) - actionpack (= 7.1.0) - activejob (= 7.1.0) - activerecord (= 7.1.0) - activestorage (= 7.1.0) - activesupport (= 7.1.0) + actionmailbox (7.1.3.2) + actionpack (= 7.1.3.2) + activejob (= 7.1.3.2) + activerecord (= 7.1.3.2) + activestorage (= 7.1.3.2) + activesupport (= 7.1.3.2) mail (>= 2.7.1) net-imap net-pop net-smtp - actionmailer (7.1.0) - actionpack (= 7.1.0) - actionview (= 7.1.0) - activejob (= 7.1.0) - activesupport (= 7.1.0) + actionmailer (7.1.3.2) + actionpack (= 7.1.3.2) + actionview (= 7.1.3.2) + activejob (= 7.1.3.2) + activesupport (= 7.1.3.2) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp rails-dom-testing (~> 2.2) - actionpack (7.1.0) - actionview (= 7.1.0) - activesupport (= 7.1.0) + actionpack (7.1.3.2) + actionview (= 7.1.3.2) + activesupport (= 7.1.3.2) nokogiri (>= 1.8.5) + racc rack (>= 2.2.4) rack-session (>= 1.0.1) rack-test (>= 0.6.3) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - actiontext (7.1.0) - actionpack (= 7.1.0) - activerecord (= 7.1.0) - activestorage (= 7.1.0) - activesupport (= 7.1.0) + actiontext (7.1.3.2) + actionpack (= 7.1.3.2) + activerecord (= 7.1.3.2) + activestorage (= 7.1.3.2) + activesupport (= 7.1.3.2) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.1.0) - activesupport (= 7.1.0) + actionview (7.1.3.2) + activesupport (= 7.1.3.2) builder (~> 3.1) erubi (~> 1.11) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - activejob (7.1.0) - activesupport (= 7.1.0) + activejob (7.1.3.2) + activesupport (= 7.1.3.2) globalid (>= 0.3.6) - activemodel (7.1.0) - activesupport (= 7.1.0) - activerecord (7.1.0) - activemodel (= 7.1.0) - activesupport (= 7.1.0) + activemodel (7.1.3.2) + activesupport (= 7.1.3.2) + activerecord (7.1.3.2) + activemodel (= 7.1.3.2) + activesupport (= 7.1.3.2) timeout (>= 0.4.0) - activestorage (7.1.0) - actionpack (= 7.1.0) - activejob (= 7.1.0) - activerecord (= 7.1.0) - activesupport (= 7.1.0) + activestorage (7.1.3.2) + actionpack (= 7.1.3.2) + activejob (= 7.1.3.2) + activerecord (= 7.1.3.2) + activesupport (= 7.1.3.2) marcel (~> 1.0) - activesupport (7.1.0) + activesupport (7.1.3.2) base64 bigdecimal concurrent-ruby (~> 1.0, >= 1.0.2) @@ -159,20 +160,20 @@ GEM rackup (2.1.0) rack (>= 3) webrick (~> 1.8) - rails (7.1.0) - actioncable (= 7.1.0) - actionmailbox (= 7.1.0) - actionmailer (= 7.1.0) - actionpack (= 7.1.0) - actiontext (= 7.1.0) - actionview (= 7.1.0) - activejob (= 7.1.0) - activemodel (= 7.1.0) - activerecord (= 7.1.0) - activestorage (= 7.1.0) - activesupport (= 7.1.0) + rails (7.1.3.2) + actioncable (= 7.1.3.2) + actionmailbox (= 7.1.3.2) + actionmailer (= 7.1.3.2) + actionpack (= 7.1.3.2) + actiontext (= 7.1.3.2) + actionview (= 7.1.3.2) + activejob (= 7.1.3.2) + activemodel (= 7.1.3.2) + activerecord (= 7.1.3.2) + activestorage (= 7.1.3.2) + activesupport (= 7.1.3.2) bundler (>= 1.15.0) - railties (= 7.1.0) + railties (= 7.1.3.2) rails-dom-testing (2.2.0) activesupport (>= 5.0.0) minitest @@ -180,9 +181,9 @@ GEM rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) - railties (7.1.0) - actionpack (= 7.1.0) - activesupport (= 7.1.0) + railties (7.1.3.2) + actionpack (= 7.1.3.2) + activesupport (= 7.1.3.2) irb rackup (>= 1.0.0) rake (>= 12.2) @@ -249,7 +250,7 @@ DEPENDENCIES data_migrate! overcommit pry - rails (= 7.1.0) + rails (~> 7.1.0) rake rb-readline rspec From f9b6793451507e6f3e4de23a5fe35f69a0a30707 Mon Sep 17 00:00:00 2001 From: Ngan Pham Date: Tue, 27 Feb 2024 11:23:50 -0800 Subject: [PATCH 72/98] bump all --- Gemfile | 1 - Gemfile.lock | 155 +++++++++++++++++++------------- Gemfile.rails6.1 | 11 --- data_migrate.gemspec | 2 +- gemfiles/rails_6.1.gemfile | 1 - gemfiles/rails_6.1.gemfile.lock | 6 +- gemfiles/rails_7.0.gemfile | 1 - gemfiles/rails_7.0.gemfile.lock | 6 +- gemfiles/rails_7.1.gemfile | 1 - gemfiles/rails_7.1.gemfile.lock | 6 +- 10 files changed, 105 insertions(+), 85 deletions(-) delete mode 100644 Gemfile.rails6.1 diff --git a/Gemfile b/Gemfile index 6a4aedc4..c80ee369 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,3 @@ source "http://rubygems.org" -gem 'sqlite3', "~> 1.4" gemspec diff --git a/Gemfile.lock b/Gemfile.lock index ec5fc13c..e86736a6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -8,124 +8,159 @@ PATH GEM remote: http://rubygems.org/ specs: - actionpack (7.0.7.2) - actionview (= 7.0.7.2) - activesupport (= 7.0.7.2) - rack (~> 2.0, >= 2.2.4) + actionpack (7.1.3.2) + actionview (= 7.1.3.2) + activesupport (= 7.1.3.2) + nokogiri (>= 1.8.5) + racc + rack (>= 2.2.4) + rack-session (>= 1.0.1) rack-test (>= 0.6.3) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.2.0) - actionview (7.0.7.2) - activesupport (= 7.0.7.2) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + actionview (7.1.3.2) + activesupport (= 7.1.3.2) builder (~> 3.1) - erubi (~> 1.4) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.1, >= 1.2.0) - activemodel (7.0.7.2) - activesupport (= 7.0.7.2) - activerecord (7.0.7.2) - activemodel (= 7.0.7.2) - activesupport (= 7.0.7.2) - activesupport (7.0.7.2) + erubi (~> 1.11) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + activemodel (7.1.3.2) + activesupport (= 7.1.3.2) + activerecord (7.1.3.2) + activemodel (= 7.1.3.2) + activesupport (= 7.1.3.2) + timeout (>= 0.4.0) + activesupport (7.1.3.2) + base64 + bigdecimal concurrent-ruby (~> 1.0, >= 1.0.2) + connection_pool (>= 2.2.5) + drb i18n (>= 1.6, < 2) minitest (>= 5.1) + mutex_m tzinfo (~> 2.0) appraisal (2.5.0) bundler rake thor (>= 0.14.0) ast (2.4.2) + base64 (0.2.0) + bigdecimal (3.1.6) builder (3.2.4) - childprocess (4.1.0) + childprocess (5.0.0) coderay (1.1.3) - concurrent-ruby (1.2.2) + concurrent-ruby (1.2.3) + connection_pool (2.4.1) crass (1.0.6) - diff-lcs (1.5.0) + diff-lcs (1.5.1) + drb (2.2.0) + ruby2_keywords erubi (1.12.0) i18n (1.14.1) concurrent-ruby (~> 1.0) iniparse (1.5.0) - json (2.6.3) + io-console (0.7.2) + irb (1.11.2) + rdoc + reline (>= 0.4.2) + json (2.7.1) language_server-protocol (3.17.0.3) - loofah (2.21.3) + loofah (2.22.0) crass (~> 1.0.2) nokogiri (>= 1.12.0) method_source (1.0.0) - minitest (5.19.0) + minitest (5.22.2) + mutex_m (0.2.0) nokogiri (1.16.2-arm64-darwin) racc (~> 1.4) nokogiri (1.16.2-x86_64-linux) racc (~> 1.4) - overcommit (0.60.0) - childprocess (>= 0.6.3, < 5) + overcommit (0.63.0) + childprocess (>= 0.6.3, < 6) iniparse (~> 1.4) rexml (~> 3.2) - parallel (1.23.0) - parser (3.2.2.3) + parallel (1.24.0) + parser (3.3.0.5) ast (~> 2.4.1) racc pry (0.14.2) coderay (~> 1.1) method_source (~> 1.0) + psych (5.1.2) + stringio racc (1.7.3) - rack (2.2.7) + rack (3.0.9.1) + rack-session (2.0.0) + rack (>= 3.0.0) rack-test (2.1.0) rack (>= 1.3) - rails-dom-testing (2.1.1) + rackup (2.1.0) + rack (>= 3) + webrick (~> 1.8) + rails-dom-testing (2.2.0) activesupport (>= 5.0.0) minitest nokogiri (>= 1.6) rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) - railties (7.0.7.2) - actionpack (= 7.0.7.2) - activesupport (= 7.0.7.2) - method_source + railties (7.1.3.2) + actionpack (= 7.1.3.2) + activesupport (= 7.1.3.2) + irb + rackup (>= 1.0.0) rake (>= 12.2) - thor (~> 1.0) - zeitwerk (~> 2.5) + thor (~> 1.0, >= 1.2.2) + zeitwerk (~> 2.6) rainbow (3.1.1) - rake (13.0.6) + rake (13.1.0) rb-readline (0.5.5) - regexp_parser (2.8.1) - rexml (3.2.5) - rspec (3.12.0) - rspec-core (~> 3.12.0) - rspec-expectations (~> 3.12.0) - rspec-mocks (~> 3.12.0) - rspec-core (3.12.2) - rspec-support (~> 3.12.0) - rspec-expectations (3.12.3) + rdoc (6.6.2) + psych (>= 4.0.0) + regexp_parser (2.9.0) + reline (0.4.3) + io-console (~> 0.5) + rexml (3.2.6) + rspec (3.13.0) + rspec-core (~> 3.13.0) + rspec-expectations (~> 3.13.0) + rspec-mocks (~> 3.13.0) + rspec-core (3.13.0) + rspec-support (~> 3.13.0) + rspec-expectations (3.13.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.12.0) - rspec-mocks (3.12.6) + rspec-support (~> 3.13.0) + rspec-mocks (3.13.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.12.0) - rspec-support (3.12.1) - rubocop (1.54.2) + rspec-support (~> 3.13.0) + rspec-support (3.13.1) + rubocop (1.60.2) json (~> 2.3) language_server-protocol (>= 3.17.0) parallel (~> 1.10) - parser (>= 3.2.2.3) + parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.28.0, < 2.0) + rubocop-ast (>= 1.30.0, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.29.0) + rubocop-ast (1.30.0) parser (>= 3.2.1.0) ruby-progressbar (1.13.0) - sqlite3 (1.6.3-arm64-darwin) - sqlite3 (1.6.3-x86_64-linux) - thor (1.2.2) - timecop (0.9.6) + ruby2_keywords (0.0.5) + sqlite3 (1.7.2-arm64-darwin) + sqlite3 (1.7.2-x86_64-linux) + stringio (3.1.0) + thor (1.3.1) + timecop (0.9.8) + timeout (0.4.1) tzinfo (2.0.6) concurrent-ruby (~> 1.0) - unicode-display_width (2.4.2) - zeitwerk (2.6.8) + unicode-display_width (2.5.0) + webrick (1.8.1) + zeitwerk (2.6.13) PLATFORMS arm64-darwin-22 @@ -141,7 +176,7 @@ DEPENDENCIES rspec rspec-core rubocop - sqlite3 (~> 1.4) + sqlite3 timecop BUNDLED WITH diff --git a/Gemfile.rails6.1 b/Gemfile.rails6.1 deleted file mode 100644 index b330a279..00000000 --- a/Gemfile.rails6.1 +++ /dev/null @@ -1,11 +0,0 @@ -source "http://rubygems.org" - -# Specify your gem's dependencies in data_migrate.gemspec -%w[ - activerecord - railties -].each do |rails_gem| - gem rails_gem, '~> 6.1.0' -end -gem 'sqlite3', "~> 1.4" -gemspec diff --git a/data_migrate.gemspec b/data_migrate.gemspec index 5646c2b4..22e9cb4f 100644 --- a/data_migrate.gemspec +++ b/data_migrate.gemspec @@ -28,7 +28,7 @@ Gem::Specification.new do |s| s.add_development_dependency "rspec-core" s.add_development_dependency "pry" s.add_development_dependency "rb-readline" - s.add_development_dependency "sqlite3", "~> 1.3.6" + s.add_development_dependency "sqlite3" s.add_development_dependency "timecop" s.add_development_dependency "rubocop" s.add_development_dependency "overcommit" diff --git a/gemfiles/rails_6.1.gemfile b/gemfiles/rails_6.1.gemfile index 20ae603a..49332d83 100644 --- a/gemfiles/rails_6.1.gemfile +++ b/gemfiles/rails_6.1.gemfile @@ -2,7 +2,6 @@ source "http://rubygems.org" -gem "sqlite3", "~> 1.4" gem "rails", "~> 6.1.0" gemspec path: "../" diff --git a/gemfiles/rails_6.1.gemfile.lock b/gemfiles/rails_6.1.gemfile.lock index 42bbde69..bca39ed2 100644 --- a/gemfiles/rails_6.1.gemfile.lock +++ b/gemfiles/rails_6.1.gemfile.lock @@ -193,8 +193,8 @@ GEM actionpack (>= 5.2) activesupport (>= 5.2) sprockets (>= 3.0.0) - sqlite3 (1.6.3-arm64-darwin) - sqlite3 (1.6.3-x86_64-linux) + sqlite3 (1.7.2-arm64-darwin) + sqlite3 (1.7.2-x86_64-linux) thor (1.3.1) timecop (0.9.6) timeout (0.4.1) @@ -221,7 +221,7 @@ DEPENDENCIES rspec rspec-core rubocop - sqlite3 (~> 1.4) + sqlite3 timecop BUNDLED WITH diff --git a/gemfiles/rails_7.0.gemfile b/gemfiles/rails_7.0.gemfile index 3f5a75ba..8719cb74 100644 --- a/gemfiles/rails_7.0.gemfile +++ b/gemfiles/rails_7.0.gemfile @@ -2,7 +2,6 @@ source "http://rubygems.org" -gem "sqlite3", "~> 1.4" gem "rails", "~> 7.0.0" gemspec path: "../" diff --git a/gemfiles/rails_7.0.gemfile.lock b/gemfiles/rails_7.0.gemfile.lock index ab0e766d..240033c5 100644 --- a/gemfiles/rails_7.0.gemfile.lock +++ b/gemfiles/rails_7.0.gemfile.lock @@ -194,8 +194,8 @@ GEM rubocop-ast (1.29.0) parser (>= 3.2.1.0) ruby-progressbar (1.13.0) - sqlite3 (1.6.3-arm64-darwin) - sqlite3 (1.6.3-x86_64-linux) + sqlite3 (1.7.2-arm64-darwin) + sqlite3 (1.7.2-x86_64-linux) thor (1.3.1) timecop (0.9.6) timeout (0.4.1) @@ -222,7 +222,7 @@ DEPENDENCIES rspec rspec-core rubocop - sqlite3 (~> 1.4) + sqlite3 timecop BUNDLED WITH diff --git a/gemfiles/rails_7.1.gemfile b/gemfiles/rails_7.1.gemfile index 41dca2d4..c26f542a 100644 --- a/gemfiles/rails_7.1.gemfile +++ b/gemfiles/rails_7.1.gemfile @@ -2,7 +2,6 @@ source "http://rubygems.org" -gem "sqlite3", "~> 1.4" gem "rails", "~> 7.1.0" gemspec path: "../" diff --git a/gemfiles/rails_7.1.gemfile.lock b/gemfiles/rails_7.1.gemfile.lock index ffe356e1..d76a750f 100644 --- a/gemfiles/rails_7.1.gemfile.lock +++ b/gemfiles/rails_7.1.gemfile.lock @@ -226,8 +226,8 @@ GEM parser (>= 3.2.1.0) ruby-progressbar (1.13.0) ruby2_keywords (0.0.5) - sqlite3 (1.6.3-arm64-darwin) - sqlite3 (1.6.3-x86_64-linux) + sqlite3 (1.7.2-arm64-darwin) + sqlite3 (1.7.2-x86_64-linux) stringio (3.1.0) thor (1.3.1) timecop (0.9.6) @@ -256,7 +256,7 @@ DEPENDENCIES rspec rspec-core rubocop - sqlite3 (~> 1.4) + sqlite3 timecop BUNDLED WITH From 2f809e1d764da4d72a7c9d73da1b25cf37a1cb8b Mon Sep 17 00:00:00 2001 From: Maple Ong Date: Fri, 1 Mar 2024 09:44:03 -0500 Subject: [PATCH 73/98] Bump to 9.3.0 --- Changelog.md | 3 + Gemfile.lock | 3 +- gemfiles/rails_6.1.gemfile.lock | 3 +- gemfiles/rails_7.0.gemfile.lock | 3 +- gemfiles/rails_7.1.gemfile | 2 +- gemfiles/rails_7.1.gemfile.lock | 114 ++++++++++++++++---------------- lib/data_migrate/version.rb | 2 +- 7 files changed, 68 insertions(+), 62 deletions(-) diff --git a/Changelog.md b/Changelog.md index bb41f64c..9a4c63ac 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,8 @@ # Changelog +## 9.3.0 +- Improve with_data Rake task for multiple database https://github.com/ilyakatz/data-migrate/pull/296 + ## 9.2.0 - Support Rails 7.1 https://github.com/ilyakatz/data-migrate/pull/278 - Build and test against 7.1.0.rc1 https://github.com/ilyakatz/data-migrate/pull/286 diff --git a/Gemfile.lock b/Gemfile.lock index e86736a6..6d93fb47 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - data_migrate (9.2.0) + data_migrate (9.3.0) activerecord (>= 6.1) railties (>= 6.1) @@ -164,6 +164,7 @@ GEM PLATFORMS arm64-darwin-22 + arm64-darwin-23 x86_64-linux DEPENDENCIES diff --git a/gemfiles/rails_6.1.gemfile.lock b/gemfiles/rails_6.1.gemfile.lock index bca39ed2..1752be7d 100644 --- a/gemfiles/rails_6.1.gemfile.lock +++ b/gemfiles/rails_6.1.gemfile.lock @@ -1,7 +1,7 @@ PATH remote: .. specs: - data_migrate (9.2.0) + data_migrate (9.3.0) activerecord (>= 6.1) railties (>= 6.1) @@ -208,6 +208,7 @@ GEM PLATFORMS arm64-darwin-22 + arm64-darwin-23 x86_64-linux DEPENDENCIES diff --git a/gemfiles/rails_7.0.gemfile.lock b/gemfiles/rails_7.0.gemfile.lock index 240033c5..2ea06e32 100644 --- a/gemfiles/rails_7.0.gemfile.lock +++ b/gemfiles/rails_7.0.gemfile.lock @@ -1,7 +1,7 @@ PATH remote: .. specs: - data_migrate (9.2.0) + data_migrate (9.3.0) activerecord (>= 6.1) railties (>= 6.1) @@ -209,6 +209,7 @@ GEM PLATFORMS arm64-darwin-22 + arm64-darwin-23 x86_64-linux DEPENDENCIES diff --git a/gemfiles/rails_7.1.gemfile b/gemfiles/rails_7.1.gemfile index c26f542a..2daec6fe 100644 --- a/gemfiles/rails_7.1.gemfile +++ b/gemfiles/rails_7.1.gemfile @@ -2,6 +2,6 @@ source "http://rubygems.org" -gem "rails", "~> 7.1.0" +gem "rails", "7.1.0" gemspec path: "../" diff --git a/gemfiles/rails_7.1.gemfile.lock b/gemfiles/rails_7.1.gemfile.lock index d76a750f..eb58243c 100644 --- a/gemfiles/rails_7.1.gemfile.lock +++ b/gemfiles/rails_7.1.gemfile.lock @@ -1,78 +1,77 @@ PATH remote: .. specs: - data_migrate (9.2.0) + data_migrate (9.3.0) activerecord (>= 6.1) railties (>= 6.1) GEM remote: http://rubygems.org/ specs: - actioncable (7.1.3.2) - actionpack (= 7.1.3.2) - activesupport (= 7.1.3.2) + actioncable (7.1.0) + actionpack (= 7.1.0) + activesupport (= 7.1.0) nio4r (~> 2.0) websocket-driver (>= 0.6.1) zeitwerk (~> 2.6) - actionmailbox (7.1.3.2) - actionpack (= 7.1.3.2) - activejob (= 7.1.3.2) - activerecord (= 7.1.3.2) - activestorage (= 7.1.3.2) - activesupport (= 7.1.3.2) + actionmailbox (7.1.0) + actionpack (= 7.1.0) + activejob (= 7.1.0) + activerecord (= 7.1.0) + activestorage (= 7.1.0) + activesupport (= 7.1.0) mail (>= 2.7.1) net-imap net-pop net-smtp - actionmailer (7.1.3.2) - actionpack (= 7.1.3.2) - actionview (= 7.1.3.2) - activejob (= 7.1.3.2) - activesupport (= 7.1.3.2) + actionmailer (7.1.0) + actionpack (= 7.1.0) + actionview (= 7.1.0) + activejob (= 7.1.0) + activesupport (= 7.1.0) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp rails-dom-testing (~> 2.2) - actionpack (7.1.3.2) - actionview (= 7.1.3.2) - activesupport (= 7.1.3.2) + actionpack (7.1.0) + actionview (= 7.1.0) + activesupport (= 7.1.0) nokogiri (>= 1.8.5) - racc rack (>= 2.2.4) rack-session (>= 1.0.1) rack-test (>= 0.6.3) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - actiontext (7.1.3.2) - actionpack (= 7.1.3.2) - activerecord (= 7.1.3.2) - activestorage (= 7.1.3.2) - activesupport (= 7.1.3.2) + actiontext (7.1.0) + actionpack (= 7.1.0) + activerecord (= 7.1.0) + activestorage (= 7.1.0) + activesupport (= 7.1.0) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.1.3.2) - activesupport (= 7.1.3.2) + actionview (7.1.0) + activesupport (= 7.1.0) builder (~> 3.1) erubi (~> 1.11) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - activejob (7.1.3.2) - activesupport (= 7.1.3.2) + activejob (7.1.0) + activesupport (= 7.1.0) globalid (>= 0.3.6) - activemodel (7.1.3.2) - activesupport (= 7.1.3.2) - activerecord (7.1.3.2) - activemodel (= 7.1.3.2) - activesupport (= 7.1.3.2) + activemodel (7.1.0) + activesupport (= 7.1.0) + activerecord (7.1.0) + activemodel (= 7.1.0) + activesupport (= 7.1.0) timeout (>= 0.4.0) - activestorage (7.1.3.2) - actionpack (= 7.1.3.2) - activejob (= 7.1.3.2) - activerecord (= 7.1.3.2) - activesupport (= 7.1.3.2) + activestorage (7.1.0) + actionpack (= 7.1.0) + activejob (= 7.1.0) + activerecord (= 7.1.0) + activesupport (= 7.1.0) marcel (~> 1.0) - activesupport (7.1.3.2) + activesupport (7.1.0) base64 bigdecimal concurrent-ruby (~> 1.0, >= 1.0.2) @@ -119,7 +118,7 @@ GEM net-imap net-pop net-smtp - marcel (1.0.2) + marcel (1.0.4) method_source (1.0.0) mini_mime (1.1.5) minitest (5.22.2) @@ -160,20 +159,20 @@ GEM rackup (2.1.0) rack (>= 3) webrick (~> 1.8) - rails (7.1.3.2) - actioncable (= 7.1.3.2) - actionmailbox (= 7.1.3.2) - actionmailer (= 7.1.3.2) - actionpack (= 7.1.3.2) - actiontext (= 7.1.3.2) - actionview (= 7.1.3.2) - activejob (= 7.1.3.2) - activemodel (= 7.1.3.2) - activerecord (= 7.1.3.2) - activestorage (= 7.1.3.2) - activesupport (= 7.1.3.2) + rails (7.1.0) + actioncable (= 7.1.0) + actionmailbox (= 7.1.0) + actionmailer (= 7.1.0) + actionpack (= 7.1.0) + actiontext (= 7.1.0) + actionview (= 7.1.0) + activejob (= 7.1.0) + activemodel (= 7.1.0) + activerecord (= 7.1.0) + activestorage (= 7.1.0) + activesupport (= 7.1.0) bundler (>= 1.15.0) - railties (= 7.1.3.2) + railties (= 7.1.0) rails-dom-testing (2.2.0) activesupport (>= 5.0.0) minitest @@ -181,9 +180,9 @@ GEM rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) - railties (7.1.3.2) - actionpack (= 7.1.3.2) - activesupport (= 7.1.3.2) + railties (7.1.0) + actionpack (= 7.1.0) + activesupport (= 7.1.0) irb rackup (>= 1.0.0) rake (>= 12.2) @@ -243,6 +242,7 @@ GEM PLATFORMS arm64-darwin-22 + arm64-darwin-23 x86_64-linux DEPENDENCIES @@ -250,7 +250,7 @@ DEPENDENCIES data_migrate! overcommit pry - rails (~> 7.1.0) + rails (= 7.1.0) rake rb-readline rspec diff --git a/lib/data_migrate/version.rb b/lib/data_migrate/version.rb index 4c584041..12a7c077 100644 --- a/lib/data_migrate/version.rb +++ b/lib/data_migrate/version.rb @@ -1,3 +1,3 @@ module DataMigrate - VERSION = "9.2.0".freeze + VERSION = "9.3.0".freeze end From 120b4f2b593b55f7e3c7546a3594b81c71c27e54 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Mar 2024 20:11:21 +0000 Subject: [PATCH 74/98] Bump rdoc from 6.6.2 to 6.6.3.1 Bumps [rdoc](https://github.com/ruby/rdoc) from 6.6.2 to 6.6.3.1. - [Release notes](https://github.com/ruby/rdoc/releases) - [Changelog](https://github.com/ruby/rdoc/blob/master/History.rdoc) - [Commits](https://github.com/ruby/rdoc/compare/v6.6.2...v6.6.3.1) --- updated-dependencies: - dependency-name: rdoc dependency-type: indirect ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 6d93fb47..e5621bf4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -116,7 +116,7 @@ GEM rainbow (3.1.1) rake (13.1.0) rb-readline (0.5.5) - rdoc (6.6.2) + rdoc (6.6.3.1) psych (>= 4.0.0) regexp_parser (2.9.0) reline (0.4.3) From a83a10793391044ee3ab576cc8b22e84e0a22925 Mon Sep 17 00:00:00 2001 From: Maple Ong Date: Thu, 25 Apr 2024 15:52:02 -0400 Subject: [PATCH 75/98] Reset model schema cache before each run --- lib/data_migrate/data_migrator.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/data_migrate/data_migrator.rb b/lib/data_migrate/data_migrator.rb index 300cde73..26a08dca 100644 --- a/lib/data_migrate/data_migrator.rb +++ b/lib/data_migrate/data_migrator.rb @@ -54,6 +54,10 @@ def migrations(_migrations_paths) #TODO: this was added to be backward compatible, need to re-evaluate def run(direction, migration_paths, version) + # Ensure all Active Record model cache is reset for each data migration + # As recommended in: https://github.com/rails/rails/blob/da21c2e9812e5eb0698fba4a9aa38632fc004432/activerecord/lib/active_record/migration.rb#L467-L470 + ActiveRecord::Base.descendants.each(&:reset_column_information) + DataMigrate::MigrationContext.new(migration_paths).run(direction, version) end From 0650a0300de5d248821387c9dcd20fa74b58c6b5 Mon Sep 17 00:00:00 2001 From: Maple Ong Date: Thu, 25 Apr 2024 16:13:03 -0400 Subject: [PATCH 76/98] Load config before db:migrate:with_data --- tasks/databases.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/databases.rake b/tasks/databases.rake index 4ca696cd..cf4b9a54 100644 --- a/tasks/databases.rake +++ b/tasks/databases.rake @@ -5,7 +5,7 @@ require 'data_migrate/tasks/data_migrate_tasks' namespace :db do namespace :migrate do desc "Migrate the database data and schema (options: VERSION=x, VERBOSE=false)." - task :with_data => :environment do + task :with_data => :load_config do DataMigrate::DataMigrator.create_data_schema_table ActiveRecord::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true From a060beac996a2f9543dfa4faecc4d641d87220cb Mon Sep 17 00:00:00 2001 From: Maple Ong Date: Thu, 25 Apr 2024 17:49:07 -0400 Subject: [PATCH 77/98] Add to changelog --- Changelog.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Changelog.md b/Changelog.md index 9a4c63ac..6ff62e56 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,8 @@ # Changelog +## 9.4.0 +- Reset model schema cache before each data migration https://github.com/ilyakatz/data-migrate/pull/307 + ## 9.3.0 - Improve with_data Rake task for multiple database https://github.com/ilyakatz/data-migrate/pull/296 From 51081840cb5ed4c53df2b3a63a133b842560e4ab Mon Sep 17 00:00:00 2001 From: Maple Ong Date: Fri, 26 Apr 2024 16:32:57 -0400 Subject: [PATCH 78/98] Bump version 9.4.0 --- Changelog.md | 1 + Gemfile.lock | 2 +- gemfiles/rails_6.1.gemfile.lock | 2 +- gemfiles/rails_7.0.gemfile.lock | 2 +- gemfiles/rails_7.1.gemfile.lock | 2 +- lib/data_migrate/version.rb | 2 +- 6 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Changelog.md b/Changelog.md index 6ff62e56..eb2418e1 100644 --- a/Changelog.md +++ b/Changelog.md @@ -2,6 +2,7 @@ ## 9.4.0 - Reset model schema cache before each data migration https://github.com/ilyakatz/data-migrate/pull/307 +- Run load_config rake task before db:migrate:with_data https://github.com/ilyakatz/data-migrate/pull/308 ## 9.3.0 - Improve with_data Rake task for multiple database https://github.com/ilyakatz/data-migrate/pull/296 diff --git a/Gemfile.lock b/Gemfile.lock index e5621bf4..dfeb38c1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - data_migrate (9.3.0) + data_migrate (9.4.0) activerecord (>= 6.1) railties (>= 6.1) diff --git a/gemfiles/rails_6.1.gemfile.lock b/gemfiles/rails_6.1.gemfile.lock index 1752be7d..653ff856 100644 --- a/gemfiles/rails_6.1.gemfile.lock +++ b/gemfiles/rails_6.1.gemfile.lock @@ -1,7 +1,7 @@ PATH remote: .. specs: - data_migrate (9.3.0) + data_migrate (9.4.0) activerecord (>= 6.1) railties (>= 6.1) diff --git a/gemfiles/rails_7.0.gemfile.lock b/gemfiles/rails_7.0.gemfile.lock index 2ea06e32..7681df08 100644 --- a/gemfiles/rails_7.0.gemfile.lock +++ b/gemfiles/rails_7.0.gemfile.lock @@ -1,7 +1,7 @@ PATH remote: .. specs: - data_migrate (9.3.0) + data_migrate (9.4.0) activerecord (>= 6.1) railties (>= 6.1) diff --git a/gemfiles/rails_7.1.gemfile.lock b/gemfiles/rails_7.1.gemfile.lock index eb58243c..686209c8 100644 --- a/gemfiles/rails_7.1.gemfile.lock +++ b/gemfiles/rails_7.1.gemfile.lock @@ -1,7 +1,7 @@ PATH remote: .. specs: - data_migrate (9.3.0) + data_migrate (9.4.0) activerecord (>= 6.1) railties (>= 6.1) diff --git a/lib/data_migrate/version.rb b/lib/data_migrate/version.rb index 12a7c077..0d931593 100644 --- a/lib/data_migrate/version.rb +++ b/lib/data_migrate/version.rb @@ -1,3 +1,3 @@ module DataMigrate - VERSION = "9.3.0".freeze + VERSION = "9.4.0".freeze end From 7addc572bb972527bbe081203f28dcea0a37ce2a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 May 2024 23:36:41 +0000 Subject: [PATCH 79/98] Bump nokogiri from 1.16.2 to 1.16.5 Bumps [nokogiri](https://github.com/sparklemotion/nokogiri) from 1.16.2 to 1.16.5. - [Release notes](https://github.com/sparklemotion/nokogiri/releases) - [Changelog](https://github.com/sparklemotion/nokogiri/blob/main/CHANGELOG.md) - [Commits](https://github.com/sparklemotion/nokogiri/compare/v1.16.2...v1.16.5) --- updated-dependencies: - dependency-name: nokogiri dependency-type: indirect ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index dfeb38c1..8ab0737a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -72,9 +72,9 @@ GEM method_source (1.0.0) minitest (5.22.2) mutex_m (0.2.0) - nokogiri (1.16.2-arm64-darwin) + nokogiri (1.16.5-arm64-darwin) racc (~> 1.4) - nokogiri (1.16.2-x86_64-linux) + nokogiri (1.16.5-x86_64-linux) racc (~> 1.4) overcommit (0.63.0) childprocess (>= 0.6.3, < 6) From 9718e6d38e8f8006f48afcf6ec987dc8edf9ba88 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 16 May 2024 21:57:42 +0000 Subject: [PATCH 80/98] Bump rexml from 3.2.6 to 3.2.8 Bumps [rexml](https://github.com/ruby/rexml) from 3.2.6 to 3.2.8. - [Release notes](https://github.com/ruby/rexml/releases) - [Changelog](https://github.com/ruby/rexml/blob/master/NEWS.md) - [Commits](https://github.com/ruby/rexml/compare/v3.2.6...v3.2.8) --- updated-dependencies: - dependency-name: rexml dependency-type: indirect ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index dfeb38c1..e21de571 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -121,7 +121,8 @@ GEM regexp_parser (2.9.0) reline (0.4.3) io-console (~> 0.5) - rexml (3.2.6) + rexml (3.2.8) + strscan (>= 3.0.9) rspec (3.13.0) rspec-core (~> 3.13.0) rspec-expectations (~> 3.13.0) @@ -153,6 +154,7 @@ GEM sqlite3 (1.7.2-arm64-darwin) sqlite3 (1.7.2-x86_64-linux) stringio (3.1.0) + strscan (3.1.0) thor (1.3.1) timecop (0.9.8) timeout (0.4.1) From 44a330a7354f4024cd51b9f71a43f1e170d7d18b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 4 Jun 2024 22:35:53 +0000 Subject: [PATCH 81/98] Bump actionpack from 7.1.3.2 to 7.1.3.4 Bumps [actionpack](https://github.com/rails/rails) from 7.1.3.2 to 7.1.3.4. - [Release notes](https://github.com/rails/rails/releases) - [Changelog](https://github.com/rails/rails/blob/v7.1.3.4/actionpack/CHANGELOG.md) - [Commits](https://github.com/rails/rails/compare/v7.1.3.2...v7.1.3.4) --- updated-dependencies: - dependency-name: actionpack dependency-type: indirect ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 44 +++++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 8ab0737a..df1a6c0c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -8,9 +8,9 @@ PATH GEM remote: http://rubygems.org/ specs: - actionpack (7.1.3.2) - actionview (= 7.1.3.2) - activesupport (= 7.1.3.2) + actionpack (7.1.3.4) + actionview (= 7.1.3.4) + activesupport (= 7.1.3.4) nokogiri (>= 1.8.5) racc rack (>= 2.2.4) @@ -18,19 +18,19 @@ GEM rack-test (>= 0.6.3) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - actionview (7.1.3.2) - activesupport (= 7.1.3.2) + actionview (7.1.3.4) + activesupport (= 7.1.3.4) builder (~> 3.1) erubi (~> 1.11) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - activemodel (7.1.3.2) - activesupport (= 7.1.3.2) - activerecord (7.1.3.2) - activemodel (= 7.1.3.2) - activesupport (= 7.1.3.2) + activemodel (7.1.3.4) + activesupport (= 7.1.3.4) + activerecord (7.1.3.4) + activemodel (= 7.1.3.4) + activesupport (= 7.1.3.4) timeout (>= 0.4.0) - activesupport (7.1.3.2) + activesupport (7.1.3.4) base64 bigdecimal concurrent-ruby (~> 1.0, >= 1.0.2) @@ -46,18 +46,17 @@ GEM thor (>= 0.14.0) ast (2.4.2) base64 (0.2.0) - bigdecimal (3.1.6) + bigdecimal (3.1.8) builder (3.2.4) childprocess (5.0.0) coderay (1.1.3) - concurrent-ruby (1.2.3) + concurrent-ruby (1.3.1) connection_pool (2.4.1) crass (1.0.6) diff-lcs (1.5.1) - drb (2.2.0) - ruby2_keywords + drb (2.2.1) erubi (1.12.0) - i18n (1.14.1) + i18n (1.14.5) concurrent-ruby (~> 1.0) iniparse (1.5.0) io-console (0.7.2) @@ -70,7 +69,7 @@ GEM crass (~> 1.0.2) nokogiri (>= 1.12.0) method_source (1.0.0) - minitest (5.22.2) + minitest (5.23.1) mutex_m (0.2.0) nokogiri (1.16.5-arm64-darwin) racc (~> 1.4) @@ -89,8 +88,8 @@ GEM method_source (~> 1.0) psych (5.1.2) stringio - racc (1.7.3) - rack (3.0.9.1) + racc (1.8.0) + rack (3.0.11) rack-session (2.0.0) rack (>= 3.0.0) rack-test (2.1.0) @@ -105,9 +104,9 @@ GEM rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) - railties (7.1.3.2) - actionpack (= 7.1.3.2) - activesupport (= 7.1.3.2) + railties (7.1.3.4) + actionpack (= 7.1.3.4) + activesupport (= 7.1.3.4) irb rackup (>= 1.0.0) rake (>= 12.2) @@ -149,7 +148,6 @@ GEM rubocop-ast (1.30.0) parser (>= 3.2.1.0) ruby-progressbar (1.13.0) - ruby2_keywords (0.0.5) sqlite3 (1.7.2-arm64-darwin) sqlite3 (1.7.2-x86_64-linux) stringio (3.1.0) From 9f7a3c8c3a4ee532d2ad9f8afb90a25b1b9c714f Mon Sep 17 00:00:00 2001 From: James Smith Date: Sun, 2 Jul 2023 10:52:33 +0100 Subject: [PATCH 82/98] Move migrate code into DataMigrate::DatabaseTasks so that we can call it from other tasks directly without invoking rake --- lib/data_migrate/database_tasks.rb | 31 ++++++++++++++++++++++++++++++ tasks/databases.rake | 29 +--------------------------- 2 files changed, 32 insertions(+), 28 deletions(-) diff --git a/lib/data_migrate/database_tasks.rb b/lib/data_migrate/database_tasks.rb index 38a2a2fa..dee2c473 100644 --- a/lib/data_migrate/database_tasks.rb +++ b/lib/data_migrate/database_tasks.rb @@ -173,5 +173,36 @@ def past_migrations(sort = nil) sort&.downcase == "asc" ? sort_migrations(migrations) : sort_migrations(migrations).reverse end + + def self.migrate_with_data + DataMigrate::DataMigrator.create_data_schema_table + + ActiveRecord::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true + + db_configs = ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env) + + schema_mapped_versions = ActiveRecord::Tasks::DatabaseTasks.db_configs_with_versions(db_configs) + data_mapped_versions = DataMigrate::DatabaseTasks.db_configs_with_versions + + mapped_versions = schema_mapped_versions.merge(data_mapped_versions) do |_key, schema_db_configs, data_db_configs| + schema_db_configs + data_db_configs + end + + mapped_versions.sort.each do |version, db_configs| + db_configs.each do |db_config| + if is_data_migration = db_config.is_a?(DataMigrate::DatabaseConfigurationWrapper) + db_config = db_config.db_config + end + + DataMigrate::DatabaseTasks.with_temporary_connection(db_config) do + if is_data_migration + DataMigrate::DataMigrator.run(:up, DataMigrate::DatabaseTasks.data_migrations_path, version) + else + ActiveRecord::Tasks::DatabaseTasks.migrate(version) + end + end + end + end + end end end diff --git a/tasks/databases.rake b/tasks/databases.rake index cf4b9a54..9608a4ed 100644 --- a/tasks/databases.rake +++ b/tasks/databases.rake @@ -6,34 +6,7 @@ namespace :db do namespace :migrate do desc "Migrate the database data and schema (options: VERSION=x, VERBOSE=false)." task :with_data => :load_config do - DataMigrate::DataMigrator.create_data_schema_table - ActiveRecord::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true - - db_configs = ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env) - - schema_mapped_versions = ActiveRecord::Tasks::DatabaseTasks.db_configs_with_versions(db_configs) - data_mapped_versions = DataMigrate::DatabaseTasks.db_configs_with_versions - - mapped_versions = schema_mapped_versions.merge(data_mapped_versions) do |_key, schema_db_configs, data_db_configs| - schema_db_configs + data_db_configs - end - - mapped_versions.sort.each do |version, db_configs| - db_configs.each do |db_config| - if is_data_migration = db_config.is_a?(DataMigrate::DatabaseConfigurationWrapper) - db_config = db_config.db_config - end - - DataMigrate::DatabaseTasks.with_temporary_connection(db_config) do - if is_data_migration - DataMigrate::DataMigrator.run(:up, DataMigrate::DatabaseTasks.data_migrations_path, version) - else - ActiveRecord::Tasks::DatabaseTasks.migrate(version) - end - end - end - end - + DataMigrate::DatabaseTasks.migrate_with_data Rake::Task["db:_dump"].invoke Rake::Task["data:dump"].invoke end From 920103883add43b21221c3e8c436f93a0ca936a9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 2 Aug 2024 02:06:09 +0000 Subject: [PATCH 83/98] Bump rexml from 3.2.8 to 3.3.3 Bumps [rexml](https://github.com/ruby/rexml) from 3.2.8 to 3.3.3. - [Release notes](https://github.com/ruby/rexml/releases) - [Changelog](https://github.com/ruby/rexml/blob/master/NEWS.md) - [Commits](https://github.com/ruby/rexml/compare/v3.2.8...v3.3.3) --- updated-dependencies: - dependency-name: rexml dependency-type: indirect ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 59d53be2..2da85947 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -120,8 +120,8 @@ GEM regexp_parser (2.9.0) reline (0.4.3) io-console (~> 0.5) - rexml (3.2.8) - strscan (>= 3.0.9) + rexml (3.3.3) + strscan rspec (3.13.0) rspec-core (~> 3.13.0) rspec-expectations (~> 3.13.0) From 01d8b811b354adc6f86855963b0933f535284e75 Mon Sep 17 00:00:00 2001 From: Ilya Katz Date: Mon, 12 Aug 2024 18:41:23 -0700 Subject: [PATCH 84/98] Add task db:prepare:with_data --- Changelog.md | 3 +++ lib/data_migrate/version.rb | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Changelog.md b/Changelog.md index eb2418e1..0b8040c3 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,8 @@ # Changelog +## 9.4.1 + - Add db:prepare task + ## 9.4.0 - Reset model schema cache before each data migration https://github.com/ilyakatz/data-migrate/pull/307 - Run load_config rake task before db:migrate:with_data https://github.com/ilyakatz/data-migrate/pull/308 diff --git a/lib/data_migrate/version.rb b/lib/data_migrate/version.rb index 0d931593..5a4d6873 100644 --- a/lib/data_migrate/version.rb +++ b/lib/data_migrate/version.rb @@ -1,3 +1,3 @@ module DataMigrate - VERSION = "9.4.0".freeze + VERSION = "9.4.1".freeze end From 20d416f4027600017a3fc461a60a8d0becebd866 Mon Sep 17 00:00:00 2001 From: Ilya Katz Date: Mon, 12 Aug 2024 18:44:20 -0700 Subject: [PATCH 85/98] Update gemfile --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 8ab0737a..48239213 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - data_migrate (9.4.0) + data_migrate (9.4.1) activerecord (>= 6.1) railties (>= 6.1) From bbd5efa056df33a6b035e7dddcd63fb2887ecbb8 Mon Sep 17 00:00:00 2001 From: Ilya Katz Date: Mon, 12 Aug 2024 19:22:17 -0700 Subject: [PATCH 86/98] Update gemfile --- gemfiles/rails_6.1.gemfile.lock | 2 +- gemfiles/rails_7.0.gemfile.lock | 2 +- gemfiles/rails_7.1.gemfile.lock | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gemfiles/rails_6.1.gemfile.lock b/gemfiles/rails_6.1.gemfile.lock index 653ff856..7c82ed1c 100644 --- a/gemfiles/rails_6.1.gemfile.lock +++ b/gemfiles/rails_6.1.gemfile.lock @@ -1,7 +1,7 @@ PATH remote: .. specs: - data_migrate (9.4.0) + data_migrate (9.4.1) activerecord (>= 6.1) railties (>= 6.1) diff --git a/gemfiles/rails_7.0.gemfile.lock b/gemfiles/rails_7.0.gemfile.lock index 7681df08..8a52a689 100644 --- a/gemfiles/rails_7.0.gemfile.lock +++ b/gemfiles/rails_7.0.gemfile.lock @@ -1,7 +1,7 @@ PATH remote: .. specs: - data_migrate (9.4.0) + data_migrate (9.4.1) activerecord (>= 6.1) railties (>= 6.1) diff --git a/gemfiles/rails_7.1.gemfile.lock b/gemfiles/rails_7.1.gemfile.lock index 686209c8..511411b6 100644 --- a/gemfiles/rails_7.1.gemfile.lock +++ b/gemfiles/rails_7.1.gemfile.lock @@ -1,7 +1,7 @@ PATH remote: .. specs: - data_migrate (9.4.0) + data_migrate (9.4.1) activerecord (>= 6.1) railties (>= 6.1) From 6db6acf59d9db84af3283897ef02f2a54758ea00 Mon Sep 17 00:00:00 2001 From: Ilya Katz Date: Mon, 12 Aug 2024 19:52:20 -0700 Subject: [PATCH 87/98] Document release process --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index e6aca129..4e93fd53 100644 --- a/README.md +++ b/README.md @@ -169,6 +169,14 @@ bundle exec appraisal rails-7.0 rspec bundle exec appraisal rails-7.1 rspec ``` +## Releasing new version + +1. Create a new tag, eg `git tag 9.4.1` +1. Go to https://github.com/ilyakatz/data-migrate/tags +1. Click "Create release" under 9.4.1 +1. CLick "Generate release notes" +1. Click "Publish release" + ## Thanks [Andrew J Vargo](http://github.com/ajvargo) Andrew was the original creator and maintainer of this project! From a0c4978ccca8ecad16e6466031468cfa1b8b3152 Mon Sep 17 00:00:00 2001 From: "Javier G. Montoya S" Date: Wed, 14 Aug 2024 16:58:46 -0400 Subject: [PATCH 88/98] fix(db:prepare:with_data): add missing prepare_all_with_data and task definition --- Changelog.md | 3 +++ Gemfile.lock | 2 +- gemfiles/rails_6.1.gemfile.lock | 2 +- gemfiles/rails_7.0.gemfile.lock | 2 +- gemfiles/rails_7.1.gemfile.lock | 2 +- lib/data_migrate/database_tasks.rb | 37 ++++++++++++++++++++++++++++++ lib/data_migrate/version.rb | 2 +- tasks/databases.rake | 7 ++++++ 8 files changed, 52 insertions(+), 5 deletions(-) diff --git a/Changelog.md b/Changelog.md index 0b8040c3..5a184fed 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,8 @@ # Changelog +## 9.4.2 + - Fix db:prepare:with_data task + ## 9.4.1 - Add db:prepare task diff --git a/Gemfile.lock b/Gemfile.lock index 7fb98b8d..bbbdbca1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - data_migrate (9.4.1) + data_migrate (9.4.2) activerecord (>= 6.1) railties (>= 6.1) diff --git a/gemfiles/rails_6.1.gemfile.lock b/gemfiles/rails_6.1.gemfile.lock index 7c82ed1c..54d78e85 100644 --- a/gemfiles/rails_6.1.gemfile.lock +++ b/gemfiles/rails_6.1.gemfile.lock @@ -1,7 +1,7 @@ PATH remote: .. specs: - data_migrate (9.4.1) + data_migrate (9.4.2) activerecord (>= 6.1) railties (>= 6.1) diff --git a/gemfiles/rails_7.0.gemfile.lock b/gemfiles/rails_7.0.gemfile.lock index 8a52a689..9d99b69b 100644 --- a/gemfiles/rails_7.0.gemfile.lock +++ b/gemfiles/rails_7.0.gemfile.lock @@ -1,7 +1,7 @@ PATH remote: .. specs: - data_migrate (9.4.1) + data_migrate (9.4.2) activerecord (>= 6.1) railties (>= 6.1) diff --git a/gemfiles/rails_7.1.gemfile.lock b/gemfiles/rails_7.1.gemfile.lock index 511411b6..b1066e6c 100644 --- a/gemfiles/rails_7.1.gemfile.lock +++ b/gemfiles/rails_7.1.gemfile.lock @@ -1,7 +1,7 @@ PATH remote: .. specs: - data_migrate (9.4.1) + data_migrate (9.4.2) activerecord (>= 6.1) railties (>= 6.1) diff --git a/lib/data_migrate/database_tasks.rb b/lib/data_migrate/database_tasks.rb index dee2c473..3f5a914e 100644 --- a/lib/data_migrate/database_tasks.rb +++ b/lib/data_migrate/database_tasks.rb @@ -204,5 +204,42 @@ def self.migrate_with_data end end end + + def self.prepare_all_with_data + seed = false + + each_current_configuration(env) do |db_config| + next unless db_config.primary? + + with_temporary_pool(db_config) do + begin + database_initialized = migration_connection.schema_migration.table_exists? + rescue ActiveRecord::NoDatabaseError + create(db_config) + retry + end + + unless database_initialized + if File.exist?(schema_dump_path(db_config)) + load_schema(db_config, ActiveRecord.schema_format, nil) + load_schema_current( + :ruby, + ENV["DATA_SCHEMA"] + ) + end + + seed = true + end + + migrate_with_data + if ActiveRecord.dump_schema_after_migration + dump_schema(db_config) + DataMigrate::Tasks::DataMigrateTasks.dump + end + end + end + + load_seed if seed + end end end diff --git a/lib/data_migrate/version.rb b/lib/data_migrate/version.rb index 5a4d6873..ffc2c438 100644 --- a/lib/data_migrate/version.rb +++ b/lib/data_migrate/version.rb @@ -1,3 +1,3 @@ module DataMigrate - VERSION = "9.4.1".freeze + VERSION = "9.4.2".freeze end diff --git a/tasks/databases.rake b/tasks/databases.rake index 9608a4ed..7c92515f 100644 --- a/tasks/databases.rake +++ b/tasks/databases.rake @@ -146,6 +146,13 @@ namespace :db do end end end + + namespace :prepare do + desc "Runs setup if database does not exist, or runs data and schema migrations if it does" + task with_data: :environment do + DataMigrate::DatabaseTasks.prepare_all_with_data + end + end end namespace :data do From c4456b0fc2b3d54f25afea2e22cee32a8c6fe73f Mon Sep 17 00:00:00 2001 From: Vincent Prigent Date: Tue, 4 Jun 2024 12:23:57 +1200 Subject: [PATCH 89/98] Support rails 7.2 --- .github/workflows/build.yml | 1 + Appraisals | 5 + Changelog.md | 4 + Gemfile.lock | 9 +- README.md | 5 +- gemfiles/rails_6.1.gemfile.lock | 4 + gemfiles/rails_7.0.gemfile.lock | 4 + gemfiles/rails_7.1.gemfile.lock | 4 + gemfiles/rails_7.2.gemfile | 7 + gemfiles/rails_7.2.gemfile.lock | 261 ++++++++++++++++++++ lib/data_migrate/rails_helper.rb | 17 +- spec/data_migrate/migration_context_spec.rb | 11 +- tasks/databases.rake | 1 + 13 files changed, 325 insertions(+), 8 deletions(-) create mode 100644 gemfiles/rails_7.2.gemfile create mode 100644 gemfiles/rails_7.2.gemfile.lock diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index de73c902..6ac140f0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,6 +19,7 @@ jobs: - gemfiles/rails_6.1.gemfile - gemfiles/rails_7.0.gemfile - gemfiles/rails_7.1.gemfile + - gemfiles/rails_7.2.gemfile runs-on: ubuntu-latest env: BUNDLE_GEMFILE: ${{ matrix.gemfile }} diff --git a/Appraisals b/Appraisals index 7eec0afd..ded82fbd 100644 --- a/Appraisals +++ b/Appraisals @@ -9,3 +9,8 @@ end appraise 'rails-7.1' do gem 'rails', '7.1.0' end + + +appraise 'rails-7.2' do + gem 'rails', '7.2.0.beta1' +end diff --git a/Changelog.md b/Changelog.md index 5a184fed..8764c451 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,9 @@ # Changelog + +## 9.5.0 +- Support Rails 7.2 + ## 9.4.2 - Fix db:prepare:with_data task diff --git a/Gemfile.lock b/Gemfile.lock index bbbdbca1..01d208b5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -71,9 +71,11 @@ GEM method_source (1.0.0) minitest (5.23.1) mutex_m (0.2.0) - nokogiri (1.16.5-arm64-darwin) + nokogiri (1.16.2-aarch64-linux) racc (~> 1.4) - nokogiri (1.16.5-x86_64-linux) + nokogiri (1.16.2-arm64-darwin) + racc (~> 1.4) + nokogiri (1.16.2-x86_64-linux) racc (~> 1.4) overcommit (0.63.0) childprocess (>= 0.6.3, < 6) @@ -149,6 +151,8 @@ GEM rubocop-ast (1.30.0) parser (>= 3.2.1.0) ruby-progressbar (1.13.0) + ruby2_keywords (0.0.5) + sqlite3 (1.7.2-aarch64-linux) sqlite3 (1.7.2-arm64-darwin) sqlite3 (1.7.2-x86_64-linux) stringio (3.1.0) @@ -163,6 +167,7 @@ GEM zeitwerk (2.6.13) PLATFORMS + aarch64-linux arm64-darwin-22 arm64-darwin-23 x86_64-linux diff --git a/README.md b/README.md index e6aca129..00397fb8 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ table to track all migrations. ## Rails Support -Support Rails 6.1 through 7.1 +Support Rails 6.1 through 7.2 #### v1 @@ -163,10 +163,11 @@ Then, in the Engine's `db/data` folder, you can add data migrations and run them Run tests for a specific version of Rails ``` -bundle exec appraisal install + bundle exec appraisal rails-6.1 rspec bundle exec appraisal rails-7.0 rspec bundle exec appraisal rails-7.1 rspec +bundle exec appraisal rails-7.2 rspec ``` ## Thanks diff --git a/gemfiles/rails_6.1.gemfile.lock b/gemfiles/rails_6.1.gemfile.lock index 54d78e85..fdd6a657 100644 --- a/gemfiles/rails_6.1.gemfile.lock +++ b/gemfiles/rails_6.1.gemfile.lock @@ -108,6 +108,8 @@ GEM net-smtp (0.4.0.1) net-protocol nio4r (2.7.0) + nokogiri (1.16.2-aarch64-linux) + racc (~> 1.4) nokogiri (1.16.2-arm64-darwin) racc (~> 1.4) nokogiri (1.16.2-x86_64-linux) @@ -193,6 +195,7 @@ GEM actionpack (>= 5.2) activesupport (>= 5.2) sprockets (>= 3.0.0) + sqlite3 (1.7.2-aarch64-linux) sqlite3 (1.7.2-arm64-darwin) sqlite3 (1.7.2-x86_64-linux) thor (1.3.1) @@ -207,6 +210,7 @@ GEM zeitwerk (2.6.13) PLATFORMS + aarch64-linux arm64-darwin-22 arm64-darwin-23 x86_64-linux diff --git a/gemfiles/rails_7.0.gemfile.lock b/gemfiles/rails_7.0.gemfile.lock index 9d99b69b..cf45d9cd 100644 --- a/gemfiles/rails_7.0.gemfile.lock +++ b/gemfiles/rails_7.0.gemfile.lock @@ -115,6 +115,8 @@ GEM net-smtp (0.4.0.1) net-protocol nio4r (2.7.0) + nokogiri (1.16.2-aarch64-linux) + racc (~> 1.4) nokogiri (1.16.2-arm64-darwin) racc (~> 1.4) nokogiri (1.16.2-x86_64-linux) @@ -194,6 +196,7 @@ GEM rubocop-ast (1.29.0) parser (>= 3.2.1.0) ruby-progressbar (1.13.0) + sqlite3 (1.7.2-aarch64-linux) sqlite3 (1.7.2-arm64-darwin) sqlite3 (1.7.2-x86_64-linux) thor (1.3.1) @@ -208,6 +211,7 @@ GEM zeitwerk (2.6.13) PLATFORMS + aarch64-linux arm64-darwin-22 arm64-darwin-23 x86_64-linux diff --git a/gemfiles/rails_7.1.gemfile.lock b/gemfiles/rails_7.1.gemfile.lock index b1066e6c..f78e9d29 100644 --- a/gemfiles/rails_7.1.gemfile.lock +++ b/gemfiles/rails_7.1.gemfile.lock @@ -133,6 +133,8 @@ GEM net-smtp (0.4.0.1) net-protocol nio4r (2.7.0) + nokogiri (1.16.2-aarch64-linux) + racc (~> 1.4) nokogiri (1.16.2-arm64-darwin) racc (~> 1.4) nokogiri (1.16.2-x86_64-linux) @@ -225,6 +227,7 @@ GEM parser (>= 3.2.1.0) ruby-progressbar (1.13.0) ruby2_keywords (0.0.5) + sqlite3 (1.7.2-aarch64-linux) sqlite3 (1.7.2-arm64-darwin) sqlite3 (1.7.2-x86_64-linux) stringio (3.1.0) @@ -241,6 +244,7 @@ GEM zeitwerk (2.6.13) PLATFORMS + aarch64-linux arm64-darwin-22 arm64-darwin-23 x86_64-linux diff --git a/gemfiles/rails_7.2.gemfile b/gemfiles/rails_7.2.gemfile new file mode 100644 index 00000000..6730ca89 --- /dev/null +++ b/gemfiles/rails_7.2.gemfile @@ -0,0 +1,7 @@ +# This file was generated by Appraisal + +source "http://rubygems.org" + +gem "rails", "7.2.0.beta1" + +gemspec path: "../" diff --git a/gemfiles/rails_7.2.gemfile.lock b/gemfiles/rails_7.2.gemfile.lock new file mode 100644 index 00000000..70e69bb9 --- /dev/null +++ b/gemfiles/rails_7.2.gemfile.lock @@ -0,0 +1,261 @@ +PATH + remote: .. + specs: + data_migrate (9.4.0) + activerecord (>= 6.1) + railties (>= 6.1) + +GEM + remote: http://rubygems.org/ + specs: + actioncable (7.2.0.beta1) + actionpack (= 7.2.0.beta1) + activesupport (= 7.2.0.beta1) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + zeitwerk (~> 2.6) + actionmailbox (7.2.0.beta1) + actionpack (= 7.2.0.beta1) + activejob (= 7.2.0.beta1) + activerecord (= 7.2.0.beta1) + activestorage (= 7.2.0.beta1) + activesupport (= 7.2.0.beta1) + mail (>= 2.8.0) + actionmailer (7.2.0.beta1) + actionpack (= 7.2.0.beta1) + actionview (= 7.2.0.beta1) + activejob (= 7.2.0.beta1) + activesupport (= 7.2.0.beta1) + mail (>= 2.8.0) + rails-dom-testing (~> 2.2) + actionpack (7.2.0.beta1) + actionview (= 7.2.0.beta1) + activesupport (= 7.2.0.beta1) + nokogiri (>= 1.8.5) + racc + rack (>= 2.2.4) + rack-session (>= 1.0.1) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + useragent (~> 0.16) + actiontext (7.2.0.beta1) + actionpack (= 7.2.0.beta1) + activerecord (= 7.2.0.beta1) + activestorage (= 7.2.0.beta1) + activesupport (= 7.2.0.beta1) + globalid (>= 0.6.0) + nokogiri (>= 1.8.5) + actionview (7.2.0.beta1) + activesupport (= 7.2.0.beta1) + builder (~> 3.1) + erubi (~> 1.11) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + activejob (7.2.0.beta1) + activesupport (= 7.2.0.beta1) + globalid (>= 0.3.6) + activemodel (7.2.0.beta1) + activesupport (= 7.2.0.beta1) + activerecord (7.2.0.beta1) + activemodel (= 7.2.0.beta1) + activesupport (= 7.2.0.beta1) + timeout (>= 0.4.0) + activestorage (7.2.0.beta1) + actionpack (= 7.2.0.beta1) + activejob (= 7.2.0.beta1) + activerecord (= 7.2.0.beta1) + activesupport (= 7.2.0.beta1) + marcel (~> 1.0) + activesupport (7.2.0.beta1) + base64 + bigdecimal + concurrent-ruby (~> 1.0, >= 1.3.1) + connection_pool (>= 2.2.5) + drb + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0, >= 2.0.5) + appraisal (2.5.0) + bundler + rake + thor (>= 0.14.0) + ast (2.4.2) + base64 (0.2.0) + bigdecimal (3.1.8) + builder (3.2.4) + childprocess (5.0.0) + coderay (1.1.3) + concurrent-ruby (1.3.1) + connection_pool (2.4.1) + crass (1.0.6) + date (3.3.4) + diff-lcs (1.5.1) + drb (2.2.1) + erubi (1.12.0) + globalid (1.2.1) + activesupport (>= 6.1) + i18n (1.14.5) + concurrent-ruby (~> 1.0) + iniparse (1.5.0) + io-console (0.7.2) + irb (1.13.1) + rdoc (>= 4.0.0) + reline (>= 0.4.2) + json (2.7.2) + language_server-protocol (3.17.0.3) + loofah (2.22.0) + crass (~> 1.0.2) + nokogiri (>= 1.12.0) + mail (2.8.1) + mini_mime (>= 0.1.1) + net-imap + net-pop + net-smtp + marcel (1.0.4) + method_source (1.1.0) + mini_mime (1.1.5) + minitest (5.23.1) + net-imap (0.4.11) + date + net-protocol + net-pop (0.1.2) + net-protocol + net-protocol (0.2.2) + timeout + net-smtp (0.5.0) + net-protocol + nio4r (2.7.3) + nokogiri (1.16.5-aarch64-linux) + racc (~> 1.4) + nokogiri (1.16.5-arm64-darwin) + racc (~> 1.4) + nokogiri (1.16.5-x86_64-linux) + racc (~> 1.4) + overcommit (0.63.0) + childprocess (>= 0.6.3, < 6) + iniparse (~> 1.4) + rexml (~> 3.2) + parallel (1.24.0) + parser (3.3.1.0) + ast (~> 2.4.1) + racc + pry (0.14.2) + coderay (~> 1.1) + method_source (~> 1.0) + psych (5.1.2) + stringio + racc (1.8.0) + rack (3.0.11) + rack-session (2.0.0) + rack (>= 3.0.0) + rack-test (2.1.0) + rack (>= 1.3) + rackup (2.1.0) + rack (>= 3) + webrick (~> 1.8) + rails (7.2.0.beta1) + actioncable (= 7.2.0.beta1) + actionmailbox (= 7.2.0.beta1) + actionmailer (= 7.2.0.beta1) + actionpack (= 7.2.0.beta1) + actiontext (= 7.2.0.beta1) + actionview (= 7.2.0.beta1) + activejob (= 7.2.0.beta1) + activemodel (= 7.2.0.beta1) + activerecord (= 7.2.0.beta1) + activestorage (= 7.2.0.beta1) + activesupport (= 7.2.0.beta1) + bundler (>= 1.15.0) + railties (= 7.2.0.beta1) + rails-dom-testing (2.2.0) + activesupport (>= 5.0.0) + minitest + nokogiri (>= 1.6) + rails-html-sanitizer (1.6.0) + loofah (~> 2.21) + nokogiri (~> 1.14) + railties (7.2.0.beta1) + actionpack (= 7.2.0.beta1) + activesupport (= 7.2.0.beta1) + irb (~> 1.13) + rackup (>= 1.0.0) + rake (>= 12.2) + thor (~> 1.0, >= 1.2.2) + zeitwerk (~> 2.6) + rainbow (3.1.1) + rake (13.2.1) + rb-readline (0.5.5) + rdoc (6.7.0) + psych (>= 4.0.0) + regexp_parser (2.9.2) + reline (0.5.8) + io-console (~> 0.5) + rexml (3.2.8) + strscan (>= 3.0.9) + rspec (3.13.0) + rspec-core (~> 3.13.0) + rspec-expectations (~> 3.13.0) + rspec-mocks (~> 3.13.0) + rspec-core (3.13.0) + rspec-support (~> 3.13.0) + rspec-expectations (3.13.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.13.0) + rspec-mocks (3.13.1) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.13.0) + rspec-support (3.13.1) + rubocop (1.64.0) + json (~> 2.3) + language_server-protocol (>= 3.17.0) + parallel (~> 1.10) + parser (>= 3.3.0.2) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.8, < 3.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.31.1, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.31.3) + parser (>= 3.3.1.0) + ruby-progressbar (1.13.0) + sqlite3 (2.0.2-aarch64-linux-gnu) + sqlite3 (2.0.2-arm64-darwin) + sqlite3 (2.0.2-x86_64-linux-gnu) + stringio (3.1.0) + strscan (3.1.0) + thor (1.3.1) + timecop (0.9.8) + timeout (0.4.1) + tzinfo (2.0.6) + concurrent-ruby (~> 1.0) + unicode-display_width (2.5.0) + useragent (0.16.10) + webrick (1.8.1) + websocket-driver (0.7.6) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + zeitwerk (2.6.15) + +PLATFORMS + aarch64-linux + arm64-darwin-23 + x86_64-linux + +DEPENDENCIES + appraisal + data_migrate! + overcommit + pry + rails (= 7.2.0.beta1) + rake + rb-readline + rspec + rspec-core + rubocop + sqlite3 + timecop + +BUNDLED WITH + 2.4.17 diff --git a/lib/data_migrate/rails_helper.rb b/lib/data_migrate/rails_helper.rb index 9f94e73a..330f50a9 100644 --- a/lib/data_migrate/rails_helper.rb +++ b/lib/data_migrate/rails_helper.rb @@ -1,6 +1,11 @@ module DataMigrate class RailsHelper class << self + def rails_version_equal_to_or_higher_than_7_2 + return @equal_to_or_higher_than_7_2 if defined?(@equal_to_or_higher_than_7_2) + + @equal_to_or_higher_than_7_2 = Gem::Dependency.new("railties", ">= 7.2.0.alpha").match?("railties", Gem.loaded_specs["railties"].version, true) + end def rails_version_equal_to_or_higher_than_7_1 return @equal_to_or_higher_than_7_1 if defined?(@equal_to_or_higher_than_7_1) @@ -14,7 +19,9 @@ def rails_version_equal_to_or_higher_than_7_0 end def internal_metadata - if rails_version_equal_to_or_higher_than_7_1 + if rails_version_equal_to_or_higher_than_7_2 + ActiveRecord::Base.connection.pool.internal_metadata + elsif rails_version_equal_to_or_higher_than_7_1 ActiveRecord::Base.connection.internal_metadata else ActiveRecord::InternalMetadata @@ -22,7 +29,9 @@ def internal_metadata end def schema_migration - if rails_version_equal_to_or_higher_than_7_1 + if rails_version_equal_to_or_higher_than_7_2 + ActiveRecord::Base.connection.pool.schema_migration + elsif rails_version_equal_to_or_higher_than_7_1 ActiveRecord::Base.connection.schema_migration else ActiveRecord::SchemaMigration @@ -54,7 +63,9 @@ def data_schema_delete_version(version) end def data_schema_migration - if rails_version_equal_to_or_higher_than_7_1 + if rails_version_equal_to_or_higher_than_7_2 + DataMigrate::DataSchemaMigration.new(ActiveRecord::Tasks::DatabaseTasks.migration_connection.pool) + elsif rails_version_equal_to_or_higher_than_7_1 DataMigrate::DataSchemaMigration.new(ActiveRecord::Tasks::DatabaseTasks.migration_connection) else DataMigrate::DataSchemaMigration diff --git a/spec/data_migrate/migration_context_spec.rb b/spec/data_migrate/migration_context_spec.rb index c80155d4..6b6ce80e 100644 --- a/spec/data_migrate/migration_context_spec.rb +++ b/spec/data_migrate/migration_context_spec.rb @@ -4,7 +4,7 @@ describe DataMigrate::DataMigrator do let(:context) { DataMigrate::MigrationContext.new("spec/db/data") } - let(:schema_context) { ActiveRecord::MigrationContext.new("spec/db/migrate", ActiveRecord::Base.connection.schema_migration) } + let(:schema_context) { ActiveRecord::MigrationContext.new("spec/db/migrate", ar_schema_migration()) } let(:db_config) do { adapter: "sqlite3", @@ -105,4 +105,13 @@ expect(versions.count).to eq(0) end end + + # schema migration changed in Rails 7.2, from the connection to the pool object. + def ar_schema_migration + if ActiveRecord::Base.connection.pool.respond_to?(:schema_migration) + ActiveRecord::Base.connection.pool.schema_migration + else + ActiveRecord::Base.connection.schema_migration + end + end end diff --git a/tasks/databases.rake b/tasks/databases.rake index 7c92515f..5bdcb108 100644 --- a/tasks/databases.rake +++ b/tasks/databases.rake @@ -7,6 +7,7 @@ namespace :db do desc "Migrate the database data and schema (options: VERSION=x, VERBOSE=false)." task :with_data => :load_config do DataMigrate::DatabaseTasks.migrate_with_data + Rake::Task["db:_dump"].invoke Rake::Task["data:dump"].invoke end From e4aefab5a33ea9a21f80048420f3aa12952dca93 Mon Sep 17 00:00:00 2001 From: Vincent Prigent Date: Sun, 9 Jun 2024 22:31:41 +0200 Subject: [PATCH 90/98] Use connection_pool over chaining calls --- Changelog.md | 2 +- lib/data_migrate/rails_helper.rb | 6 +++--- spec/data_migrate/migration_context_spec.rb | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Changelog.md b/Changelog.md index 8764c451..effe76a9 100644 --- a/Changelog.md +++ b/Changelog.md @@ -2,7 +2,7 @@ ## 9.5.0 -- Support Rails 7.2 +- Support Rails 7.2 https://github.com/ilyakatz/data-migrate/pull/312 ## 9.4.2 - Fix db:prepare:with_data task diff --git a/lib/data_migrate/rails_helper.rb b/lib/data_migrate/rails_helper.rb index 330f50a9..d71ae443 100644 --- a/lib/data_migrate/rails_helper.rb +++ b/lib/data_migrate/rails_helper.rb @@ -20,7 +20,7 @@ def rails_version_equal_to_or_higher_than_7_0 def internal_metadata if rails_version_equal_to_or_higher_than_7_2 - ActiveRecord::Base.connection.pool.internal_metadata + ActiveRecord::Base.connection_pool.internal_metadata elsif rails_version_equal_to_or_higher_than_7_1 ActiveRecord::Base.connection.internal_metadata else @@ -30,7 +30,7 @@ def internal_metadata def schema_migration if rails_version_equal_to_or_higher_than_7_2 - ActiveRecord::Base.connection.pool.schema_migration + ActiveRecord::Base.connection_pool.schema_migration elsif rails_version_equal_to_or_higher_than_7_1 ActiveRecord::Base.connection.schema_migration else @@ -64,7 +64,7 @@ def data_schema_delete_version(version) def data_schema_migration if rails_version_equal_to_or_higher_than_7_2 - DataMigrate::DataSchemaMigration.new(ActiveRecord::Tasks::DatabaseTasks.migration_connection.pool) + DataMigrate::DataSchemaMigration.new(ActiveRecord::Tasks::DatabaseTasks.migration_connection_pool) elsif rails_version_equal_to_or_higher_than_7_1 DataMigrate::DataSchemaMigration.new(ActiveRecord::Tasks::DatabaseTasks.migration_connection) else diff --git a/spec/data_migrate/migration_context_spec.rb b/spec/data_migrate/migration_context_spec.rb index 6b6ce80e..4d147509 100644 --- a/spec/data_migrate/migration_context_spec.rb +++ b/spec/data_migrate/migration_context_spec.rb @@ -108,8 +108,8 @@ # schema migration changed in Rails 7.2, from the connection to the pool object. def ar_schema_migration - if ActiveRecord::Base.connection.pool.respond_to?(:schema_migration) - ActiveRecord::Base.connection.pool.schema_migration + if ActiveRecord::Base.connection_pool.respond_to?(:schema_migration) + ActiveRecord::Base.connection_pool.schema_migration else ActiveRecord::Base.connection.schema_migration end From 55b86f6496171a5be093495e82cf7cc16e780545 Mon Sep 17 00:00:00 2001 From: Vincent Prigent Date: Thu, 15 Aug 2024 14:50:33 +0200 Subject: [PATCH 91/98] Drop ruby 3.0 from test matrix --- .github/workflows/build.yml | 1 - gemfiles/rails_7.2.gemfile.lock | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6ac140f0..c31c416f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,7 +11,6 @@ jobs: matrix: os: [ "ubuntu-20.04" ] ruby: - - '3.0' - '3.1' - '3.2' - '3.3' diff --git a/gemfiles/rails_7.2.gemfile.lock b/gemfiles/rails_7.2.gemfile.lock index 70e69bb9..751f9e19 100644 --- a/gemfiles/rails_7.2.gemfile.lock +++ b/gemfiles/rails_7.2.gemfile.lock @@ -1,7 +1,7 @@ PATH remote: .. specs: - data_migrate (9.4.0) + data_migrate (9.4.2) activerecord (>= 6.1) railties (>= 6.1) From 4d6715eaa21404fb9cbd5bf1a140870445b5fd53 Mon Sep 17 00:00:00 2001 From: Ngan Pham Date: Thu, 15 Aug 2024 16:34:42 -0700 Subject: [PATCH 92/98] Remove Ruby 3.0 from build matrix --- .github/workflows/build.yml | 1 - Changelog.md | 7 +++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index de73c902..fdbc5419 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,7 +11,6 @@ jobs: matrix: os: [ "ubuntu-20.04" ] ruby: - - '3.0' - '3.1' - '3.2' - '3.3' diff --git a/Changelog.md b/Changelog.md index 5a184fed..2dd7b7df 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,10 +1,13 @@ # Changelog +# Unreleased +- Remove Ruby 3.0 from build matrix + ## 9.4.2 - - Fix db:prepare:with_data task +- Fix db:prepare:with_data task ## 9.4.1 - - Add db:prepare task +- Add db:prepare task ## 9.4.0 - Reset model schema cache before each data migration https://github.com/ilyakatz/data-migrate/pull/307 From d33409790486feae1a457c35e41f2e639609ae9b Mon Sep 17 00:00:00 2001 From: Ngan Pham Date: Thu, 15 Aug 2024 16:40:32 -0700 Subject: [PATCH 93/98] Update spec/data_migrate/migration_context_spec.rb Co-authored-by: Ronan --- spec/data_migrate/migration_context_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/data_migrate/migration_context_spec.rb b/spec/data_migrate/migration_context_spec.rb index 4d147509..d9951378 100644 --- a/spec/data_migrate/migration_context_spec.rb +++ b/spec/data_migrate/migration_context_spec.rb @@ -4,7 +4,7 @@ describe DataMigrate::DataMigrator do let(:context) { DataMigrate::MigrationContext.new("spec/db/data") } - let(:schema_context) { ActiveRecord::MigrationContext.new("spec/db/migrate", ar_schema_migration()) } + let(:schema_context) { ActiveRecord::MigrationContext.new("spec/db/migrate", ar_schema_migration) } let(:db_config) do { adapter: "sqlite3", From 04159f8bd82aed953a518601ad9c10aa5c7966f7 Mon Sep 17 00:00:00 2001 From: Ngan Pham Date: Thu, 15 Aug 2024 16:40:49 -0700 Subject: [PATCH 94/98] Update tasks/databases.rake Co-authored-by: Ronan --- tasks/databases.rake | 1 - 1 file changed, 1 deletion(-) diff --git a/tasks/databases.rake b/tasks/databases.rake index 5bdcb108..7c92515f 100644 --- a/tasks/databases.rake +++ b/tasks/databases.rake @@ -7,7 +7,6 @@ namespace :db do desc "Migrate the database data and schema (options: VERSION=x, VERBOSE=false)." task :with_data => :load_config do DataMigrate::DatabaseTasks.migrate_with_data - Rake::Task["db:_dump"].invoke Rake::Task["data:dump"].invoke end From 7c523193934c832ea89d317c1f8a1fbb13e02722 Mon Sep 17 00:00:00 2001 From: Bruno Costanzo Date: Mon, 19 Aug 2024 12:36:48 +0200 Subject: [PATCH 95/98] Bump version to 9.4.3 --- lib/data_migrate/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/data_migrate/version.rb b/lib/data_migrate/version.rb index ffc2c438..55b322ef 100644 --- a/lib/data_migrate/version.rb +++ b/lib/data_migrate/version.rb @@ -1,3 +1,3 @@ module DataMigrate - VERSION = "9.4.2".freeze + VERSION = "9.4.3".freeze end From 46889e5f048f51ad3045a667b917819e94f75a44 Mon Sep 17 00:00:00 2001 From: Bruno Costanzo Date: Mon, 19 Aug 2024 12:44:27 +0200 Subject: [PATCH 96/98] Bump version to 9.4.4 --- lib/data_migrate/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/data_migrate/version.rb b/lib/data_migrate/version.rb index 55b322ef..a3b3b4bb 100644 --- a/lib/data_migrate/version.rb +++ b/lib/data_migrate/version.rb @@ -1,3 +1,3 @@ module DataMigrate - VERSION = "9.4.3".freeze + VERSION = "9.4.4".freeze end From 2391e3bfdea429c6dfad2ad4c2a0f866a7bdcb32 Mon Sep 17 00:00:00 2001 From: Bruno Costanzo Date: Mon, 19 Aug 2024 13:17:36 +0200 Subject: [PATCH 97/98] Update gemfiles --- Gemfile.lock | 3 +-- gemfiles/rails_6.1.gemfile.lock | 2 +- gemfiles/rails_7.0.gemfile.lock | 2 +- gemfiles/rails_7.1.gemfile.lock | 2 +- gemfiles/rails_7.2.gemfile.lock | 2 +- 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 6930de5b..599c5cf7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - data_migrate (9.4.2) + data_migrate (9.4.4) activerecord (>= 6.1) railties (>= 6.1) @@ -151,7 +151,6 @@ GEM rubocop-ast (1.30.0) parser (>= 3.2.1.0) ruby-progressbar (1.13.0) - ruby2_keywords (0.0.5) sqlite3 (1.7.2-aarch64-linux) sqlite3 (1.7.2-arm64-darwin) sqlite3 (1.7.2-x86_64-linux) diff --git a/gemfiles/rails_6.1.gemfile.lock b/gemfiles/rails_6.1.gemfile.lock index fdd6a657..d2be375b 100644 --- a/gemfiles/rails_6.1.gemfile.lock +++ b/gemfiles/rails_6.1.gemfile.lock @@ -1,7 +1,7 @@ PATH remote: .. specs: - data_migrate (9.4.2) + data_migrate (9.4.4) activerecord (>= 6.1) railties (>= 6.1) diff --git a/gemfiles/rails_7.0.gemfile.lock b/gemfiles/rails_7.0.gemfile.lock index cf45d9cd..d745e314 100644 --- a/gemfiles/rails_7.0.gemfile.lock +++ b/gemfiles/rails_7.0.gemfile.lock @@ -1,7 +1,7 @@ PATH remote: .. specs: - data_migrate (9.4.2) + data_migrate (9.4.4) activerecord (>= 6.1) railties (>= 6.1) diff --git a/gemfiles/rails_7.1.gemfile.lock b/gemfiles/rails_7.1.gemfile.lock index f78e9d29..e7965999 100644 --- a/gemfiles/rails_7.1.gemfile.lock +++ b/gemfiles/rails_7.1.gemfile.lock @@ -1,7 +1,7 @@ PATH remote: .. specs: - data_migrate (9.4.2) + data_migrate (9.4.4) activerecord (>= 6.1) railties (>= 6.1) diff --git a/gemfiles/rails_7.2.gemfile.lock b/gemfiles/rails_7.2.gemfile.lock index 751f9e19..aab8ea5c 100644 --- a/gemfiles/rails_7.2.gemfile.lock +++ b/gemfiles/rails_7.2.gemfile.lock @@ -1,7 +1,7 @@ PATH remote: .. specs: - data_migrate (9.4.2) + data_migrate (9.4.4) activerecord (>= 6.1) railties (>= 6.1) From c5e49370a98dfb0335ea8ffde7a297cdeca5f2d0 Mon Sep 17 00:00:00 2001 From: Bruno Costanzo Date: Mon, 19 Aug 2024 23:27:11 +0200 Subject: [PATCH 98/98] Bump version to 11.0.0.rc and update changelog --- Changelog.md | 5 +- Gemfile.lock | 2 +- gemfiles/rails_6.1.gemfile.lock | 148 +++++++++++++++--------------- gemfiles/rails_7.0.gemfile.lock | 142 ++++++++++++++--------------- gemfiles/rails_7.1.gemfile | 2 +- gemfiles/rails_7.1.gemfile.lock | 157 ++++++++++++++++---------------- gemfiles/rails_7.2.gemfile | 2 +- gemfiles/rails_7.2.gemfile.lock | 144 +++++++++++++++-------------- lib/data_migrate/version.rb | 2 +- 9 files changed, 304 insertions(+), 300 deletions(-) diff --git a/Changelog.md b/Changelog.md index d5350458..8c7cf9e6 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,8 +1,9 @@ # Changelog -# Unreleased +# 11.0.0rc - Remove Ruby 3.0 from build matrix -- Support Rails 7.2 https://github.com/ilyakatz/data-migrate/pull/312 +- Support Rails 7.2.0 https://github.com/ilyakatz/data-migrate/pull/312 +- Update gemfile.lock builds ## 9.4.2 - Fix db:prepare:with_data task diff --git a/Gemfile.lock b/Gemfile.lock index 599c5cf7..21bc5433 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - data_migrate (9.4.4) + data_migrate (11.0.0.rc) activerecord (>= 6.1) railties (>= 6.1) diff --git a/gemfiles/rails_6.1.gemfile.lock b/gemfiles/rails_6.1.gemfile.lock index d2be375b..e49aa0f0 100644 --- a/gemfiles/rails_6.1.gemfile.lock +++ b/gemfiles/rails_6.1.gemfile.lock @@ -1,67 +1,67 @@ PATH remote: .. specs: - data_migrate (9.4.4) + data_migrate (11.0.0.rc) activerecord (>= 6.1) railties (>= 6.1) GEM remote: http://rubygems.org/ specs: - actioncable (6.1.7.7) - actionpack (= 6.1.7.7) - activesupport (= 6.1.7.7) + actioncable (6.1.7.8) + actionpack (= 6.1.7.8) + activesupport (= 6.1.7.8) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (6.1.7.7) - actionpack (= 6.1.7.7) - activejob (= 6.1.7.7) - activerecord (= 6.1.7.7) - activestorage (= 6.1.7.7) - activesupport (= 6.1.7.7) + actionmailbox (6.1.7.8) + actionpack (= 6.1.7.8) + activejob (= 6.1.7.8) + activerecord (= 6.1.7.8) + activestorage (= 6.1.7.8) + activesupport (= 6.1.7.8) mail (>= 2.7.1) - actionmailer (6.1.7.7) - actionpack (= 6.1.7.7) - actionview (= 6.1.7.7) - activejob (= 6.1.7.7) - activesupport (= 6.1.7.7) + actionmailer (6.1.7.8) + actionpack (= 6.1.7.8) + actionview (= 6.1.7.8) + activejob (= 6.1.7.8) + activesupport (= 6.1.7.8) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (6.1.7.7) - actionview (= 6.1.7.7) - activesupport (= 6.1.7.7) + actionpack (6.1.7.8) + actionview (= 6.1.7.8) + activesupport (= 6.1.7.8) rack (~> 2.0, >= 2.0.9) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (6.1.7.7) - actionpack (= 6.1.7.7) - activerecord (= 6.1.7.7) - activestorage (= 6.1.7.7) - activesupport (= 6.1.7.7) + actiontext (6.1.7.8) + actionpack (= 6.1.7.8) + activerecord (= 6.1.7.8) + activestorage (= 6.1.7.8) + activesupport (= 6.1.7.8) nokogiri (>= 1.8.5) - actionview (6.1.7.7) - activesupport (= 6.1.7.7) + actionview (6.1.7.8) + activesupport (= 6.1.7.8) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (6.1.7.7) - activesupport (= 6.1.7.7) + activejob (6.1.7.8) + activesupport (= 6.1.7.8) globalid (>= 0.3.6) - activemodel (6.1.7.7) - activesupport (= 6.1.7.7) - activerecord (6.1.7.7) - activemodel (= 6.1.7.7) - activesupport (= 6.1.7.7) - activestorage (6.1.7.7) - actionpack (= 6.1.7.7) - activejob (= 6.1.7.7) - activerecord (= 6.1.7.7) - activesupport (= 6.1.7.7) + activemodel (6.1.7.8) + activesupport (= 6.1.7.8) + activerecord (6.1.7.8) + activemodel (= 6.1.7.8) + activesupport (= 6.1.7.8) + activestorage (6.1.7.8) + actionpack (= 6.1.7.8) + activejob (= 6.1.7.8) + activerecord (= 6.1.7.8) + activesupport (= 6.1.7.8) marcel (~> 1.0) mini_mime (>= 1.1.0) - activesupport (6.1.7.7) + activesupport (6.1.7.8) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) @@ -72,17 +72,17 @@ GEM rake thor (>= 0.14.0) ast (2.4.2) - builder (3.2.4) + builder (3.3.0) childprocess (4.1.0) coderay (1.1.3) - concurrent-ruby (1.2.3) + concurrent-ruby (1.3.4) crass (1.0.6) date (3.3.4) diff-lcs (1.5.0) - erubi (1.12.0) + erubi (1.13.0) globalid (1.2.1) activesupport (>= 6.1) - i18n (1.14.1) + i18n (1.14.5) concurrent-ruby (~> 1.0) iniparse (1.5.0) json (2.6.3) @@ -94,25 +94,25 @@ GEM net-imap net-pop net-smtp - marcel (1.0.2) - method_source (1.0.0) + marcel (1.0.4) + method_source (1.1.0) mini_mime (1.1.5) - minitest (5.22.2) - net-imap (0.4.10) + minitest (5.25.1) + net-imap (0.4.14) date net-protocol net-pop (0.1.2) net-protocol net-protocol (0.2.2) timeout - net-smtp (0.4.0.1) + net-smtp (0.5.0) net-protocol - nio4r (2.7.0) - nokogiri (1.16.2-aarch64-linux) + nio4r (2.7.3) + nokogiri (1.16.7-aarch64-linux) racc (~> 1.4) - nokogiri (1.16.2-arm64-darwin) + nokogiri (1.16.7-arm64-darwin) racc (~> 1.4) - nokogiri (1.16.2-x86_64-linux) + nokogiri (1.16.7-x86_64-linux) racc (~> 1.4) overcommit (0.60.0) childprocess (>= 0.6.3, < 5) @@ -125,24 +125,24 @@ GEM pry (0.14.2) coderay (~> 1.1) method_source (~> 1.0) - racc (1.7.3) - rack (2.2.8.1) + racc (1.8.1) + rack (2.2.9) rack-test (2.1.0) rack (>= 1.3) - rails (6.1.7.7) - actioncable (= 6.1.7.7) - actionmailbox (= 6.1.7.7) - actionmailer (= 6.1.7.7) - actionpack (= 6.1.7.7) - actiontext (= 6.1.7.7) - actionview (= 6.1.7.7) - activejob (= 6.1.7.7) - activemodel (= 6.1.7.7) - activerecord (= 6.1.7.7) - activestorage (= 6.1.7.7) - activesupport (= 6.1.7.7) + rails (6.1.7.8) + actioncable (= 6.1.7.8) + actionmailbox (= 6.1.7.8) + actionmailer (= 6.1.7.8) + actionpack (= 6.1.7.8) + actiontext (= 6.1.7.8) + actionview (= 6.1.7.8) + activejob (= 6.1.7.8) + activemodel (= 6.1.7.8) + activerecord (= 6.1.7.8) + activestorage (= 6.1.7.8) + activesupport (= 6.1.7.8) bundler (>= 1.15.0) - railties (= 6.1.7.7) + railties (= 6.1.7.8) sprockets-rails (>= 2.0.0) rails-dom-testing (2.2.0) activesupport (>= 5.0.0) @@ -151,14 +151,14 @@ GEM rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) - railties (6.1.7.7) - actionpack (= 6.1.7.7) - activesupport (= 6.1.7.7) + railties (6.1.7.8) + actionpack (= 6.1.7.8) + activesupport (= 6.1.7.8) method_source rake (>= 12.2) thor (~> 1.0) rainbow (3.1.1) - rake (13.1.0) + rake (13.2.1) rb-readline (0.5.5) regexp_parser (2.8.1) rexml (3.2.5) @@ -191,9 +191,9 @@ GEM sprockets (4.2.1) concurrent-ruby (~> 1.0) rack (>= 2.2.4, < 4) - sprockets-rails (3.4.2) - actionpack (>= 5.2) - activesupport (>= 5.2) + sprockets-rails (3.5.2) + actionpack (>= 6.1) + activesupport (>= 6.1) sprockets (>= 3.0.0) sqlite3 (1.7.2-aarch64-linux) sqlite3 (1.7.2-arm64-darwin) @@ -207,7 +207,7 @@ GEM websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) - zeitwerk (2.6.13) + zeitwerk (2.6.17) PLATFORMS aarch64-linux diff --git a/gemfiles/rails_7.0.gemfile.lock b/gemfiles/rails_7.0.gemfile.lock index d745e314..e024bade 100644 --- a/gemfiles/rails_7.0.gemfile.lock +++ b/gemfiles/rails_7.0.gemfile.lock @@ -1,74 +1,74 @@ PATH remote: .. specs: - data_migrate (9.4.4) + data_migrate (11.0.0.rc) activerecord (>= 6.1) railties (>= 6.1) GEM remote: http://rubygems.org/ specs: - actioncable (7.0.8.1) - actionpack (= 7.0.8.1) - activesupport (= 7.0.8.1) + actioncable (7.0.8.4) + actionpack (= 7.0.8.4) + activesupport (= 7.0.8.4) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (7.0.8.1) - actionpack (= 7.0.8.1) - activejob (= 7.0.8.1) - activerecord (= 7.0.8.1) - activestorage (= 7.0.8.1) - activesupport (= 7.0.8.1) + actionmailbox (7.0.8.4) + actionpack (= 7.0.8.4) + activejob (= 7.0.8.4) + activerecord (= 7.0.8.4) + activestorage (= 7.0.8.4) + activesupport (= 7.0.8.4) mail (>= 2.7.1) net-imap net-pop net-smtp - actionmailer (7.0.8.1) - actionpack (= 7.0.8.1) - actionview (= 7.0.8.1) - activejob (= 7.0.8.1) - activesupport (= 7.0.8.1) + actionmailer (7.0.8.4) + actionpack (= 7.0.8.4) + actionview (= 7.0.8.4) + activejob (= 7.0.8.4) + activesupport (= 7.0.8.4) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp rails-dom-testing (~> 2.0) - actionpack (7.0.8.1) - actionview (= 7.0.8.1) - activesupport (= 7.0.8.1) + actionpack (7.0.8.4) + actionview (= 7.0.8.4) + activesupport (= 7.0.8.4) rack (~> 2.0, >= 2.2.4) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (7.0.8.1) - actionpack (= 7.0.8.1) - activerecord (= 7.0.8.1) - activestorage (= 7.0.8.1) - activesupport (= 7.0.8.1) + actiontext (7.0.8.4) + actionpack (= 7.0.8.4) + activerecord (= 7.0.8.4) + activestorage (= 7.0.8.4) + activesupport (= 7.0.8.4) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.0.8.1) - activesupport (= 7.0.8.1) + actionview (7.0.8.4) + activesupport (= 7.0.8.4) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (7.0.8.1) - activesupport (= 7.0.8.1) + activejob (7.0.8.4) + activesupport (= 7.0.8.4) globalid (>= 0.3.6) - activemodel (7.0.8.1) - activesupport (= 7.0.8.1) - activerecord (7.0.8.1) - activemodel (= 7.0.8.1) - activesupport (= 7.0.8.1) - activestorage (7.0.8.1) - actionpack (= 7.0.8.1) - activejob (= 7.0.8.1) - activerecord (= 7.0.8.1) - activesupport (= 7.0.8.1) + activemodel (7.0.8.4) + activesupport (= 7.0.8.4) + activerecord (7.0.8.4) + activemodel (= 7.0.8.4) + activesupport (= 7.0.8.4) + activestorage (7.0.8.4) + actionpack (= 7.0.8.4) + activejob (= 7.0.8.4) + activerecord (= 7.0.8.4) + activesupport (= 7.0.8.4) marcel (~> 1.0) mini_mime (>= 1.1.0) - activesupport (7.0.8.1) + activesupport (7.0.8.4) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) @@ -78,17 +78,17 @@ GEM rake thor (>= 0.14.0) ast (2.4.2) - builder (3.2.4) + builder (3.3.0) childprocess (4.1.0) coderay (1.1.3) - concurrent-ruby (1.2.3) + concurrent-ruby (1.3.4) crass (1.0.6) date (3.3.4) diff-lcs (1.5.0) - erubi (1.12.0) + erubi (1.13.0) globalid (1.2.1) activesupport (>= 6.1) - i18n (1.14.1) + i18n (1.14.5) concurrent-ruby (~> 1.0) iniparse (1.5.0) json (2.6.3) @@ -101,25 +101,25 @@ GEM net-imap net-pop net-smtp - marcel (1.0.2) - method_source (1.0.0) + marcel (1.0.4) + method_source (1.1.0) mini_mime (1.1.5) - minitest (5.22.2) - net-imap (0.4.10) + minitest (5.25.1) + net-imap (0.4.14) date net-protocol net-pop (0.1.2) net-protocol net-protocol (0.2.2) timeout - net-smtp (0.4.0.1) + net-smtp (0.5.0) net-protocol - nio4r (2.7.0) - nokogiri (1.16.2-aarch64-linux) + nio4r (2.7.3) + nokogiri (1.16.7-aarch64-linux) racc (~> 1.4) - nokogiri (1.16.2-arm64-darwin) + nokogiri (1.16.7-arm64-darwin) racc (~> 1.4) - nokogiri (1.16.2-x86_64-linux) + nokogiri (1.16.7-x86_64-linux) racc (~> 1.4) overcommit (0.60.0) childprocess (>= 0.6.3, < 5) @@ -132,24 +132,24 @@ GEM pry (0.14.2) coderay (~> 1.1) method_source (~> 1.0) - racc (1.7.3) - rack (2.2.8.1) + racc (1.8.1) + rack (2.2.9) rack-test (2.1.0) rack (>= 1.3) - rails (7.0.8.1) - actioncable (= 7.0.8.1) - actionmailbox (= 7.0.8.1) - actionmailer (= 7.0.8.1) - actionpack (= 7.0.8.1) - actiontext (= 7.0.8.1) - actionview (= 7.0.8.1) - activejob (= 7.0.8.1) - activemodel (= 7.0.8.1) - activerecord (= 7.0.8.1) - activestorage (= 7.0.8.1) - activesupport (= 7.0.8.1) + rails (7.0.8.4) + actioncable (= 7.0.8.4) + actionmailbox (= 7.0.8.4) + actionmailer (= 7.0.8.4) + actionpack (= 7.0.8.4) + actiontext (= 7.0.8.4) + actionview (= 7.0.8.4) + activejob (= 7.0.8.4) + activemodel (= 7.0.8.4) + activerecord (= 7.0.8.4) + activestorage (= 7.0.8.4) + activesupport (= 7.0.8.4) bundler (>= 1.15.0) - railties (= 7.0.8.1) + railties (= 7.0.8.4) rails-dom-testing (2.2.0) activesupport (>= 5.0.0) minitest @@ -157,15 +157,15 @@ GEM rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) - railties (7.0.8.1) - actionpack (= 7.0.8.1) - activesupport (= 7.0.8.1) + railties (7.0.8.4) + actionpack (= 7.0.8.4) + activesupport (= 7.0.8.4) method_source rake (>= 12.2) thor (~> 1.0) zeitwerk (~> 2.5) rainbow (3.1.1) - rake (13.1.0) + rake (13.2.1) rb-readline (0.5.5) regexp_parser (2.8.1) rexml (3.2.5) @@ -208,7 +208,7 @@ GEM websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) - zeitwerk (2.6.13) + zeitwerk (2.6.17) PLATFORMS aarch64-linux diff --git a/gemfiles/rails_7.1.gemfile b/gemfiles/rails_7.1.gemfile index 2daec6fe..c26f542a 100644 --- a/gemfiles/rails_7.1.gemfile +++ b/gemfiles/rails_7.1.gemfile @@ -2,6 +2,6 @@ source "http://rubygems.org" -gem "rails", "7.1.0" +gem "rails", "~> 7.1.0" gemspec path: "../" diff --git a/gemfiles/rails_7.1.gemfile.lock b/gemfiles/rails_7.1.gemfile.lock index e7965999..3c402699 100644 --- a/gemfiles/rails_7.1.gemfile.lock +++ b/gemfiles/rails_7.1.gemfile.lock @@ -1,77 +1,78 @@ PATH remote: .. specs: - data_migrate (9.4.4) + data_migrate (11.0.0.rc) activerecord (>= 6.1) railties (>= 6.1) GEM remote: http://rubygems.org/ specs: - actioncable (7.1.0) - actionpack (= 7.1.0) - activesupport (= 7.1.0) + actioncable (7.1.3.4) + actionpack (= 7.1.3.4) + activesupport (= 7.1.3.4) nio4r (~> 2.0) websocket-driver (>= 0.6.1) zeitwerk (~> 2.6) - actionmailbox (7.1.0) - actionpack (= 7.1.0) - activejob (= 7.1.0) - activerecord (= 7.1.0) - activestorage (= 7.1.0) - activesupport (= 7.1.0) + actionmailbox (7.1.3.4) + actionpack (= 7.1.3.4) + activejob (= 7.1.3.4) + activerecord (= 7.1.3.4) + activestorage (= 7.1.3.4) + activesupport (= 7.1.3.4) mail (>= 2.7.1) net-imap net-pop net-smtp - actionmailer (7.1.0) - actionpack (= 7.1.0) - actionview (= 7.1.0) - activejob (= 7.1.0) - activesupport (= 7.1.0) + actionmailer (7.1.3.4) + actionpack (= 7.1.3.4) + actionview (= 7.1.3.4) + activejob (= 7.1.3.4) + activesupport (= 7.1.3.4) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp rails-dom-testing (~> 2.2) - actionpack (7.1.0) - actionview (= 7.1.0) - activesupport (= 7.1.0) + actionpack (7.1.3.4) + actionview (= 7.1.3.4) + activesupport (= 7.1.3.4) nokogiri (>= 1.8.5) + racc rack (>= 2.2.4) rack-session (>= 1.0.1) rack-test (>= 0.6.3) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - actiontext (7.1.0) - actionpack (= 7.1.0) - activerecord (= 7.1.0) - activestorage (= 7.1.0) - activesupport (= 7.1.0) + actiontext (7.1.3.4) + actionpack (= 7.1.3.4) + activerecord (= 7.1.3.4) + activestorage (= 7.1.3.4) + activesupport (= 7.1.3.4) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.1.0) - activesupport (= 7.1.0) + actionview (7.1.3.4) + activesupport (= 7.1.3.4) builder (~> 3.1) erubi (~> 1.11) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - activejob (7.1.0) - activesupport (= 7.1.0) + activejob (7.1.3.4) + activesupport (= 7.1.3.4) globalid (>= 0.3.6) - activemodel (7.1.0) - activesupport (= 7.1.0) - activerecord (7.1.0) - activemodel (= 7.1.0) - activesupport (= 7.1.0) + activemodel (7.1.3.4) + activesupport (= 7.1.3.4) + activerecord (7.1.3.4) + activemodel (= 7.1.3.4) + activesupport (= 7.1.3.4) timeout (>= 0.4.0) - activestorage (7.1.0) - actionpack (= 7.1.0) - activejob (= 7.1.0) - activerecord (= 7.1.0) - activesupport (= 7.1.0) + activestorage (7.1.3.4) + actionpack (= 7.1.3.4) + activejob (= 7.1.3.4) + activerecord (= 7.1.3.4) + activesupport (= 7.1.3.4) marcel (~> 1.0) - activesupport (7.1.0) + activesupport (7.1.3.4) base64 bigdecimal concurrent-ruby (~> 1.0, >= 1.0.2) @@ -87,26 +88,25 @@ GEM thor (>= 0.14.0) ast (2.4.2) base64 (0.2.0) - bigdecimal (3.1.6) - builder (3.2.4) + bigdecimal (3.1.8) + builder (3.3.0) childprocess (4.1.0) coderay (1.1.3) - concurrent-ruby (1.2.3) + concurrent-ruby (1.3.4) connection_pool (2.4.1) crass (1.0.6) date (3.3.4) diff-lcs (1.5.0) - drb (2.2.0) - ruby2_keywords - erubi (1.12.0) + drb (2.2.1) + erubi (1.13.0) globalid (1.2.1) activesupport (>= 6.1) - i18n (1.14.1) + i18n (1.14.5) concurrent-ruby (~> 1.0) iniparse (1.5.0) io-console (0.7.2) - irb (1.11.2) - rdoc + irb (1.14.0) + rdoc (>= 4.0.0) reline (>= 0.4.2) json (2.6.3) language_server-protocol (3.17.0.3) @@ -121,23 +121,23 @@ GEM marcel (1.0.4) method_source (1.0.0) mini_mime (1.1.5) - minitest (5.22.2) + minitest (5.25.1) mutex_m (0.2.0) - net-imap (0.4.10) + net-imap (0.4.14) date net-protocol net-pop (0.1.2) net-protocol net-protocol (0.2.2) timeout - net-smtp (0.4.0.1) + net-smtp (0.5.0) net-protocol - nio4r (2.7.0) - nokogiri (1.16.2-aarch64-linux) + nio4r (2.7.3) + nokogiri (1.16.7-aarch64-linux) racc (~> 1.4) - nokogiri (1.16.2-arm64-darwin) + nokogiri (1.16.7-arm64-darwin) racc (~> 1.4) - nokogiri (1.16.2-x86_64-linux) + nokogiri (1.16.7-x86_64-linux) racc (~> 1.4) overcommit (0.60.0) childprocess (>= 0.6.3, < 5) @@ -152,8 +152,8 @@ GEM method_source (~> 1.0) psych (5.1.2) stringio - racc (1.7.3) - rack (3.0.9.1) + racc (1.8.1) + rack (3.1.7) rack-session (2.0.0) rack (>= 3.0.0) rack-test (2.1.0) @@ -161,20 +161,20 @@ GEM rackup (2.1.0) rack (>= 3) webrick (~> 1.8) - rails (7.1.0) - actioncable (= 7.1.0) - actionmailbox (= 7.1.0) - actionmailer (= 7.1.0) - actionpack (= 7.1.0) - actiontext (= 7.1.0) - actionview (= 7.1.0) - activejob (= 7.1.0) - activemodel (= 7.1.0) - activerecord (= 7.1.0) - activestorage (= 7.1.0) - activesupport (= 7.1.0) + rails (7.1.3.4) + actioncable (= 7.1.3.4) + actionmailbox (= 7.1.3.4) + actionmailer (= 7.1.3.4) + actionpack (= 7.1.3.4) + actiontext (= 7.1.3.4) + actionview (= 7.1.3.4) + activejob (= 7.1.3.4) + activemodel (= 7.1.3.4) + activerecord (= 7.1.3.4) + activestorage (= 7.1.3.4) + activesupport (= 7.1.3.4) bundler (>= 1.15.0) - railties (= 7.1.0) + railties (= 7.1.3.4) rails-dom-testing (2.2.0) activesupport (>= 5.0.0) minitest @@ -182,21 +182,21 @@ GEM rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) - railties (7.1.0) - actionpack (= 7.1.0) - activesupport (= 7.1.0) + railties (7.1.3.4) + actionpack (= 7.1.3.4) + activesupport (= 7.1.3.4) irb rackup (>= 1.0.0) rake (>= 12.2) thor (~> 1.0, >= 1.2.2) zeitwerk (~> 2.6) rainbow (3.1.1) - rake (13.1.0) + rake (13.2.1) rb-readline (0.5.5) - rdoc (6.6.2) + rdoc (6.7.0) psych (>= 4.0.0) regexp_parser (2.8.1) - reline (0.4.3) + reline (0.5.9) io-console (~> 0.5) rexml (3.2.5) rspec (3.12.0) @@ -226,11 +226,10 @@ GEM rubocop-ast (1.29.0) parser (>= 3.2.1.0) ruby-progressbar (1.13.0) - ruby2_keywords (0.0.5) sqlite3 (1.7.2-aarch64-linux) sqlite3 (1.7.2-arm64-darwin) sqlite3 (1.7.2-x86_64-linux) - stringio (3.1.0) + stringio (3.1.1) thor (1.3.1) timecop (0.9.6) timeout (0.4.1) @@ -241,7 +240,7 @@ GEM websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) - zeitwerk (2.6.13) + zeitwerk (2.6.17) PLATFORMS aarch64-linux @@ -254,7 +253,7 @@ DEPENDENCIES data_migrate! overcommit pry - rails (= 7.1.0) + rails (~> 7.1.0) rake rb-readline rspec diff --git a/gemfiles/rails_7.2.gemfile b/gemfiles/rails_7.2.gemfile index 6730ca89..54a05ef5 100644 --- a/gemfiles/rails_7.2.gemfile +++ b/gemfiles/rails_7.2.gemfile @@ -2,6 +2,6 @@ source "http://rubygems.org" -gem "rails", "7.2.0.beta1" +gem "rails", "~> 7.2.0" gemspec path: "../" diff --git a/gemfiles/rails_7.2.gemfile.lock b/gemfiles/rails_7.2.gemfile.lock index aab8ea5c..9858f1af 100644 --- a/gemfiles/rails_7.2.gemfile.lock +++ b/gemfiles/rails_7.2.gemfile.lock @@ -1,80 +1,82 @@ PATH remote: .. specs: - data_migrate (9.4.4) + data_migrate (11.0.0.rc) activerecord (>= 6.1) railties (>= 6.1) GEM remote: http://rubygems.org/ specs: - actioncable (7.2.0.beta1) - actionpack (= 7.2.0.beta1) - activesupport (= 7.2.0.beta1) + actioncable (7.2.0) + actionpack (= 7.2.0) + activesupport (= 7.2.0) nio4r (~> 2.0) websocket-driver (>= 0.6.1) zeitwerk (~> 2.6) - actionmailbox (7.2.0.beta1) - actionpack (= 7.2.0.beta1) - activejob (= 7.2.0.beta1) - activerecord (= 7.2.0.beta1) - activestorage (= 7.2.0.beta1) - activesupport (= 7.2.0.beta1) + actionmailbox (7.2.0) + actionpack (= 7.2.0) + activejob (= 7.2.0) + activerecord (= 7.2.0) + activestorage (= 7.2.0) + activesupport (= 7.2.0) mail (>= 2.8.0) - actionmailer (7.2.0.beta1) - actionpack (= 7.2.0.beta1) - actionview (= 7.2.0.beta1) - activejob (= 7.2.0.beta1) - activesupport (= 7.2.0.beta1) + actionmailer (7.2.0) + actionpack (= 7.2.0) + actionview (= 7.2.0) + activejob (= 7.2.0) + activesupport (= 7.2.0) mail (>= 2.8.0) rails-dom-testing (~> 2.2) - actionpack (7.2.0.beta1) - actionview (= 7.2.0.beta1) - activesupport (= 7.2.0.beta1) + actionpack (7.2.0) + actionview (= 7.2.0) + activesupport (= 7.2.0) nokogiri (>= 1.8.5) racc - rack (>= 2.2.4) + rack (>= 2.2.4, < 3.2) rack-session (>= 1.0.1) rack-test (>= 0.6.3) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) useragent (~> 0.16) - actiontext (7.2.0.beta1) - actionpack (= 7.2.0.beta1) - activerecord (= 7.2.0.beta1) - activestorage (= 7.2.0.beta1) - activesupport (= 7.2.0.beta1) + actiontext (7.2.0) + actionpack (= 7.2.0) + activerecord (= 7.2.0) + activestorage (= 7.2.0) + activesupport (= 7.2.0) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.2.0.beta1) - activesupport (= 7.2.0.beta1) + actionview (7.2.0) + activesupport (= 7.2.0) builder (~> 3.1) erubi (~> 1.11) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - activejob (7.2.0.beta1) - activesupport (= 7.2.0.beta1) + activejob (7.2.0) + activesupport (= 7.2.0) globalid (>= 0.3.6) - activemodel (7.2.0.beta1) - activesupport (= 7.2.0.beta1) - activerecord (7.2.0.beta1) - activemodel (= 7.2.0.beta1) - activesupport (= 7.2.0.beta1) + activemodel (7.2.0) + activesupport (= 7.2.0) + activerecord (7.2.0) + activemodel (= 7.2.0) + activesupport (= 7.2.0) timeout (>= 0.4.0) - activestorage (7.2.0.beta1) - actionpack (= 7.2.0.beta1) - activejob (= 7.2.0.beta1) - activerecord (= 7.2.0.beta1) - activesupport (= 7.2.0.beta1) + activestorage (7.2.0) + actionpack (= 7.2.0) + activejob (= 7.2.0) + activerecord (= 7.2.0) + activesupport (= 7.2.0) marcel (~> 1.0) - activesupport (7.2.0.beta1) + activesupport (7.2.0) base64 bigdecimal concurrent-ruby (~> 1.0, >= 1.3.1) connection_pool (>= 2.2.5) drb i18n (>= 1.6, < 2) + logger (>= 1.4.2) minitest (>= 5.1) + securerandom (>= 0.3) tzinfo (~> 2.0, >= 2.0.5) appraisal (2.5.0) bundler @@ -83,27 +85,28 @@ GEM ast (2.4.2) base64 (0.2.0) bigdecimal (3.1.8) - builder (3.2.4) + builder (3.3.0) childprocess (5.0.0) coderay (1.1.3) - concurrent-ruby (1.3.1) + concurrent-ruby (1.3.4) connection_pool (2.4.1) crass (1.0.6) date (3.3.4) diff-lcs (1.5.1) drb (2.2.1) - erubi (1.12.0) + erubi (1.13.0) globalid (1.2.1) activesupport (>= 6.1) i18n (1.14.5) concurrent-ruby (~> 1.0) iniparse (1.5.0) io-console (0.7.2) - irb (1.13.1) + irb (1.14.0) rdoc (>= 4.0.0) reline (>= 0.4.2) json (2.7.2) language_server-protocol (3.17.0.3) + logger (1.6.0) loofah (2.22.0) crass (~> 1.0.2) nokogiri (>= 1.12.0) @@ -115,8 +118,8 @@ GEM marcel (1.0.4) method_source (1.1.0) mini_mime (1.1.5) - minitest (5.23.1) - net-imap (0.4.11) + minitest (5.25.1) + net-imap (0.4.14) date net-protocol net-pop (0.1.2) @@ -126,11 +129,11 @@ GEM net-smtp (0.5.0) net-protocol nio4r (2.7.3) - nokogiri (1.16.5-aarch64-linux) + nokogiri (1.16.7-aarch64-linux) racc (~> 1.4) - nokogiri (1.16.5-arm64-darwin) + nokogiri (1.16.7-arm64-darwin) racc (~> 1.4) - nokogiri (1.16.5-x86_64-linux) + nokogiri (1.16.7-x86_64-linux) racc (~> 1.4) overcommit (0.63.0) childprocess (>= 0.6.3, < 6) @@ -145,8 +148,8 @@ GEM method_source (~> 1.0) psych (5.1.2) stringio - racc (1.8.0) - rack (3.0.11) + racc (1.8.1) + rack (3.1.7) rack-session (2.0.0) rack (>= 3.0.0) rack-test (2.1.0) @@ -154,20 +157,20 @@ GEM rackup (2.1.0) rack (>= 3) webrick (~> 1.8) - rails (7.2.0.beta1) - actioncable (= 7.2.0.beta1) - actionmailbox (= 7.2.0.beta1) - actionmailer (= 7.2.0.beta1) - actionpack (= 7.2.0.beta1) - actiontext (= 7.2.0.beta1) - actionview (= 7.2.0.beta1) - activejob (= 7.2.0.beta1) - activemodel (= 7.2.0.beta1) - activerecord (= 7.2.0.beta1) - activestorage (= 7.2.0.beta1) - activesupport (= 7.2.0.beta1) + rails (7.2.0) + actioncable (= 7.2.0) + actionmailbox (= 7.2.0) + actionmailer (= 7.2.0) + actionpack (= 7.2.0) + actiontext (= 7.2.0) + actionview (= 7.2.0) + activejob (= 7.2.0) + activemodel (= 7.2.0) + activerecord (= 7.2.0) + activestorage (= 7.2.0) + activesupport (= 7.2.0) bundler (>= 1.15.0) - railties (= 7.2.0.beta1) + railties (= 7.2.0) rails-dom-testing (2.2.0) activesupport (>= 5.0.0) minitest @@ -175,9 +178,9 @@ GEM rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) - railties (7.2.0.beta1) - actionpack (= 7.2.0.beta1) - activesupport (= 7.2.0.beta1) + railties (7.2.0) + actionpack (= 7.2.0) + activesupport (= 7.2.0) irb (~> 1.13) rackup (>= 1.0.0) rake (>= 12.2) @@ -189,7 +192,7 @@ GEM rdoc (6.7.0) psych (>= 4.0.0) regexp_parser (2.9.2) - reline (0.5.8) + reline (0.5.9) io-console (~> 0.5) rexml (3.2.8) strscan (>= 3.0.9) @@ -220,10 +223,11 @@ GEM rubocop-ast (1.31.3) parser (>= 3.3.1.0) ruby-progressbar (1.13.0) + securerandom (0.3.1) sqlite3 (2.0.2-aarch64-linux-gnu) sqlite3 (2.0.2-arm64-darwin) sqlite3 (2.0.2-x86_64-linux-gnu) - stringio (3.1.0) + stringio (3.1.1) strscan (3.1.0) thor (1.3.1) timecop (0.9.8) @@ -236,7 +240,7 @@ GEM websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) - zeitwerk (2.6.15) + zeitwerk (2.6.17) PLATFORMS aarch64-linux @@ -248,7 +252,7 @@ DEPENDENCIES data_migrate! overcommit pry - rails (= 7.2.0.beta1) + rails (~> 7.2.0) rake rb-readline rspec diff --git a/lib/data_migrate/version.rb b/lib/data_migrate/version.rb index a3b3b4bb..db46d66b 100644 --- a/lib/data_migrate/version.rb +++ b/lib/data_migrate/version.rb @@ -1,3 +1,3 @@ module DataMigrate - VERSION = "9.4.4".freeze + VERSION = "11.0.0.rc".freeze end