seed_migration 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/seed_migration/migrator.rb +25 -21
- data/lib/seed_migration/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f8cbe10525d9a825e5345594b8ba3095fe7d63ed
|
4
|
+
data.tar.gz: c90f8982dac4016e9a4ca2bcb76455cae8c0e099
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d25e906db4e6b95970fc98d06408689a3863253de53b09d44218a4455d8ba6e2185aede1ab688be073741f8001ab5fb998dc29b41ed31ff558d9115ada285f0e
|
7
|
+
data.tar.gz: 0e3e8a0dbd56640b66f50ceea6d6ef704eb038cfd544831e721247615cdb777ffdbb7ed1acb489ea864788ec199ef1109782afbfba299d74231beb3173b0813d
|
@@ -22,21 +22,23 @@ module SeedMigration
|
|
22
22
|
|
23
23
|
start_time = Time.now
|
24
24
|
announce("#{klass}: migrating")
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
25
|
+
ActiveRecord::Base.transaction do
|
26
|
+
klass.new.up
|
27
|
+
end_time = Time.now
|
28
|
+
runtime = (end_time - start_time).to_d.round(2)
|
29
|
+
|
30
|
+
# Create record
|
31
|
+
migration = SeedMigration::DataMigration.new
|
32
|
+
migration.version = version
|
33
|
+
migration.runtime = runtime.to_i
|
34
|
+
migration.migrated_on = DateTime.now
|
35
|
+
begin
|
36
|
+
migration.save!
|
37
|
+
rescue Exception => e
|
38
|
+
puts e
|
39
|
+
end
|
40
|
+
announce("#{klass}: migrated (#{runtime}s)")
|
38
41
|
end
|
39
|
-
announce("#{klass}: migrated (#{runtime}s)")
|
40
42
|
end
|
41
43
|
|
42
44
|
def down
|
@@ -52,13 +54,15 @@ module SeedMigration
|
|
52
54
|
# Revert
|
53
55
|
start_time = Time.now
|
54
56
|
announce("#{klass}: reverting")
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
57
|
+
ActiveRecord::Base.transaction do
|
58
|
+
klass.new.down
|
59
|
+
end_time = Time.now
|
60
|
+
runtime = (end_time - start_time).to_d.round(2)
|
61
|
+
|
62
|
+
# Delete record of migration
|
63
|
+
migration.destroy
|
64
|
+
announce("#{klass}: reverted (#{runtime}s)")
|
65
|
+
end
|
62
66
|
end
|
63
67
|
|
64
68
|
# Rake methods
|
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.4
|
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-09-30 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: sqlite3
|
@@ -132,3 +132,4 @@ signing_key:
|
|
132
132
|
specification_version: 4
|
133
133
|
summary: Rails Data Migration
|
134
134
|
test_files: []
|
135
|
+
has_rdoc:
|