seed_migration 1.0.2 → 1.0.3

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: 38f8055cf600a0ea55f7ae4b315f1b534a448779
4
- data.tar.gz: 2629240a52ecda680e6fec7b29ad46f05a0eba20
3
+ metadata.gz: 1b14ff645f5d47de31e2ddf8827739c5144d7def
4
+ data.tar.gz: dcaea217bc557ea81df7b60c9a3bae5197c24343
5
5
  SHA512:
6
- metadata.gz: 78cf3c5d47ec09b44d44404d4ef7c26881d4365318517984fc34698285cf336de5c40cb2e7290a17cf37a5d1e3e95537128e992020aac66f60ad2ab3f3d33fec
7
- data.tar.gz: b1e061859b4e9fa78a4b43d4d6fc7cdb37c6d337b589f2d4cd8c57b0c4d83557bc65d1ab3664b7a8ca04c5d6dbe6aaf5efdf8c9dedaec5eaa902f46bc9829b48
6
+ metadata.gz: 9638eb0ce5375411847366c4ea0dbb34d71adbe0ee286d572907090dd8eec88ea2437addf95ff7ad06a1ae2fa5f9c0712bc787414594c4c5489e0a683ec53a6c
7
+ data.tar.gz: 55b8773cd27aa52b6eafc25bf9c56f0db99dabe09129200688e1d542ed2e03053baa6b001f9dad9e50c124589bbebac2e4e179081d358654d419ae626b0dabf8
data/README.md CHANGED
@@ -104,7 +104,7 @@ This will create a `seeds.rb` containing all User and Product in the database:
104
104
  # of editing this file, please use the migrations feature of Seed Migration to
105
105
  # incrementally modify your database, and then regenerate this seed file.
106
106
  #
107
- # If you need to create see the database on another system, you should be using
107
+ # If you need to create the database on another system, you should be using
108
108
  # db:seed, not running all the migrations from scratch. The latter is a flawed
109
109
  # and unsustainable approach (the more migrations you'll amass, the slower
110
110
  # it'll run and the greater likelihood for issues).
@@ -122,6 +122,8 @@ end
122
122
  SeedMigration::Migrator.bootstrap(20140404193326)
123
123
  ```
124
124
 
125
+ Note that `seeds.rb` is only generated in development mode. Production data will not be dumped in this process.
126
+
125
127
  ### Adding seed_migrations to an existing app
126
128
 
127
129
  If your app already contains seeds, using this gem could cause some issues.
@@ -1,13 +1,13 @@
1
1
  class CreateDataMigrations < ActiveRecord::Migration
2
- def up
3
- create_table SeedMigration.migration_table_name do |t|
4
- t.string :version
5
- t.integer :runtime
6
- t.datetime :migrated_on
7
- end
2
+ def up
3
+ create_table SeedMigration.migration_table_name do |t|
4
+ t.string :version
5
+ t.integer :runtime
6
+ t.datetime :migrated_on
8
7
  end
8
+ end
9
9
 
10
- def down
11
- drop_table SeedMigration.migration_table_name
12
- end
10
+ def down
11
+ drop_table SeedMigration.migration_table_name
12
+ end
13
13
  end
@@ -4,15 +4,30 @@ require 'rails/generators/named_base'
4
4
  module SeedMigration
5
5
  module Generators
6
6
  class SeedMigrationGenerator < Rails::Generators::NamedBase
7
-
8
- namespace "seed_migration"
9
- desc "Creates a seed migration"
7
+ namespace 'seed_migration'
8
+ desc 'Creates a seed migration'
10
9
  class_option :migration_name, :type => :string, :default => nil
11
10
  argument :timestamp, :type => :string, :required => false, :default => Time.now.utc.strftime("%Y%m%d%H%M%S")
12
11
 
13
12
  def create_seed_migration_file
14
13
  path = SeedMigration::Migrator::DATA_MIGRATION_DIRECTORY
15
- create_file path.join("#{timestamp}_#{file_name.gsub(/([A-Z])/, '_\1').downcase}.rb"),"class #{file_name.camelize} < SeedMigration::Migration\n def up\n \n end\n\n def down\n \n end\nend"
14
+ create_file path.join("#{timestamp}_#{file_name.gsub(/([A-Z])/, '_\1').downcase}.rb"), contents
15
+ end
16
+
17
+ private
18
+
19
+ def contents
20
+ <<STRING
21
+ class #{file_name.camelize} < SeedMigration::Migration
22
+ def up
23
+
24
+ end
25
+
26
+ def down
27
+
28
+ end
29
+ end
30
+ STRING
16
31
  end
17
32
  end
18
33
  end
@@ -201,7 +201,7 @@ module SeedMigration
201
201
  # of editing this file, please use the migrations feature of Seed Migration to
202
202
  # incrementally modify your database, and then regenerate this seed file.
203
203
  #
204
- # If you need to create see the database on another system, you should be using
204
+ # If you need to create the database on another system, you should be using
205
205
  # db:seed, not running all the migrations from scratch. The latter is a flawed
206
206
  # and unsustainable approach (the more migrations you'll amass, the slower
207
207
  # it'll run and the greater likelihood for issues).
@@ -1,3 +1,3 @@
1
1
  module SeedMigration
2
- VERSION = "1.0.2"
2
+ VERSION = "1.0.3"
3
3
  end
@@ -5,6 +5,7 @@ module SeedMigration
5
5
  autoload :Migrator, "seed_migration/migrator" # Is it needed ?
6
6
  autoload :Migration, "seed_migration/migration"
7
7
  autoload :RegisterEntry, "seed_migration/register_entry"
8
+ autoload :DataMigration, "seed_migration/data_migration"
8
9
 
9
10
  @@registrar = Set.new
10
11
  mattr_accessor :registrar
@@ -6,6 +6,6 @@ namespace :seed do
6
6
 
7
7
  desc "Revert last data migration."
8
8
  task :rollback => :environment do
9
- SeedMigration::Migrator.rollback_migrations(ENV["MIGRATION"], ENV["STEP"] || 1)
9
+ SeedMigration::Migrator.rollback_migrations(ENV["MIGRATION"], ENV["STEP"] || ENV["STEPS"] || 1)
10
10
  end
11
11
  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.2
4
+ version: 1.0.3
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: 2014-06-17 00:00:00.000000000 Z
14
+ date: 2014-08-15 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: sqlite3