data_migrate 8.4.2 → 9.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/build.yml +35 -0
- data/.github/workflows/gempush.yml +1 -1
- data/.travis.yml +3 -0
- data/Changelog.md +9 -0
- data/README.md +1 -0
- data/data_migrate.gemspec +1 -10
- data/lib/data_migrate/config.rb +10 -1
- data/lib/data_migrate/version.rb +1 -1
- data/lib/data_migrate.rb +3 -0
- data/lib/generators/data_migrate.rb +15 -2
- data/lib/generators/data_migration/data_migration_generator.rb +5 -1
- data/spec/data_migrate/config_spec.rb +42 -3
- data/spec/generators/data_migration/data_migration_generator_spec.rb +47 -6
- metadata +8 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2acff14ddfe78e35e593865b31aaa8f5964c7bc958b7f40f7019333288efaa4e
|
4
|
+
data.tar.gz: 3098c184b2bb1ba2f2ed75181c31938800c0c0313431b6b1749ff4b103ee0f33
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba3d909404e128ddb3f7319c83301a7f7395e13226e47c2c35f858535e32d15dd25bb89b475841edf013643407b29a56ebe0eb89f86d1f2f14c66178d868894f
|
7
|
+
data.tar.gz: 7039baeee12e08f77f7cfa680b1841a9137291aa8c3e7c299fe779d8343182a7f851e582b9614d8674add0df9727d38d2918ae726f17a888cd07d4bb556d0360
|
@@ -0,0 +1,35 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on:
|
4
|
+
- push
|
5
|
+
- pull_request
|
6
|
+
|
7
|
+
jobs:
|
8
|
+
test:
|
9
|
+
strategy:
|
10
|
+
fail-fast: false
|
11
|
+
matrix:
|
12
|
+
os: [ "ubuntu-20.04" ]
|
13
|
+
ruby:
|
14
|
+
- '2.7'
|
15
|
+
- '3.0'
|
16
|
+
- '3.1'
|
17
|
+
- '3.2'
|
18
|
+
gemfile:
|
19
|
+
- gemfiles/rails_6.0.gemfile
|
20
|
+
- gemfiles/rails_6.1.gemfile
|
21
|
+
- gemfiles/rails_7.0.gemfile
|
22
|
+
runs-on: ubuntu-latest
|
23
|
+
env:
|
24
|
+
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
|
25
|
+
RAILS_ENV: test
|
26
|
+
steps:
|
27
|
+
- name: Checkout code
|
28
|
+
uses: actions/checkout@v3
|
29
|
+
- name: Set up Ruby
|
30
|
+
uses: ruby/setup-ruby@v1
|
31
|
+
with:
|
32
|
+
ruby-version: ${{ matrix.ruby }}
|
33
|
+
bundler-cache: true
|
34
|
+
- name: Run tests
|
35
|
+
run: bundle exec rspec
|
data/.travis.yml
CHANGED
@@ -2,6 +2,7 @@ language: ruby
|
|
2
2
|
rvm:
|
3
3
|
- 2.7
|
4
4
|
- 3.0
|
5
|
+
- 3.2
|
5
6
|
script: bundle exec rspec
|
6
7
|
gemfile:
|
7
8
|
- gemfiles/rails_5.2.gemfile
|
@@ -12,3 +13,5 @@ jobs:
|
|
12
13
|
exclude:
|
13
14
|
- rvm: 3.0
|
14
15
|
gemfile: gemfiles/rails_5.2.gemfile
|
16
|
+
- rvm: 3.2
|
17
|
+
gemfile: gemfiles/rails_5.2.gemfile
|
data/Changelog.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 9.0.0
|
4
|
+
|
5
|
+
Ruby 3.2 support [mehanoid](https://github.com/mehanoid)
|
6
|
+
Rails 5.2 is no longer supported
|
7
|
+
|
8
|
+
## 8.5.0
|
9
|
+
|
10
|
+
Allow custom templates [bazay](https://github.com/bazay)
|
11
|
+
|
3
12
|
## 8.4.0
|
4
13
|
|
5
14
|
Avoid Globally Accessible Functions for All Rake Tasks [berniechiu](https://github.com/berniechiu)
|
data/README.md
CHANGED
@@ -108,6 +108,7 @@ You can override this setting in `config/initializers/data_migrate.rb`
|
|
108
108
|
```ruby
|
109
109
|
DataMigrate.configure do |config|
|
110
110
|
config.data_migrations_path = 'db/awesomepath/'
|
111
|
+
config.data_template_path = Rails.root.join("lib", "awesomepath", "custom_data_migration.rb")
|
111
112
|
config.db_configuration = {
|
112
113
|
'host' => '127.0.0.1',
|
113
114
|
'database' => 'awesome_database',
|
data/data_migrate.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
|
|
19
19
|
activerecord
|
20
20
|
railties
|
21
21
|
].each do |rails_gem|
|
22
|
-
s.add_dependency(rails_gem, '>=
|
22
|
+
s.add_dependency(rails_gem, '>= 6.0')
|
23
23
|
end
|
24
24
|
|
25
25
|
s.add_development_dependency "appraisal"
|
@@ -38,13 +38,4 @@ Gem::Specification.new do |s|
|
|
38
38
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
39
39
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
40
40
|
s.require_paths = ["lib"]
|
41
|
-
|
42
|
-
s.post_install_message = <<-POST_INSTALL_MESSAGE
|
43
|
-
#{"*" * 80}
|
44
|
-
data-migrate: IMPORTANT: Breaking change introduced for migrations from v2.
|
45
|
-
|
46
|
-
Failure to run the migration can have serious consequences.
|
47
|
-
See Readme for more info.
|
48
|
-
#{"*" * 80}
|
49
|
-
POST_INSTALL_MESSAGE
|
50
41
|
end
|
data/lib/data_migrate/config.rb
CHANGED
@@ -12,12 +12,21 @@ module DataMigrate
|
|
12
12
|
end
|
13
13
|
|
14
14
|
class Config
|
15
|
-
attr_accessor :data_migrations_path, :db_configuration, :spec_name
|
15
|
+
attr_accessor :data_migrations_path, :data_template_path, :db_configuration, :spec_name
|
16
|
+
|
17
|
+
DEFAULT_DATA_TEMPLATE_PATH = "data_migration.rb"
|
16
18
|
|
17
19
|
def initialize
|
18
20
|
@data_migrations_path = "db/data/"
|
21
|
+
@data_template_path = DEFAULT_DATA_TEMPLATE_PATH
|
19
22
|
@db_configuration = nil
|
20
23
|
@spec_name = nil
|
21
24
|
end
|
25
|
+
|
26
|
+
def data_template_path=(value)
|
27
|
+
@data_template_path = value.tap do |path|
|
28
|
+
raise ArgumentError, "File not found: '#{path}'" unless path == DEFAULT_DATA_TEMPLATE_PATH || File.exist?(path)
|
29
|
+
end
|
30
|
+
end
|
22
31
|
end
|
23
32
|
end
|
data/lib/data_migrate/version.rb
CHANGED
data/lib/data_migrate.rb
CHANGED
@@ -1,9 +1,22 @@
|
|
1
1
|
require 'rails/generators/named_base'
|
2
|
+
|
2
3
|
module DataMigrate
|
3
4
|
module Generators
|
4
5
|
class DataMigrationGenerator < Rails::Generators::NamedBase #:nodoc:
|
5
|
-
|
6
|
-
|
6
|
+
class << self
|
7
|
+
def source_root
|
8
|
+
build_data_migrate_source_root
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def build_data_migrate_source_root
|
14
|
+
if DataMigrate.config.data_template_path == DataMigrate::Config::DEFAULT_DATA_TEMPLATE_PATH
|
15
|
+
File.expand_path(File.join(File.dirname(__FILE__), generator_name, 'templates'))
|
16
|
+
else
|
17
|
+
File.expand_path(File.dirname(DataMigrate.config.data_template_path))
|
18
|
+
end
|
19
|
+
end
|
7
20
|
end
|
8
21
|
end
|
9
22
|
end
|
@@ -14,7 +14,7 @@ module DataMigrate
|
|
14
14
|
|
15
15
|
def create_data_migration
|
16
16
|
set_local_assigns!
|
17
|
-
migration_template
|
17
|
+
migration_template template_path, data_migrations_file_path
|
18
18
|
end
|
19
19
|
|
20
20
|
protected
|
@@ -26,6 +26,10 @@ module DataMigrate
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
+
def template_path
|
30
|
+
DataMigrate.config.data_template_path
|
31
|
+
end
|
32
|
+
|
29
33
|
def migration_base_class_name
|
30
34
|
"ActiveRecord::Migration[#{ActiveRecord::Migration.current_version}]"
|
31
35
|
end
|
@@ -1,12 +1,16 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe DataMigrate::Config do
|
4
|
-
|
5
4
|
it "sets default data_migrations_path path", :no_override do
|
6
5
|
expect(DataMigrate.config.data_migrations_path).to eq "db/data/"
|
7
6
|
end
|
8
7
|
|
8
|
+
it "sets default data_template_path path", :no_override do
|
9
|
+
expect(DataMigrate.config.data_template_path).to eq DataMigrate::Config::DEFAULT_DATA_TEMPLATE_PATH
|
10
|
+
end
|
11
|
+
|
9
12
|
describe "data migration path configured" do
|
13
|
+
subject { DataMigrate.config.data_migrations_path }
|
10
14
|
before do
|
11
15
|
@before = DataMigrate.config.data_migrations_path
|
12
16
|
DataMigrate.configure do |config|
|
@@ -20,8 +24,43 @@ describe DataMigrate::Config do
|
|
20
24
|
end
|
21
25
|
end
|
22
26
|
|
23
|
-
it do
|
24
|
-
|
27
|
+
it "equals the custom data migration path" do
|
28
|
+
is_expected.to eq "db/awesome/"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "data template path configured" do
|
33
|
+
subject { DataMigrate.config.data_template_path }
|
34
|
+
|
35
|
+
before do
|
36
|
+
@before = DataMigrate.config.data_template_path
|
37
|
+
DataMigrate.configure do |config|
|
38
|
+
config.data_template_path = data_template_path
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
let(:data_template_path) do
|
43
|
+
File.join(DataMigrate.root, "generators", "data_migration", "templates", "data_migration.rb")
|
44
|
+
end
|
45
|
+
|
46
|
+
after do
|
47
|
+
DataMigrate.configure do |config|
|
48
|
+
config.data_template_path = @before
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
it "equals the custom data template path" do
|
53
|
+
is_expected.to eq data_template_path
|
54
|
+
end
|
55
|
+
|
56
|
+
context "when path does not exist" do
|
57
|
+
subject { DataMigrate.config.data_template_path = invalid_path }
|
58
|
+
|
59
|
+
let(:invalid_path) { "lib/awesome/templates/data_migration.rb" }
|
60
|
+
|
61
|
+
it "checks that file exists on setting config var" do
|
62
|
+
expect { subject }.to raise_error { ArgumentError.new("File not found: '#{data_template_path}'") }
|
63
|
+
end
|
25
64
|
end
|
26
65
|
end
|
27
66
|
end
|
@@ -4,7 +4,8 @@ require 'rails/generators/migration'
|
|
4
4
|
require 'generators/data_migration/data_migration_generator'
|
5
5
|
|
6
6
|
describe DataMigrate::Generators::DataMigrationGenerator do
|
7
|
-
|
7
|
+
subject { DataMigrate::Generators::DataMigrationGenerator }
|
8
|
+
|
8
9
|
describe :next_migration_number do
|
9
10
|
it "next migration" do
|
10
11
|
Timecop.freeze("2016-12-03 22:15:26 -0800") do
|
@@ -19,14 +20,18 @@ describe DataMigrate::Generators::DataMigrationGenerator do
|
|
19
20
|
end
|
20
21
|
|
21
22
|
describe :migration_base_class_name do
|
22
|
-
|
23
|
+
subject { generator.send(:migration_base_class_name) }
|
24
|
+
|
25
|
+
let(:generator) { DataMigrate::Generators::DataMigrationGenerator.new(['my_migration']) }
|
26
|
+
|
23
27
|
it "returns the correct base class name" do
|
24
|
-
|
28
|
+
is_expected.to eq("ActiveRecord::Migration[#{ActiveRecord::Migration.current_version}]")
|
25
29
|
end
|
26
30
|
end
|
27
31
|
|
28
32
|
describe :create_data_migration do
|
29
|
-
|
33
|
+
subject { DataMigrate::Generators::DataMigrationGenerator.new(['my_migration']) }
|
34
|
+
|
30
35
|
let(:data_migrations_file_path) { 'abc/my_migration.rb' }
|
31
36
|
|
32
37
|
context 'when custom data migrations path has a trailing slash' do
|
@@ -35,7 +40,7 @@ describe DataMigrate::Generators::DataMigrationGenerator do
|
|
35
40
|
end
|
36
41
|
|
37
42
|
it 'returns correct file path' do
|
38
|
-
|
43
|
+
is_expected.to receive(:migration_template).with(
|
39
44
|
'data_migration.rb', data_migrations_file_path
|
40
45
|
)
|
41
46
|
|
@@ -49,7 +54,7 @@ describe DataMigrate::Generators::DataMigrationGenerator do
|
|
49
54
|
end
|
50
55
|
|
51
56
|
it 'returns correct file path' do
|
52
|
-
|
57
|
+
is_expected.to receive(:migration_template).with(
|
53
58
|
'data_migration.rb', data_migrations_file_path
|
54
59
|
)
|
55
60
|
|
@@ -57,4 +62,40 @@ describe DataMigrate::Generators::DataMigrationGenerator do
|
|
57
62
|
end
|
58
63
|
end
|
59
64
|
end
|
65
|
+
|
66
|
+
describe ".source_root" do
|
67
|
+
subject { described_class.source_root }
|
68
|
+
|
69
|
+
let(:default_source_root) do
|
70
|
+
File.expand_path(
|
71
|
+
File.dirname(File.join(DataMigrate.root, "generators", "data_migration", "templates", "data_migration.rb"))
|
72
|
+
)
|
73
|
+
end
|
74
|
+
|
75
|
+
it { is_expected.to eq default_source_root }
|
76
|
+
|
77
|
+
context "when DateMigrate.config.data_template_path is set" do
|
78
|
+
before do
|
79
|
+
@before = DataMigrate.config.data_template_path
|
80
|
+
DataMigrate.configure do |config|
|
81
|
+
config.data_template_path = data_template_path
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
let(:data_template_path) do
|
86
|
+
File.join(DataMigrate.root, "generators", "data_migration", "templates", "data_migration.rb")
|
87
|
+
end
|
88
|
+
let(:expected_source_root) { File.dirname(data_template_path) }
|
89
|
+
|
90
|
+
after do
|
91
|
+
DataMigrate.configure do |config|
|
92
|
+
config.data_template_path = @before
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
it "reads directory from config data template path" do
|
97
|
+
is_expected.to eq expected_source_root
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
60
101
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: data_migrate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 9.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew J Vargo
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2023-02-21 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|
@@ -18,28 +18,28 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ">="
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: '
|
21
|
+
version: '6.0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
26
|
- - ">="
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
version: '
|
28
|
+
version: '6.0'
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: railties
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
32
32
|
requirements:
|
33
33
|
- - ">="
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version: '
|
35
|
+
version: '6.0'
|
36
36
|
type: :runtime
|
37
37
|
prerelease: false
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
40
|
- - ">="
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: '
|
42
|
+
version: '6.0'
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
44
|
name: appraisal
|
45
45
|
requirement: !ruby/object:Gem::Requirement
|
@@ -189,6 +189,7 @@ executables: []
|
|
189
189
|
extensions: []
|
190
190
|
extra_rdoc_files: []
|
191
191
|
files:
|
192
|
+
- ".github/workflows/build.yml"
|
192
193
|
- ".github/workflows/gempush.yml"
|
193
194
|
- ".gitignore"
|
194
195
|
- ".hound.yml"
|
@@ -270,13 +271,7 @@ homepage: https://github.com/ilyakatz/data-migrate
|
|
270
271
|
licenses:
|
271
272
|
- MIT
|
272
273
|
metadata: {}
|
273
|
-
post_install_message:
|
274
|
-
********************************************************************************
|
275
|
-
data-migrate: IMPORTANT: Breaking change introduced for migrations from v2.
|
276
|
-
|
277
|
-
Failure to run the migration can have serious consequences.
|
278
|
-
See Readme for more info.
|
279
|
-
********************************************************************************
|
274
|
+
post_install_message:
|
280
275
|
rdoc_options: []
|
281
276
|
require_paths:
|
282
277
|
- lib
|