data_migrate 3.2.0 → 11.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. checksums.yaml +5 -5
  2. data/Changelog.md +246 -2
  3. data/README.md +107 -91
  4. data/lib/capistrano/data_migrate/migrate.rb +3 -4
  5. data/lib/data_migrate/config.rb +33 -0
  6. data/lib/data_migrate/data_migrator.rb +54 -58
  7. data/lib/data_migrate/data_schema.rb +63 -0
  8. data/lib/data_migrate/data_schema_migration.rb +23 -6
  9. data/lib/data_migrate/database_configurations_wrapper.rb +11 -0
  10. data/lib/data_migrate/database_tasks.rb +290 -0
  11. data/lib/data_migrate/migration_context.rb +93 -0
  12. data/lib/data_migrate/rails_helper.rb +91 -0
  13. data/lib/data_migrate/schema_dumper.rb +38 -0
  14. data/lib/data_migrate/schema_migration.rb +41 -0
  15. data/lib/data_migrate/status_service.rb +58 -0
  16. data/lib/data_migrate/tasks/data_migrate_tasks.rb +107 -0
  17. data/lib/data_migrate/version.rb +1 -1
  18. data/lib/data_migrate.rb +20 -7
  19. data/lib/generators/data_migrate.rb +15 -2
  20. data/lib/generators/data_migration/data_migration_generator.rb +22 -21
  21. data/lib/generators/data_migration/templates/data_migration.rb +4 -2
  22. data/tasks/databases.rake +115 -228
  23. metadata +64 -42
  24. data/.gitignore +0 -6
  25. data/.rspec +0 -3
  26. data/.travis.yml +0 -17
  27. data/Appraisals +0 -21
  28. data/Gemfile +0 -4
  29. data/Gemfile.rails5 +0 -5
  30. data/Gemfile.rails5.1 +0 -5
  31. data/Rakefile +0 -2
  32. data/data_migrate.gemspec +0 -39
  33. data/gemfiles/rails_4.0.gemfile +0 -7
  34. data/gemfiles/rails_4.1.gemfile +0 -7
  35. data/gemfiles/rails_4.2.gemfile +0 -8
  36. data/gemfiles/rails_5.0.gemfile +0 -7
  37. data/gemfiles/rails_5.1.gemfile +0 -7
  38. data/lib/data_migrate/migration.rb +0 -26
  39. data/lib/data_migrate/migration_five.rb +0 -26
  40. data/screenshot.png +0 -0
  41. data/spec/data_migrate/data_migrator_spec.rb +0 -45
  42. data/spec/data_migrate/data_schema_migration_spec.rb +0 -16
  43. data/spec/data_migrate/migration.rb +0 -19
  44. data/spec/generators/data_migration/data_migration_generator_spec.rb +0 -27
  45. data/spec/spec_helper.rb +0 -5
  46. data/tasks/.gitkeep +0 -0
