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.
- checksums.yaml +5 -5
- data/Changelog.md +246 -2
- data/README.md +107 -91
- data/lib/capistrano/data_migrate/migrate.rb +3 -4
- data/lib/data_migrate/config.rb +33 -0
- data/lib/data_migrate/data_migrator.rb +54 -58
- data/lib/data_migrate/data_schema.rb +63 -0
- data/lib/data_migrate/data_schema_migration.rb +23 -6
- data/lib/data_migrate/database_configurations_wrapper.rb +11 -0
- data/lib/data_migrate/database_tasks.rb +290 -0
- data/lib/data_migrate/migration_context.rb +93 -0
- data/lib/data_migrate/rails_helper.rb +91 -0
- data/lib/data_migrate/schema_dumper.rb +38 -0
- data/lib/data_migrate/schema_migration.rb +41 -0
- data/lib/data_migrate/status_service.rb +58 -0
- data/lib/data_migrate/tasks/data_migrate_tasks.rb +107 -0
- data/lib/data_migrate/version.rb +1 -1
- data/lib/data_migrate.rb +20 -7
- data/lib/generators/data_migrate.rb +15 -2
- data/lib/generators/data_migration/data_migration_generator.rb +22 -21
- data/lib/generators/data_migration/templates/data_migration.rb +4 -2
- data/tasks/databases.rake +115 -228
- metadata +64 -42
- data/.gitignore +0 -6
- data/.rspec +0 -3
- data/.travis.yml +0 -17
- data/Appraisals +0 -21
- data/Gemfile +0 -4
- data/Gemfile.rails5 +0 -5
- data/Gemfile.rails5.1 +0 -5
- data/Rakefile +0 -2
- data/data_migrate.gemspec +0 -39
- data/gemfiles/rails_4.0.gemfile +0 -7
- data/gemfiles/rails_4.1.gemfile +0 -7
- data/gemfiles/rails_4.2.gemfile +0 -8
- data/gemfiles/rails_5.0.gemfile +0 -7
- data/gemfiles/rails_5.1.gemfile +0 -7
- data/lib/data_migrate/migration.rb +0 -26
- data/lib/data_migrate/migration_five.rb +0 -26
- data/screenshot.png +0 -0
- data/spec/data_migrate/data_migrator_spec.rb +0 -45
- data/spec/data_migrate/data_schema_migration_spec.rb +0 -16
- data/spec/data_migrate/migration.rb +0 -19
- data/spec/generators/data_migration/data_migration_generator_spec.rb +0 -27
- data/spec/spec_helper.rb +0 -5
- 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
data/Gemfile.rails5
DELETED
data/Gemfile.rails5.1
DELETED
data/Rakefile
DELETED
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
|
data/gemfiles/rails_4.0.gemfile
DELETED
data/gemfiles/rails_4.1.gemfile
DELETED
data/gemfiles/rails_4.2.gemfile
DELETED
data/gemfiles/rails_5.0.gemfile
DELETED
data/gemfiles/rails_5.1.gemfile
DELETED
@@ -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
data/tasks/.gitkeep
DELETED
File without changes
|