data_migrate 9.4.1 → 9.4.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aa16e421f2f5d046c5e78678b226574ddaeca7345bfcff5f8ab69091fb901f3c
4
- data.tar.gz: 91d60c54724dc47e6aac6f7638275c005c0f27f052741c00fbed0f15fb8056b7
3
+ metadata.gz: b061a1b90d162a48df5225719ec96da94aaa77d0580d952a1ff0f4cb895e452e
4
+ data.tar.gz: bc78e03d816377c6a784b8102ce9f6c9504ee4650839436a92b1a949bce6a45d
5
5
  SHA512:
6
- metadata.gz: e0585dd9cc369cfbb980c609d1c7f1cc286a3109f799303d1518cca460f1e41b89df484154426e8e6798cd674f520241d19ab4bd2343bb0800e429de78b7d379
7
- data.tar.gz: 52aeb1ce48bcf2644f8c4640b99d5dbb98bee62e10fa5f3a20fabff41eb3dc833c346c39b51245a128095eb75231d588ca734092056aedbff62bfa1df6512888
6
+ metadata.gz: 5c612eefd1985b3935c79c87039f1f67db81088a1984fb4e90d15c361d9c0fd90b9acefaeb131ec4b77f22a56f6524a99444e663b5e2e2a820115864b09471ed
7
+ data.tar.gz: b2ce56c6fd8510adb0eb465fc765df93fdce42f6d7f81e809276bbaf29f7e1891dd7638191e395af0afb774f1ced8fc33387a9619b09edf24cde824b03aa00a6
data/Changelog.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Changelog
2
2
 
3
+ ## 9.4.2
4
+ - Fix db:prepare:with_data task
5
+
3
6
  ## 9.4.1
4
7
  - Add db:prepare task
5
8
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- data_migrate (9.4.1)
4
+ data_migrate (9.4.2)
5
5
  activerecord (>= 6.1)
6
6
  railties (>= 6.1)
7
7
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- data_migrate (9.4.1)
4
+ data_migrate (9.4.2)
5
5
  activerecord (>= 6.1)
6
6
  railties (>= 6.1)
7
7
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- data_migrate (9.4.1)
4
+ data_migrate (9.4.2)
5
5
  activerecord (>= 6.1)
6
6
  railties (>= 6.1)
7
7
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- data_migrate (9.4.1)
4
+ data_migrate (9.4.2)
5
5
  activerecord (>= 6.1)
6
6
  railties (>= 6.1)
7
7
 
@@ -204,5 +204,42 @@ module DataMigrate
204
204
  end
205
205
  end
206
206
  end
207
+
208
+ def self.prepare_all_with_data
209
+ seed = false
210
+
211
+ each_current_configuration(env) do |db_config|
212
+ next unless db_config.primary?
213
+
214
+ with_temporary_pool(db_config) do
215
+ begin
216
+ database_initialized = migration_connection.schema_migration.table_exists?
217
+ rescue ActiveRecord::NoDatabaseError
218
+ create(db_config)
219
+ retry
220
+ end
221
+
222
+ unless database_initialized
223
+ if File.exist?(schema_dump_path(db_config))
224
+ load_schema(db_config, ActiveRecord.schema_format, nil)
225
+ load_schema_current(
226
+ :ruby,
227
+ ENV["DATA_SCHEMA"]
228
+ )
229
+ end
230
+
231
+ seed = true
232
+ end
233
+
234
+ migrate_with_data
235
+ if ActiveRecord.dump_schema_after_migration
236
+ dump_schema(db_config)
237
+ DataMigrate::Tasks::DataMigrateTasks.dump
238
+ end
239
+ end
240
+ end
241
+
242
+ load_seed if seed
243
+ end
207
244
  end
208
245
  end
@@ -1,3 +1,3 @@
1
1
  module DataMigrate
2
- VERSION = "9.4.1".freeze
2
+ VERSION = "9.4.2".freeze
3
3
  end
data/tasks/databases.rake CHANGED
@@ -146,6 +146,13 @@ namespace :db do
146
146
  end
147
147
  end
148
148
  end
149
+
150
+ namespace :prepare do
151
+ desc "Runs setup if database does not exist, or runs data and schema migrations if it does"
152
+ task with_data: :environment do
153
+ DataMigrate::DatabaseTasks.prepare_all_with_data
154
+ end
155
+ end
149
156
  end
150
157
 
151
158
  namespace :data do
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: 9.4.1
4
+ version: 9.4.2
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: 2024-08-13 00:00:00.000000000 Z
13
+ date: 2024-08-14 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord