seed_migration 1.0.7 → 1.1.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
  SHA1:
3
- metadata.gz: 25b109dd90d39710c5e83601de1b3f600b0192a4
4
- data.tar.gz: 31a55f54dc8ebcb5cf10ec606d8fcb0e461d62eb
3
+ metadata.gz: 78f4daf16c4c6c80bcd1774606a1873b860eedf0
4
+ data.tar.gz: 36d0c48eb0420bcb7ceba3cf287384eab7e71977
5
5
  SHA512:
6
- metadata.gz: 4c9a3ca38d24a54da31289a60d4066ba64210a2bee5724d6a074a892d0e5886139948965c217f58e856581c9dc9ea227bd85df30ea720861c7cb1dfda909135b
7
- data.tar.gz: af62786175f769797e3e77a10f82e2f20366d77abfe4aae0b5f85fb76f6bfb2c5960ec960c7ec77329966d9e89d28f6bb16f043ca8bb866a04ca9a57cfc982a3
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!` statements
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}.create(#{JSON.parse(sorted_attributes.to_json).to_s}, :without_protection => true)"
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}.create(#{JSON.parse(sorted_attributes.to_json).to_s})"
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,3 +1,3 @@
1
1
  module SeedMigration
2
- VERSION = "1.0.7"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -1,11 +1,15 @@
1
1
  namespace :seed do
2
- desc "Run new data migrations."
3
- task :migrate => :environment do
4
- SeedMigration::Migrator.run_migrations(ENV['MIGRATION'])
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
- desc "Revert last data migration."
8
- task :rollback => :environment do
9
- SeedMigration::Migrator.rollback_migrations(ENV["MIGRATION"], ENV["STEP"] || ENV["STEPS"] || 1)
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.7
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-10 00:00:00.000000000 Z
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.1
145
+ rubygems_version: 2.4.5
146
146
  signing_key:
147
147
  specification_version: 4
148
148
  summary: Rails Data Migration