seed_migration 1.0.2 → 1.0.3
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 +3 -1
- data/db/migrate/20140310150145_create_data_migrations.rb +9 -9
- data/lib/generators/seed_migration/seed_migration_generator.rb +19 -4
- data/lib/seed_migration/migrator.rb +1 -1
- data/lib/seed_migration/version.rb +1 -1
- data/lib/seed_migration.rb +1 -0
- data/lib/tasks/seed_migration_tasks.rake +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b14ff645f5d47de31e2ddf8827739c5144d7def
|
4
|
+
data.tar.gz: dcaea217bc557ea81df7b60c9a3bae5197c24343
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
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
|
-
|
11
|
-
|
12
|
-
|
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
|
-
|
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"),
|
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
|
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).
|
data/lib/seed_migration.rb
CHANGED
@@ -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.
|
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-
|
14
|
+
date: 2014-08-15 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: sqlite3
|