data_migrate 10.0.0.rc1 → 10.0.3.rc
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -1
- data/Changelog.md +23 -0
- data/README.md +6 -4
- data/lib/data_migrate/schema_migration.rb +2 -2
- data/lib/data_migrate/status_service.rb +2 -2
- data/lib/data_migrate/tasks/data_migrate_tasks.rb +2 -2
- data/lib/data_migrate/version.rb +1 -1
- data/spec/data_migrate/database_tasks_spec.rb +1 -1
- data/spec/data_migrate/schema_migration_spec.rb +2 -2
- data/spec/data_migrate/status_service_spec.rb +1 -1
- data/spec/data_migrate/tasks/data_migrate_tasks_spec.rb +1 -1
- data/tasks/databases.rake +12 -2
- metadata +2 -4
- data/.ruby-version +0 -1
- data/.travis.yml +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2bb05d428228b17b10beb94404770d5290cbb9727b7185356f3833dc440a40e6
|
4
|
+
data.tar.gz: e1a996f14dce42f3743db8bc74a128893b97a41cc97c63db1202db1733b1349e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 005deffc4ecd6a9f02ca76c84f2fbd8ad70f4e294e6d4259d92f2e2ce1f54f1a5032767ec2a0759af762571ff99fe1f7e290d9d3ec414ba69ebc2b7b673a2c65
|
7
|
+
data.tar.gz: a4db456966db55f1b3428a239a76dd00ba352417a796957474b20cd163918fe48f79096cad7d513d9d1bd180465bbde2969c39a182c38c08afde64705d23880d
|
data/.gitignore
CHANGED
data/Changelog.md
CHANGED
@@ -1,5 +1,28 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 10.0.3.rc
|
4
|
+
|
5
|
+
- Remove all travis references [leoarnold](https//:github.com/leoarnold)
|
6
|
+
- Changing to rc because of ongoing discussion how to properly handle multiple database environments
|
7
|
+
|
8
|
+
## 10.0.2
|
9
|
+
|
10
|
+
Change "rails" dependencies to "railties"
|
11
|
+
|
12
|
+
## 10.0.1
|
13
|
+
|
14
|
+
- Bug fix for Rails 6 config [chaunce](https//:github.com/chaunce)
|
15
|
+
- Railties bug fix by [opti](https://github.com/opti)
|
16
|
+
|
17
|
+
## 10.0.0
|
18
|
+
|
19
|
+
Releasing 10.0.0
|
20
|
+
|
21
|
+
!!! Breaking changes !!!
|
22
|
+
|
23
|
+
- This version introduces a breaking change which may lead to undesired
|
24
|
+
behavior in multi-database environments. See https://github.com/ilyakatz/data-migrate/issues/181
|
25
|
+
|
3
26
|
## 10.0.0.rc1
|
4
27
|
|
5
28
|
- Changes by [chaunce](https//:github.com/chaunce)
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
- [![Version](http://img.shields.io/gem/v/data_migrate.svg?style=flat-square)](https://rubygems.org/gems/data_migrate)
|
4
4
|
- [![License](http://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](http://opensource.org/licenses/MIT)
|
5
|
-
-
|
5
|
+
- ![.github/workflows/build.yml](https://github.com/ilyakatz/data-migrate/actions/workflows/.github/workflows/build.yml/badge.svg)
|
6
6
|
- [![Reviewed by Hound](https://img.shields.io/badge/Reviewed_by-Hound-8E64B0.svg)](https://houndci.com)
|
7
7
|
|
8
8
|
Run data migrations alongside schema migrations.
|
@@ -12,7 +12,7 @@ migrations, except they should be reserved for data migrations. For
|
|
12
12
|
instance, if you realize you need to titleize all your titles, this
|
13
13
|
is the place to do it.
|
14
14
|
|
15
|
-
![
|
15
|
+
![directory tree example](./screenshot.png)
|
16
16
|
|
17
17
|
## Why should I use this?
|
18
18
|
|
@@ -92,11 +92,13 @@ You can generate a data migration as you would a schema migration:
|
|
92
92
|
rake db:version:with_data # Retrieves the current schema version numbers for data and schema migrations
|
93
93
|
|
94
94
|
|
95
|
-
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.
|
95
|
+
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.
|
96
96
|
|
97
97
|
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.
|
98
98
|
|
99
|
-
`rake db:migrate:
|
99
|
+
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.
|
100
|
+
|
101
|
+
`rake db:migrate:status:with_data` provides an additional column to indicate which type of migration.
|
100
102
|
|
101
103
|
### Configuration
|
102
104
|
|
@@ -24,9 +24,9 @@ module DataMigrate
|
|
24
24
|
|
25
25
|
def self.migrations_paths
|
26
26
|
spec_name = DataMigrate.config.spec_name
|
27
|
-
if spec_name && Gem::Dependency.new("
|
27
|
+
if spec_name && Gem::Dependency.new("railties", "~> 7.0").match?("railties", Gem.loaded_specs["railties"].version)
|
28
28
|
ActiveRecord::Base.configurations.configs_for(env_name: Rails.env, name: spec_name).migrations_paths
|
29
|
-
elsif spec_name && Gem::Dependency.new("
|
29
|
+
elsif spec_name && Gem::Dependency.new("railties", "~> 6.0").match?("railties", Gem.loaded_specs["railties"].version)
|
30
30
|
ActiveRecord::Base.configurations.configs_for(env_name: Rails.env, spec_name: spec_name).migrations_paths
|
31
31
|
else
|
32
32
|
Rails.application.config.paths["db/migrate"].to_a
|
@@ -44,9 +44,9 @@ module DataMigrate
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def database_name
|
47
|
-
if Gem::Dependency.new("
|
47
|
+
if Gem::Dependency.new("railties", "~> 7.0").match?("railties", Gem.loaded_specs["railties"].version)
|
48
48
|
ActiveRecord::Base.connection_db_config.configuration_hash[:database]
|
49
|
-
elsif Gem::Dependency.new("
|
49
|
+
elsif Gem::Dependency.new("railties", "~> 6.0").match?("railties", Gem.loaded_specs["railties"].version)
|
50
50
|
ActiveRecord::Base.connection_config[:database]
|
51
51
|
end
|
52
52
|
end
|
@@ -95,9 +95,9 @@ module DataMigrate
|
|
95
95
|
private
|
96
96
|
|
97
97
|
def spec_name(db_config)
|
98
|
-
if Gem::Dependency.new("
|
98
|
+
if Gem::Dependency.new("railties", "~> 7.0").match?("railties", Gem.loaded_specs["railties"].version)
|
99
99
|
db_config.name
|
100
|
-
elsif Gem::Dependency.new("
|
100
|
+
elsif Gem::Dependency.new("railties", "~> 6.0").match?("railties", Gem.loaded_specs["railties"].version)
|
101
101
|
db_config.spec_name
|
102
102
|
end
|
103
103
|
end
|
data/lib/data_migrate/version.rb
CHANGED
@@ -28,7 +28,7 @@ describe DataMigrate::DatabaseTasks do
|
|
28
28
|
data_migrations_path
|
29
29
|
}
|
30
30
|
ActiveRecord::Base.establish_connection(db_config)
|
31
|
-
if Gem::Dependency.new("
|
31
|
+
if Gem::Dependency.new("railties", ">= 6.1").match?("railties", Gem.loaded_specs["railties"].version)
|
32
32
|
hash_config = ActiveRecord::DatabaseConfigurations::HashConfig.new('test', 'test', db_config)
|
33
33
|
config_obj = ActiveRecord::DatabaseConfigurations.new([hash_config])
|
34
34
|
allow(ActiveRecord::Base).to receive(:configurations).and_return(config_obj)
|
@@ -61,9 +61,9 @@ describe DataMigrate::SchemaMigration do
|
|
61
61
|
let(:paths) { ['spec/db/migrate', 'spec/db/migrate/other'] }
|
62
62
|
let(:specification_name) { "primary" }
|
63
63
|
let(:config_options) do
|
64
|
-
if Gem::Dependency.new("
|
64
|
+
if Gem::Dependency.new("railties", "~> 6.0").match?("railties", Gem.loaded_specs["railties"].version)
|
65
65
|
{ env_name: Rails.env, spec_name: specification_name }
|
66
|
-
elsif Gem::Dependency.new("
|
66
|
+
elsif Gem::Dependency.new("railties", "~> 7.0").match?("railties", Gem.loaded_specs["railties"].version)
|
67
67
|
{ env_name: Rails.env, name: specification_name }
|
68
68
|
end
|
69
69
|
end
|
@@ -7,7 +7,7 @@ describe DataMigrate::StatusService do
|
|
7
7
|
let(:stream) { StringIO.new }
|
8
8
|
let(:stream_data) { stream.read }
|
9
9
|
let(:connection_db_config) do
|
10
|
-
if Gem::Dependency.new("
|
10
|
+
if Gem::Dependency.new("railties", ">= 6.1").match?("railties", Gem.loaded_specs["railties"].version)
|
11
11
|
ActiveRecord::Base.connection_db_config
|
12
12
|
else
|
13
13
|
ActiveRecord::Base.configurations.configs_for.first
|
@@ -4,7 +4,7 @@ require "spec_helper"
|
|
4
4
|
|
5
5
|
describe DataMigrate::Tasks::DataMigrateTasks do
|
6
6
|
let(:connection_db_config) do
|
7
|
-
if Gem::Dependency.new("
|
7
|
+
if Gem::Dependency.new("railties", ">= 6.1").match?("railties", Gem.loaded_specs["railties"].version)
|
8
8
|
ActiveRecord::Base.connection_db_config
|
9
9
|
else
|
10
10
|
ActiveRecord::Base.configurations.configs_for.first
|
data/tasks/databases.rake
CHANGED
@@ -6,7 +6,12 @@ namespace :db do
|
|
6
6
|
namespace :migrate do
|
7
7
|
desc "Migrate the database data and schema (options: VERSION=x, VERBOSE=false)."
|
8
8
|
task :with_data => :environment do
|
9
|
-
original_db_config =
|
9
|
+
original_db_config = if Gem::Dependency.new("railties", "~> 7.0").match?("railties", Gem.loaded_specs["railties"].version)
|
10
|
+
ActiveRecord::Base.connection_db_config
|
11
|
+
elsif Gem::Dependency.new("railties", "~> 6.0").match?("railties", Gem.loaded_specs["railties"].version)
|
12
|
+
ActiveRecord::Base.connection_config
|
13
|
+
end
|
14
|
+
|
10
15
|
ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env).each do |db_config|
|
11
16
|
ActiveRecord::Base.establish_connection(db_config)
|
12
17
|
DataMigrate::DataMigrator.assure_data_schema_table
|
@@ -204,7 +209,12 @@ end
|
|
204
209
|
namespace :data do
|
205
210
|
desc 'Migrate data migrations (options: VERSION=x, VERBOSE=false)'
|
206
211
|
task :migrate => :environment do
|
207
|
-
original_db_config =
|
212
|
+
original_db_config = if Gem::Dependency.new("railties", "~> 7.0").match?("railties", Gem.loaded_specs["railties"].version)
|
213
|
+
ActiveRecord::Base.connection_db_config
|
214
|
+
elsif Gem::Dependency.new("railties", "~> 6.0").match?("railties", Gem.loaded_specs["railties"].version)
|
215
|
+
ActiveRecord::Base.connection_config
|
216
|
+
end
|
217
|
+
|
208
218
|
ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env).each do |db_config|
|
209
219
|
ActiveRecord::Base.establish_connection(db_config)
|
210
220
|
DataMigrate::Tasks::DataMigrateTasks.migrate
|
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: 10.0.
|
4
|
+
version: 10.0.3.rc
|
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: 2023-
|
13
|
+
date: 2023-06-15 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|
@@ -198,8 +198,6 @@ files:
|
|
198
198
|
- ".rspec"
|
199
199
|
- ".rubocop.yml"
|
200
200
|
- ".ruby-style.yml"
|
201
|
-
- ".ruby-version"
|
202
|
-
- ".travis.yml"
|
203
201
|
- Appraisals
|
204
202
|
- Changelog.md
|
205
203
|
- Gemfile
|
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
2.7.5
|