seed_migration 1.0.7 → 1.1.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 +4 -4
- data/README.md +2 -1
- data/lib/seed_migration/engine.rb +6 -0
- data/lib/seed_migration/migrator.rb +6 -2
- data/lib/seed_migration/version.rb +1 -1
- data/lib/tasks/seed_migration_tasks.rake +10 -6
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 78f4daf16c4c6c80bcd1774606a1873b860eedf0
|
4
|
+
data.tar.gz: 36d0c48eb0420bcb7ceba3cf287384eab7e71977
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40d9f2546b0eb5fe9fc65a9375a41a0d6a5abbbb56ea32eea845bb83dacad0ee3165d3c77908cf19a407344d8998ee0640ddcb8d72ae13ee600008696be05b3a
|
7
|
+
data.tar.gz: b15825df57b3c3a5a6793446a473f1a13e5d4af0ccbe79835b125a5129f8fb6f57e5483a28123019062d621d792ea914572aed3a267eecbcd8eeab01a65f4bbc
|
data/README.md
CHANGED
@@ -132,7 +132,7 @@ Here is the basic process to follow to ensure a smooth transition:
|
|
132
132
|
- Clean your local database, and seed it, that can be done with `rake db:reset`
|
133
133
|
- register all the models that were created in the original seeds file
|
134
134
|
- run `rake seed:migrate`
|
135
|
-
- At this point, your seeds file will be rewritten with all the `create
|
135
|
+
- At this point, your seeds file will be rewritten with all the `create` statements
|
136
136
|
- Commit/Push the updated seeds file
|
137
137
|
|
138
138
|
### Deployment notes
|
@@ -185,6 +185,7 @@ Use an initializer file for configuration.
|
|
185
185
|
- `extend_native_migration_task (default=false)`
|
186
186
|
- `ignore_ids (default=false)`
|
187
187
|
- `migration_table_name (default='seed_migration_data_migrations')`: Override the table name for the internal model that holds the migrations
|
188
|
+
- `use_strict_create (default=false)`: Use `create!` instead of `create` in `db/seeds.rb` when set to true
|
188
189
|
|
189
190
|
#### example:
|
190
191
|
|
@@ -8,12 +8,14 @@ module SeedMigration
|
|
8
8
|
mattr_accessor :ignore_ids
|
9
9
|
mattr_accessor :update_seeds_file
|
10
10
|
mattr_accessor :migrations_path
|
11
|
+
mattr_accessor :use_strict_create
|
11
12
|
|
12
13
|
self.migration_table_name = 'seed_migration_data_migrations' # Hardcoded, evil!
|
13
14
|
self.extend_native_migration_task = false
|
14
15
|
self.ignore_ids = false
|
15
16
|
self.update_seeds_file = true
|
16
17
|
self.migrations_path = 'data'
|
18
|
+
self.use_strict_create = false
|
17
19
|
end
|
18
20
|
|
19
21
|
def self.config(&block)
|
@@ -27,6 +29,10 @@ module SeedMigration
|
|
27
29
|
end
|
28
30
|
end
|
29
31
|
|
32
|
+
def self.use_strict_create?
|
33
|
+
use_strict_create
|
34
|
+
end
|
35
|
+
|
30
36
|
class Engine < ::Rails::Engine
|
31
37
|
isolate_namespace SeedMigration
|
32
38
|
|
@@ -247,9 +247,9 @@ SeedMigration::Migrator.bootstrap(#{last_migration})
|
|
247
247
|
end
|
248
248
|
|
249
249
|
if Rails::VERSION::MAJOR == 3 || defined?(ActiveModel::MassAssignmentSecurity)
|
250
|
-
model_creation_string = "#{instance.class}
|
250
|
+
model_creation_string = "#{instance.class}.#{create_method}(#{JSON.parse(sorted_attributes.to_json).to_s}, :without_protection => true)"
|
251
251
|
elsif Rails::VERSION::MAJOR == 4
|
252
|
-
model_creation_string = "#{instance.class}
|
252
|
+
model_creation_string = "#{instance.class}.#{create_method}(#{JSON.parse(sorted_attributes.to_json).to_s})"
|
253
253
|
end
|
254
254
|
|
255
255
|
# With pretty indents, please.
|
@@ -258,5 +258,9 @@ SeedMigration::Migrator.bootstrap(#{last_migration})
|
|
258
258
|
#{model_creation_string}
|
259
259
|
eos
|
260
260
|
end
|
261
|
+
|
262
|
+
def self.create_method
|
263
|
+
SeedMigration.use_strict_create? ? 'create!' : 'create'
|
264
|
+
end
|
261
265
|
end
|
262
266
|
end
|
@@ -1,11 +1,15 @@
|
|
1
1
|
namespace :seed do
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
if !Rake::Task.task_defined?("seed:migrate")
|
3
|
+
desc "Run new data migrations."
|
4
|
+
task :migrate => :environment do
|
5
|
+
SeedMigration::Migrator.run_migrations(ENV['MIGRATION'])
|
6
|
+
end
|
5
7
|
end
|
6
8
|
|
7
|
-
|
8
|
-
|
9
|
-
|
9
|
+
if !Rake::Task.task_defined?("seed:rollback")
|
10
|
+
desc "Revert last data migration."
|
11
|
+
task :rollback => :environment do
|
12
|
+
SeedMigration::Migrator.rollback_migrations(ENV["MIGRATION"], ENV["STEP"] || ENV["STEPS"] || 1)
|
13
|
+
end
|
10
14
|
end
|
11
15
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: seed_migration
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy O'Neill
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2015-11-
|
14
|
+
date: 2015-11-30 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: sqlite3
|
@@ -142,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
142
142
|
version: '0'
|
143
143
|
requirements: []
|
144
144
|
rubyforge_project:
|
145
|
-
rubygems_version: 2.4.5
|
145
|
+
rubygems_version: 2.4.5
|
146
146
|
signing_key:
|
147
147
|
specification_version: 4
|
148
148
|
summary: Rails Data Migration
|