data_migrate 8.1.1 → 8.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7f6afd16bfaf1425e8e8fa9b7916df46f6b2d826fb572c2adeade0db17ec9e03
4
- data.tar.gz: 80cc32ea79bfb83913ea24c647d8fd1a12fb2956756d33ad9f31eef3ebeca2db
3
+ metadata.gz: fbfb52ef4fcacc01bb90162dd1869dddf02d0f94fcabe7b3df3b6e23b0616bc6
4
+ data.tar.gz: da2ca8153fc78c898839a8309a242b96d84c656d33e28213f7e991118d068ca3
5
5
  SHA512:
6
- metadata.gz: 57a9d5e94a753924506ad0a79896b859e53073f348c222972988510a942dc958e61b3b1e6859b51f31f3374f2d550b82710e7b579509894c33e1e045bd9a0ecc
7
- data.tar.gz: 6ab5ceea16179d7f3e42b6ce9aa0028cd214c907139e3938e503ed21e35ad00c16a5a409dfe6b9032d06f689ce37ea36e14543238d9a76147f2b0dd5b5421700
6
+ metadata.gz: 9a1e6f412e15f2e597ebf7b6272dcc7e66f2aa3faeea4f8ff48e1991667d238bcaa33e1ff12d007fdf58ff7005a380c03f85babc7e39bd4ca205b6f522d091b0
7
+ data.tar.gz: 6555ff6611bc06d9c85b137d301a319b3a5f61974c92b14592b9cede75414ba8d02745808c179bd0dcc2126415ffd2ed2edf9a3d836423e676a51d2a53b4dc83
data/Changelog.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 8.3.0
4
+
5
+ Add delegation to exists? for use by third parties [foxondo](https://github.com/foxondo)
6
+
7
+ ## 8.2.0
8
+
9
+ Delegate to anonymous subclass of AR::SchemaMigration [foxondo](https://github.com/foxondo)
10
+
3
11
  ## 8.1.1
4
12
 
5
13
  Revert 8.1.0 changes
data/README.md CHANGED
@@ -132,6 +132,27 @@ require 'capistrano/data_migrate'
132
132
 
133
133
  From now on capistrano will run `rake db:migrate:with_data` in every deploy.
134
134
 
135
+ ## Rails Engines support
136
+
137
+ This gem also has a initial support for adding data migrations inside Rails engines.
138
+ Inside the Engine's class initializer (the one that inherits from `Rails::Engine`, usually inside `engines/ENGINE_NAME/lib/engine.rb`) you need to add something like this:
139
+
140
+
141
+ ```ruby
142
+ module EngineName
143
+ class Engine < ::Rails::Engine
144
+ initializer :engine_name do |app|
145
+ ::DataMigrate.configure do |data_migrate|
146
+ default_path = ::DataMigrate::Config.new.data_migrations_path
147
+ data_migrate.data_migrations_path = [default_path, root.join('db', 'data')]
148
+ end
149
+ end
150
+ end
151
+ end
152
+ ```
153
+
154
+ Then, in the Engine's `db/data` folder, you can add data migrations and run them as usual.
155
+
135
156
  ### Contributing
136
157
 
137
158
  ## Testing
@@ -1,15 +1,14 @@
1
1
  module DataMigrate
2
- class DataSchemaMigration < ::ActiveRecord::SchemaMigration
3
-
2
+ class DataSchemaMigration
4
3
  class << self
5
- def table_name
6
- ActiveRecord::Base.table_name_prefix + 'data_migrations' + ActiveRecord::Base.table_name_suffix
7
- end
4
+ delegate :table_name, :primary_key, :create_table, :normalized_versions, :create, :create!, :table_exists?, :exists?, :where, to: :instance
8
5
 
9
- def primary_key
10
- "version"
6
+ def instance
7
+ @instance ||= Class.new(::ActiveRecord::SchemaMigration) do
8
+ define_singleton_method(:table_name) { ActiveRecord::Base.table_name_prefix + 'data_migrations' + ActiveRecord::Base.table_name_suffix }
9
+ define_singleton_method(:primary_key) { "version" }
10
+ end
11
11
  end
12
12
  end
13
13
  end
14
14
  end
15
-
@@ -1,3 +1,3 @@
1
1
  module DataMigrate
2
- VERSION = "8.1.1".freeze
2
+ VERSION = "8.3.0".freeze
3
3
  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: 8.1.1
4
+ version: 8.3.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: 2022-08-02 00:00:00.000000000 Z
13
+ date: 2022-12-07 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord
@@ -291,7 +291,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
291
291
  - !ruby/object:Gem::Version
292
292
  version: '0'
293
293
  requirements: []
294
- rubygems_version: 3.3.7
294
+ rubygems_version: 3.3.26
295
295
  signing_key:
296
296
  specification_version: 4
297
297
  summary: Rake tasks to migrate data alongside schema changes.