data/Appraisals DELETED
@@ -1,21 +0,0 @@
1
- appraise 'rails-4.0' do
2
- gem 'rails', '4.0.13'
3
- end
4
-
5
- appraise 'rails-4.1' do
6
- gem 'rails', '4.1.16'
7
- end
8
-
9
- appraise 'rails-4.2' do
10
- gem 'rails', '4.2.8'
11
- # Nokogiri 1.7+ requires Ruby 2.1+
12
- gem 'nokogiri', '1.6.8.1'
13
- end
14
-
15
- appraise 'rails-5.0' do
16
- gem 'rails', '5.0.3'
17
- end
18
-
19
- appraise 'rails-5.1' do
20
- gem 'rails', '5.1'
21
- end
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source "http://rubygems.org"
2
-
3
- # Specify your gem's dependencies in data_migrate.gemspec
4
- gemspec
data/Gemfile.rails5 DELETED
@@ -1,5 +0,0 @@
1
- source "http://rubygems.org"
2
-
3
- # Specify your gem's dependencies in data_migrate.gemspec
4
- gemspec
5
- gem 'rails', '~> 5.0.0'
data/Gemfile.rails5.1 DELETED
@@ -1,5 +0,0 @@
1
- source "http://rubygems.org"
2
-
3
- # Specify your gem's dependencies in data_migrate.gemspec
4
- gemspec
5
- gem 'rails', '~> 5.1'
data/Rakefile DELETED
@@ -1,2 +0,0 @@
1
- require 'bundler'
2
- Bundler::GemHelper.install_tasks
data/data_migrate.gemspec DELETED
@@ -1,39 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
- require "data_migrate/version"
4
-
5
- Gem::Specification.new do |s|
6
- s.name = "data_migrate"
7
- s.version = DataMigrate::VERSION
8
- s.platform = Gem::Platform::RUBY
9
- s.authors = ["Andrew J Vargo", "Ilya Katz"]
10
- s.email = ["ajvargo@computer.org", "ilyakatz@gmail.com"]
11
- s.homepage = "https://github.com/ilyakatz/data-migrate"
12
- s.summary = %q{Rake tasks to migrate data alongside schema changes.}
13
- s.description = %q{Rake tasks to migrate data alongside schema changes.}
14
- s.license = "MIT"
15
-
16
- s.rubyforge_project = "data_migrate"
17
-
18
- s.add_dependency('rails', '>= 4.0')
19
- s.add_development_dependency "appraisal"
20
- s.add_development_dependency "rake"
21
- s.add_development_dependency "rspec"
22
- s.add_development_dependency "rspec-core"
23
- s.add_development_dependency "pry"
24
- s.add_development_dependency "rb-readline"
25
- s.add_development_dependency "sqlite3"
26
- s.add_development_dependency "timecop"
27
-
28
-
29
- s.files = `git ls-files`.split("\n")
30
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
31
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
32
- s.require_paths = ["lib"]
33
-
34
- s.post_install_message = <<-POST_INSTALL_MESSAGE
35
- #{"*" * 80}
36
- data-migrate: --skip-schema-migration option is no longer available as of version 3.0.0
37
- #{"*" * 80}
38
- POST_INSTALL_MESSAGE
39
- end
@@ -1,7 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "http://rubygems.org"
4
-
5
- gem "rails", "4.0.13"
6
-
7
- gemspec path: "../"
@@ -1,7 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "http://rubygems.org"
4
-
5
- gem "rails", "4.1.16"
6
-
7
- gemspec path: "../"
@@ -1,8 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "http://rubygems.org"
4
-
5
- gem "rails", "4.2.8"
6
- gem "nokogiri", "1.6.8.1"
7
-
8
- gemspec path: "../"
@@ -1,7 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "http://rubygems.org"
4
-
5
- gem "rails", "5.0.3"
6
-
7
- gemspec path: "../"
@@ -1,7 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "http://rubygems.org"
4
-
5
- gem "rails", "5.1"
6
-
7
- gemspec path: "../"
@@ -1,26 +0,0 @@
1
- module DataMigrate
2
- class Migration < ::ActiveRecord::Migration
3
-
4
- class << self
5
- def check_pending!(connection = ::ActiveRecord::Base.connection)
6
- raise ActiveRecord::PendingMigrationError if DataMigrator::Migrator.needs_migration?(connection)
7
- end
8
-
9
- def migrate(direction)
10
- new.migrate direction
11
- end
12
-
13
- def table_name
14
- ActiveRecord::Base.table_name_prefix + 'data_migrations' + ActiveRecord::Base.table_name_suffix
15
- end
16
-
17
- def index_name
18
- "#{table_name_prefix}unique_data_migrations#{table_name_suffix}"
19
- end
20
- end
21
-
22
- def initialize(name = self.class.name, version = nil)
23
- super(name, version)
24
- end
25
- end
26
- end
@@ -1,26 +0,0 @@
1
- module DataMigrate
2
- class MigrationFive < ::ActiveRecord::Migration[5.0]
3
-
4
- class << self
5
- def check_pending!(connection = ::ActiveRecord::Base.connection)
6
- raise ActiveRecord::PendingMigrationError if DataMigrator::Migrator.needs_migration?(connection)
7
- end
8
-
9
- def migrate(direction)
10
- new.migrate direction
11
- end
12
-
13
- def table_name
14
- ActiveRecord::Base.table_name_prefix + 'data_migrations' + ActiveRecord::Base.table_name_suffix
15
- end
16
-
17
- def index_name
18
- "#{table_name_prefix}unique_data_migrations#{table_name_suffix}"
19
- end
20
- end
21
-
22
- def initialize(name = self.class.name, version = nil)
23
- super(name, version)
24
- end
25
- end
26
- end
data/screenshot.png DELETED
Binary file
@@ -1,45 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe DataMigrate::DataMigrator do
4
- let(:subject) { DataMigrate::DataMigrator }
5
- let(:db_config) {
6
- {
7
- adapter: "sqlite3",
8
- database: "spec/db/test.db"
9
- }
10
- }
11
-
12
- describe :assure_data_schema_table do
13
- before do
14
- expect(subject).to receive(:db_config) { db_config }.at_least(:once)
15
- ActiveRecord::Base.establish_connection(db_config)
16
- end
17
-
18
- after do
19
- ActiveRecord::Migration.drop_table("data_migrations")
20
- end
21
-
22
- it do
23
- expect(
24
- ActiveRecord::Base.connection.table_exists?("data_migrations")
25
- ).to eq false
26
- subject.assure_data_schema_table
27
- expect(
28
- ActiveRecord::Base.connection.table_exists?("data_migrations")
29
- ).to eq true
30
- end
31
- end
32
-
33
- describe :schema_migrations_table_name do
34
- it "returns correct table name" do
35
- expect(subject.schema_migrations_table_name).to eq("data_migrations")
36
- end
37
- end
38
-
39
- describe :migrations_path do
40
- it "returns correct migrations path" do
41
- expect(subject.migrations_path).to eq("db/data")
42
- end
43
- end
44
-
45
- end
@@ -1,16 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe DataMigrate::DataSchemaMigration do
4
- let(:subject) { DataMigrate::DataSchemaMigration }
5
- describe :table_name do
6
- it "returns correct table name" do
7
- expect(subject.table_name).to eq("data_migrations")
8
- end
9
- end
10
-
11
- describe :index_name do
12
- it "returns correct index name" do
13
- expect(subject.index_name).to eq("unique_data_migrations")
14
- end
15
- end
16
- end
@@ -1,19 +0,0 @@
1
- require 'spec_helper'
2
-
3
- if Rails::VERSION::MAJOR >= 5
4
- subject = DataMigrate::MigrationFive
5
- else
6
- subject = DataMigrate::Migration
7
- end
8
-
9
- describe subject do
10
- it "uses correct table name" do
11
- expect(subject.table_name).to eq("data_migrations")
12
- end
13
-
14
- it "uses correct index name" do
15
- expect(subject).to receive(:table_name_prefix) { "" }
16
- expect(subject).to receive(:table_name_suffix) { "" }
17
- expect(subject.index_name).to eq("unique_data_migrations")
18
- end
19
- end
@@ -1,27 +0,0 @@
1
- require 'spec_helper'
2
- require 'rails/generators'
3
- require 'rails/generators/migration'
4
- require 'generators/data_migration/data_migration_generator'
5
-
6
- describe DataMigrate::Generators::DataMigrationGenerator do
7
- let(:subject) { DataMigrate::Generators::DataMigrationGenerator }
8
- describe :next_migration_number do
9
- it "next migration" do
10
- Timecop.freeze("2016-12-03 22:15:26 -0800") do
11
- expect(ActiveRecord::Base).to receive(:timestamped_migrations) { true }
12
- expect(subject.next_migration_number(1)).to eq("20161204061526")
13
- end
14
- end
15
- end
16
-
17
- describe :migration_base_class_name do
18
- let(:subject) { DataMigrate::Generators::DataMigrationGenerator.new(['my_migration']) }
19
- it "returns the correct base class name" do
20
- if ActiveRecord.version >= Gem::Version.new('5.0')
21
- expect(subject.send(:migration_base_class_name)).to eq("ActiveRecord::Migration[#{ActiveRecord::Migration.current_version}]")
22
- else
23
- expect(subject.send(:migration_base_class_name)).to eq('ActiveRecord::Migration')
24
- end
25
- end
26
- end
27
- end
data/spec/spec_helper.rb DELETED
@@ -1,5 +0,0 @@
1
- require 'rspec'
2
- require 'rails'
3
- require 'data_migrate'
4
- require 'pry'
5
- require 'timecop'
data/tasks/.gitkeep DELETED
File without changes