migrext 0.1 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/migrext/rails.rb +5 -3
- metadata +2 -2
data/lib/migrext/rails.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
|
2
2
|
require 'yaml'
|
3
|
+
require 'pathname'
|
3
4
|
|
4
5
|
module MigrExt
|
5
6
|
class RailsApplication
|
@@ -23,10 +24,11 @@ module MigrExt
|
|
23
24
|
end
|
24
25
|
|
25
26
|
def create_migration!(version, name, content)
|
26
|
-
|
27
|
-
raise RuntimeError, "Migration #{version}:#{name} exist" if
|
27
|
+
filepath = Pathname.new("#@base_dir/db/migrate/#{version}_#{name.underscore}.rb")
|
28
|
+
raise RuntimeError, "Migration #{version}:#{name} exist" if filepath.exist?
|
28
29
|
|
29
|
-
|
30
|
+
filepath.dirname.mkpath
|
31
|
+
filepath.open("w") {|f| f.write content }
|
30
32
|
@current_migrations = nil
|
31
33
|
end
|
32
34
|
|